Code: Select all
bind pub - !whoami proc_whoami
##
proc proc_whoami {nick host hand channel text} {
global botnick
if {[matchattr $nick +n]} {
putserv "NOTICE $nick :$nick, you are my Lord. How may I serve you?"
return 1
}
if {[matchattr $nick +qd]} {
putserv "NOTICE $nick :$nick, you are on a Global Blacklist for either NO-OPs, NO-VOICE, or both for any channel that I am on!"
putserv "NOTICE $nick :If you think that this is a mistake, please contact my owner."
return 1
}
if {[matchattr $nick |+qd $channel]} {
putserv "NOTICE $nick :$nick, you are on my Blacklist for either NO-OPs, NO-VOICE, or both for channel $channel!"
putserv "NOTICE $nick :If you think that this is a mistake, please contact the channel owner."
return 1
}
if {[matchattr $nick |+n $channel]} {
putserv "NOTICE $nick :$nick, you are a channel OWNER on $channel."
return 1
}
if {[matchattr $nick |+m $channel]} {
putserv "NOTICE $nick :$nick, you are a channel MASTER on $channel."
return 1
}
if {[matchattr $nick |+o $channel]} {
putserv "NOTICE $nick :$nick, you are a channel OPs on $channel."
return 1
}
if {[matchattr $nick |+l $channel]} {
putserv "NOTICE $nick :$nick, you are a channel HALFOPs on $channel."
return 1
}
if {[matchattr $nick |+f $channel]} {
putserv "NOTICE $nick :$nick, you are a channel FRIEND on $channel."
return 1
}
if {[matchattr $nick |+v $channel]} {
putserv "NOTICE $nick :$nick, you are a channel VOICE-USER on $channel."
return 1
} else {
putserv "NOTICE $nick :$nick, you are \002NOT\002 on my Channel-List for channel $channel."
putserv "NOTICE $nick :If you think that this is an error and that I should recognize you, then please \002/msg $botnick ident <your-password>\002."
putserv "NOTICE $nick :In case you are using a nickname other than the one I normally recognize you under, then please \002/msg $botnick <your-password> <your-normal-nickname>\002."
putserv "NOTICE $nick :If non of the above solutions worked for you, then please contact the channel admin for $channel."
return 1
}
}
Code: Select all
bind pub n|m !checkuser proc_checkuser
##
proc proc_checkuser {nick host hand channel text} {
global botnick
set who [lindex [split $text] 0]
if {($who == $botnick)} {
putserv "NOTICE $nick :I am a \002bot\002 $nick."
return 1
}
if {$who == ""} {
putserv "NOTICE $nick :Usage: !checkuser <nick>"
return 1
}
if {![onchan $who $channel]} {
putserv "NOTICE $nick :I dont see $who on $channel"
putserv "NOTICE $nick :The user you wish to check \002must\002 be in $channel when issuing the command."
return 1
}
if {[matchattr $who +n]} {
putserv "NOTICE $nick :$nick, $who is my OWNER."
return 1
}
if {[matchattr $who +qd]} {
putserv "NOTICE $nick :$nick, the user \002$who\002 is for some reason \002NOT\002 allowed to get OPs or VOICE on \002ANY\002 channel where I am on!"
putserv "NOTICE $nick :This action has been issued due to either an abuse towards the bot, or as a security pre-caution."
putserv "NOTICE $nick :If you think that this is an error, please contact my owner."
return 1
}
if {[matchattr $who |+qd $channel]} {
putserv "NOTICE $nick :$nick, the user \002$who\002 is for some reason \002NOT\002 allowed to get OPS or VOICE on channel $channel!"
putserv "NOTICE $nick :This action has been issued due to either an abuse towards the bot, or as a security pre-caution."
putserv "NOTICE $nick :If you think that this is an error, please contact the owner of channel $channel."
return 1
}
if {[matchattr $who |+n $channel]} {
putserv "NOTICE $nick :$who is a channel OWNER on $channel."
return 1
}
if {[matchattr $who |+m $channel]} {
putserv "NOTICE $nick :$who is a channel MASTER on $channel."
return 1
}
if {[matchattr $who |+o $channel]} {
putserv "NOTICE $nick :$who is a channel OPs on $channel."
return 1
}
if {[matchattr $who |+l $channel]} {
putserv "NOTICE $nick :$who is a channel HALFOPs on $channel."
return 1
}
if {[matchattr $who |+f $channel]} {
putserv "NOTICE $nick :$who is a channel FRIEND on $channel."
return 1
}
if {[matchattr $who |+v $channel]} {
putserv "NOTICE $nick :$who is a channel VOICE-USER on $channel."
return 1
} else {
putserv "NOTICE $nick :$who is \002NOT\002 on my Channel-List for $channel $nick."
return 1
}
}
No more than 1,000, more like 800Edit:
How many names to you expect to be ever be in your file? ... just curious.
ViciousPiranha wrote:Honestly I do not mind how the file would look like as long as it would be easy to set for each user his 'level' and the bot will will be able to retrieve it too
...
Code: Select all
# April 19, 2013
# http://forum.egghelp.org/viewtopic.php?p=101413#101413
# Usage:
# !level
# or
# !level <name>
#########################
## set path/filename of user nick/level file here
set userlevelfile "scripts/added/forum_requests/userlevelfile.txt"
bind pub - "!level" say_level
proc say_level {nick uhost handle chan text} {
global userlevelfile
if {![file exists $userlevelfile]} {
putserv "privmsg $chan :$nick: Sorry, $userlevelfile not found"
return 0
}
#reference http://forum.egghelp.org/viewtopic.php?t=6885
set fname $userlevelfile
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]
if {![llength [split $text]]} {
if {[lsearch -nocase -index 0 $lines $nick] == -1} {
putserv "privmsg $chan :Sorry, $nick is not in list"
return 0
}
putserv "privmsg $chan :Hey $nick, your level is: [lindex $lines [lsearch -nocase -index 0 $lines $nick] 1]"
} else {
if {[lsearch -nocase -index 0 $lines [lindex [split $text] 0] ] == -1} {
putserv "privmsg $chan :Sorry, [lindex [split $text] 0] is not in list"
return 0
}
putserv "privmsg $chan :User: [lindex $lines [lsearch -nocase -index 0 $lines [lindex [split $text] 0] ] 0] Level: [lindex $lines [lsearch -nocase -index 0 $lines [lindex [split $text] 0] ] 1] "
# Beware of line wrapping when copy-n-pasting. The immediate above is all on one line.
}
}
Code: Select all
Aaron VIP
Tony Stranger
LoKii voice
Moran whatever
Bill nobody
Tom regular
John VIP
George voice
Jim Op
Jeff banned
Charles novice
jaCK_test bozo
herman 2
boo 0
foo 1
ViciousPiranha wrote: ...
and also make sure they dont flood the bot with too many requests (only 1 for each 10 seconds)
...
Code: Select all
# April 19, 2013
# http://forum.egghelp.org/viewtopic.php?p=101413#101413
#########################
## set path/filename of user nick/level file here
set userlevelfile "scripts/added/forum_requests/userlevelfile.txt"
bind pub - "!level" say_level
proc say_level {nick uhost handle chan text} {
global userlevelfile
if {![file exists $userlevelfile]} {
putserv "privmsg $chan :$nick: Sorry, $userlevelfile not found"
return 0
}
#reference http://forum.egghelp.org/viewtopic.php?t=6885
set fname $userlevelfile
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]
if {![llength [split $text]]} {
if {[lsearch -nocase -index 0 $lines $nick] == -1} {
putserv "privmsg $chan :Sorry, $nick is not in list"
return 0
}
#putserv "privmsg $chan :Hey $nick, your level is: [lindex $lines [lsearch -nocase -index 0 $lines $nick] 1]"
putserv "privmsg $chan :Hey $nick, your level is: [lrange [lsearch -nocase -inline -index 0 $lines $nick] 1 end]"
} else {
if {[lsearch -nocase -index 0 $lines [lindex [split $text] 0] ] == -1} {
putserv "privmsg $chan :Sorry, [lindex [split $text] 0] is not in list"
return 0
}
###putserv "privmsg $chan :User: [lindex $lines [lsearch -nocase -index 0 $lines [lindex [split $text] 0] ] 0] Level: [lindex $lines [lsearch -nocase -index 0 $lines [lindex [split $text] 0] ] 1] "
putserv "privmsg $chan :User: [lindex $lines [lsearch -nocase -index 0 $lines [lindex [split $text] 0] ] 0] Level: [lrange [lsearch -nocase -inline -index 0 $lines [lindex [split $text] 0]] 1 end] "
## Again, beware of line wrapping when copy-n-pasting
}
}
Code: Select all
Aaron VIP one something whatever
Tony Stranger
LoKii voice
Moran whatever
Bill nobody
Tom regular yak yak blah blah
John VIP
George voice
Jim Op
Jeff banned
Charles novice
jaCK_test bozo
herman 2
boo 0
foo 1
Code: Select all
set fh [open "file" r]
while {[gets $fh line] >= 0} {
# work with $line here
}
close $fh
You forgot to clarify who the "you" is that you are speaking to.caesar wrote:If you insist in keeping things into a plain text file,
You forgot to say WHY it is better.then at least choose a better approach like reading line by line,
Perhaps you overlooked it. This is still under discussion. See my post containing a question, above.rather than reading the entire file into buffer:What's even worse is that since there's no flood protection into this,Code: Select all
set fh [open "file" r] while {[gets $fh line] >= 0} { # work with $line here } close $fh
Why will the buffer overflow?so the execution of the code multiple times in a short period of time will just make the script crash the bot with core dump as the buffer is overflowed.
Thanks for the info and the link.