Connecting to MySQL using TCL
So, lately i’ve been playing around with tcl again, and trying to make it work alongside MySQL to store information such as Q auth’s and various other information on users. Its working quite well.
We connect to MySQL through TCL using a package called mysqltcl.
Here is how I connect:
# First we require the mysqltcl package. You normally have to install this. package require mysqltcl set db [::mysql::connect -host localhost -user username -password password -db database]; # Then perform an query... # JOIN # bind join - * rec:join proc rec:join {nick uhost hand chan} { global botnick db if {$nick == $botnick} { return 0 } set result [::mysql::exec $db "INSERT INTO nicks (timestamp,channel,nickname) VALUES(UNIX_TIMESTAMP(),'$chan','$nick')"] }
As you can see, in my example we store the nickname and channel when someone joins a channel your bot is sitting in. A very useful module indeed.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments
No comments yet.
Leave a comment