From: Ian Jackson Date: Wed, 31 Jan 2001 17:40:52 +0000 (+0000) Subject: Add people to the relevant chan_nicks when they join. New leave channel manager... X-Git-Tag: branchpoint-2001-10-09-tell~28 X-Git-Url: https://git.distorted.org.uk/~mdw/ircbot/commitdiff_plain/cf6ea4de62f6db0f2d923d2b5f9c009f2cc19fd5?hp=9844e254b5b5f502a4797b460d21c602b6485736 Add people to the relevant chan_nicks when they join. New leave channel manager command. Make lagged help msg work properly. --- diff --git a/bot.tcl b/bot.tcl index ad5c908..5bbaeb0 100755 --- a/bot.tcl +++ b/bot.tcl @@ -200,7 +200,7 @@ proc onread {args} { } if {"$command" == "PRIVMSG" && [regexp {^[&#+!]} [lindex $params 0]] && - ![regexp {^!} [lindex $params 1]]} { + ![regexp {^![a-z][-a-z]*[a-z]( .*)?$} [lindex $params 1]]} { # on-channel message, ignore catch { recordlastseen_p $prefix "talking on [lindex $params 0]" 1 @@ -512,6 +512,11 @@ proc leaving {lchan} { unset nlist } +proc doleave {lchan} { + sendout PART $lchan + leaving $lchan +} + proc dojoin {lchan} { global chan_nicks sendout JOIN $lchan @@ -533,8 +538,7 @@ proc check_justme {lchan} { sendout TOPIC $lchan $topic } } else { - sendout PART $lchan - leaving $lchan + doleave $lchan } } @@ -646,8 +650,12 @@ proc nick_ishere {n} { proc msg_JOIN {p c chan} { prefix_nick recordlastseen_n $n "joining $chan" 1 - upvar #0 nick_onchans([irctolower $n]) oc - lappend oc [irctolower $chan] + set nl [irctolower $n] + set lchan [irctolower $chan] + upvar #0 nick_onchans($nl) oc + upvar #0 chan_nicks($lchan) nlist + lappend oc $lchan + lappend nlist $nl nick_ishere $n } proc msg_PART {p c chan} { @@ -824,20 +832,28 @@ proc loadhelp {} { } def_ucmd help { + upvar 1 n n + + set topic [irctolower [string trim $text]] + if {[string length $topic]} { + set ontopic " on `$topic'" + } else { + set ontopic "" + } if {[set lag [out_lagged]]} { if {[ischan $dest]} { set replyto $dest } else { set replyto $n } if {$lag > 1} { sendaction_priority 1 $replyto \ - "is very lagged. Please ask for help again later." + "is very lagged. Please ask for help$ontopic again later." ucmdr {} {} } else { sendaction_priority 1 $replyto \ - "is lagged. Your help will arrive shortly ..." + "is lagged. Your help$ontopic will arrive shortly ..." } } - upvar #0 help_topics([irctolower [string trim $text]]) info - if {![info exists info]} { ucmdr "No help on $text, sorry." {} } + upvar #0 help_topics($topic) info + if {![info exists info]} { ucmdr "No help on $topic, sorry." {} } ucmdr $info {} } @@ -1143,19 +1159,40 @@ def_chancmd show { } } -def_ucmd op { +proc channelmgr_monoop {} { + upvar 1 dest dest + upvar 1 text text + upvar 1 n n + upvar 1 p p + upvar 1 target target + global chan_nicks + if {[ischan $dest]} { set target $dest } if {[ta_anymore]} { set target [ta_word] } ta_nomore - if {![info exists target]} { error "you must specify, or !... on, the channel" } + if {![info exists target]} { + error "you must specify, or invoke me on, the relevant channel" + } + if {![info exists chan_nicks([irctolower $target])]} { + error "I am not on $target." + } if {![ischan $target]} { error "not a valid channel" } if {![chandb_exists $target]} { error "$target is not a managed channel." } prefix_nick nick_securitycheck 1 channel_securitycheck $target $n +} + +def_ucmd op { + channelmgr_monoop sendout MODE $target +o $n } +def_ucmd leave { + channelmgr_monoop + doleave $target +} + def_ucmd invite { global chan_nicks diff --git a/helpinfos b/helpinfos index 4a55aa4..e801bd3 100644 --- a/helpinfos +++ b/helpinfos @@ -12,6 +12,7 @@ General commands: Registration and user settings: !summon (See `help !identify', `help !blight-id') !invite [] ... Channel settings (see `help channel'): !op [] !channel [] [....] + !leave [] Options: Additional help topics: !timeformat ks|hms !identify !identpass !invite !blight-id Send commands to me by /msg, or say them in channel with \! in front. @@ -54,6 +55,12 @@ op (privately) I'll give you channel operator privilege, if you're a manager. See `help !manager'. +:leave +leave [] on channel +leave (privately) + I'll leave the channel, if you're a manager. For an unmanaged + channel, I'll leave when I'm the last one on the channel. + :channel channel [] [show] show settings channel [] !manager +|-|= ... set manager list