From: Ian Jackson Date: Fri, 11 Apr 2014 15:21:35 +0000 (+0100) Subject: new topicedit bot X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=8e0940d662357d62802b5be9556428add0cc05d6;p=ircbot.git new topicedit bot --- diff --git a/topicedit.tcl b/topicedit.tcl new file mode 100755 index 0000000..cc33c13 --- /dev/null +++ b/topicedit.tcl @@ -0,0 +1,47 @@ +#!/usr/bin/tclsh8.5 +# usage: +# cd ../ircbot +# ./topicedit.tcl SERVER PORT NICK IDENT FULLNAME CHANNEL TOPICINFO + +source irccore.tcl + +manyset $argv host port nick ident ownfullname channel topicinfo + +set done 0 + +proc connected {} { + global channel + sendout JOIN $channel +} +proc new_event {} { } +proc privmsg_unlogged {args} { return 1 } +proc msg_332 {server code us channel topic args} { + global oldtopic nick + if {[string compare $nick $us]} return + set oldtopic $topic +} +proc msg_333 {server code us channel setter when} { + global nick done + # might happen as a result of us connecting, or as a result of + # our own TOPIC query + set now [clock seconds] + if {![string compare $nick $setter] && $when > $now - 3600} { + if {$done} { + puts "topic set." + exit 0 + } else { + puts stderr "*** topic recently set by us, not setting again!" + exit 1 + } + } +} +proc msg_366 {args} { + global oldtopic topicinfo channel done + set newtopic "$oldtopic | $topicinfo" + sendout TOPIC $channel $newtopic + sendout TOPIC $channel + set done 1 +} + +ensure_connecting +vwait forever