08-18-2017, 14:47 +0200
AuthorPost
thommey  05-26-2005, 20:03   | [EGG] Botnick as trigger (<botnick> do something) Jabber
(Administrator)
Member since 03/2004
62 Posts
It is a bad idea to use                                                                                                                               
1
bind pub - $::botnick ..

 or similar, as the $::botnick variable is not known on startup (only on connect). And it can change which will not result in an automatic unbind and re-bind.
So we bind on * (everything) and check if the first word is our nick. Then we use switch (looks better) to determine the commands.                                                                                                                               
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
bind pubm - * triggercheck
proc triggercheck {nick host hand chan text} {
    set word1 [lindex [split $text] 0]
    set cmd [lindex [split $text] 1]
    set rest [join [lrange [split $text] 2 end]]
    if {![isbotnick $word1]} { return }
    switch -exact -- [string tolower $cmd] {
        "op" {
            if {![matchattr $hand o|o $chan]} { putserv "PRIVMSG $chan :No access"; return }
            if {![onchan $rest $chan]} { putserv "PRIVMSG $chan :$rest is not here"; return }
            putserv "MODE $chan +o $rest"
        }
        "voice" {
            if {![matchattr $hand o|o $chan]} { putserv "PRIVMSG $chan :No access"; return }
            if {![onchan $rest $chan]} { putserv "PRIVMSG $chan :$rest is not here"; return }
            putserv "MODE $chan +v $rest"
        }
        default {
            putserv "PRIVMSG $chan :Unknown command: $cmd"
        }
    }
}


Usage:
BotNick op someone
BotNick voice someone
This post was edited 1 times, last on 08-12-2009, 21:13 by thommey
Advanced options for this topic:

Ignore this topic (Do not list this topic in the "unread topics" search. You are currently not ignoring this topic.)
Hide this topic (Hidden topics are not displayed in the topics list. This topic is currently not hidden.)
Go to forum

Unclassified NewsBoard 1.5.3-d | © 2003-4 by Yves Goergen