chiark
/
gitweb
/
~mdw
/
ircbot
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add people to the relevant chan_nicks when they join. New leave channel manager...
[ircbot]
/
bot.tcl
diff --git
a/bot.tcl
b/bot.tcl
index ad5c908b336f6954fb997381a4c44dbea4f8a3c5..5bbaeb02ae224e51e29ab24c00421f4ddeb61574 100755
(executable)
--- a/
bot.tcl
+++ b/
bot.tcl
@@
-200,7
+200,7
@@
proc onread {args} {
}
if {"$command" == "PRIVMSG" &&
[regexp {^[&#+!]} [lindex $params 0]] &&
}
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
# on-channel message, ignore
catch {
recordlastseen_p $prefix "talking on [lindex $params 0]" 1
@@
-512,6
+512,11
@@
proc leaving {lchan} {
unset nlist
}
unset nlist
}
+proc doleave {lchan} {
+ sendout PART $lchan
+ leaving $lchan
+}
+
proc dojoin {lchan} {
global chan_nicks
sendout JOIN $lchan
proc dojoin {lchan} {
global chan_nicks
sendout JOIN $lchan
@@
-533,8
+538,7
@@
proc check_justme {lchan} {
sendout TOPIC $lchan $topic
}
} else {
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
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} {
nick_ishere $n
}
proc msg_PART {p c chan} {
@@
-824,20
+832,28
@@
proc loadhelp {} {
}
def_ucmd help {
}
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 \
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 \
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 $t
ext
, sorry." {} }
+ upvar #0 help_topics(
$topic
) info
+ if {![info exists info]} { ucmdr "No help on $t
opic
, sorry." {} }
ucmdr $info {}
}
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 {[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
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
}
sendout MODE $target +o $n
}
+def_ucmd leave {
+ channelmgr_monoop
+ doleave $target
+}
+
def_ucmd invite {
global chan_nicks
def_ucmd invite {
global chan_nicks