hope you guys can help i have this in a proc in one of the tcl files, i use but for some reason it only work on first channel bot is on and not all channels
proc msg_+user {nick uhost hand rest} {
global botnick thehosts default-flags cmdtbslg
if {![matchattr $hand Q]} {puthelp "NOTICE $nick :$cmdtbslg You haven't authenticate Yourself. Type: \[/msg $botnick auth <password>\] to do so." ; return 0}
set who [lindex $rest 0]
if {$who == ""} {puthelp "NOTICE $nick :$cmdtbslg Command: /msg $botnick +user <handle> \[ip_address\] \[flags\]" ; return 0}
if {[validuser $who]} {puthelp "NOTICE $nick :$cmdtbslg $who already exist in my user list." ; return 0}
set hostmask [lindex $rest 1]
if {$hostmask == ""} {
foreach chan [channels] {
if {[onchan $who $chan]} {set hostmask [getchanhost $who $chan]} else {puthelp "NOTICE $nick :$cmdtbslg $who is not on my channel(s), a <hostmask> must be included in the command." ; return 0}
}
set hostmask [maskhost $nick!$hostmask]
} else {
foreach hostsuser $thehosts {
set hostuser $hostsuser
if {$hostmask == $hostuser} {puthelp "NOTICE $nick :$cmdtbslg Hostmask: \[$hostmask\] is not a valid hostmask." ; return 0}
}
}
adduser $who $hostmask ; puthelp "NOTICE $nick :$cmdtbslg $who is now added to my user list with hostmask: \[$hostmask\]."
set addflags [lindex $rest 2]
if {$addflags == ""} {puthelp "NOTICE $nick :$cmdtbslg No user flags included, I'm going to use my default flag \[${default-flags}\] for this user."}
chattr $who ${default-flags} ; puthelp "NOTICE $nick :$cmdtbslg Standard user's flags ${default-flags} now added for handle: $who ."
save ; puthelp "NOTICE $nick :$cmdtbslg Saving user file."
puthelp "NOTICE $who Welcome $who pleaase set a password by typing /msg $botnick pass <your new pass>."
puthelp "NOTICE $who Once you have set a pass type /msg $botnick auth <yourpassword> each time you connect to irc to login"
putcmdlog "$cmdtbslg <<$nick>> !$hand! +user $who \[$hostmask\]." ; return 0
}
it seems to fail at the foreach command but i dont know why can anyone help me out ??
Last edited by Cerberus on Tue Apr 24, 2012 3:05 pm, edited 2 times in total.
proc msg_+user {nick uhost hand rest} {
global botnick thehosts default-flags cmdtbslg
if {![matchattr $hand Q]} {puthelp "NOTICE $nick :$cmdtbslg You haven't authenticate Yourself. Type: \[/msg $botnick auth <password>\] to do so." ; return 0}
set who [lindex [split $rest] 0]
if {![string length $who]} { puthelp "NOTICE $nick :$cmdtbslg Command: /msg $botnick +user <handle> \[ip_address\] \[flags\]" ; return 0}
if {[validuser $who]} { puthelp "NOTICE $nick :$cmdtbslg $who already exist in my user list." ; return 0}
set hostmask [lindex [split $rest] 1]
if {![string length $hostmask]} {
foreach chan [channels] {
if {[onchan $who $chan]} {
set hostmask [getchanhost $who $chan] ; set found 1
}
}
if {![info exists found]} {
puthelp "NOTICE $nick :$cmdtbslg $who is not on my channel(s), a <hostmask> must be included in the command." ; return 0
}
set hostmask [maskhost $who!$hostmask]
} else {
foreach hostsuser $thehosts {
set hostuser $hostsuser
if {[string equal $hostmask $hostuser]} {puthelp "NOTICE $nick :$cmdtbslg Hostmask: \[$hostmask\] is not a valid hostmask." ; return 0}
}
}
adduser $who $hostmask ; puthelp "NOTICE $nick :$cmdtbslg $who is now added to my user list with hostmask: \[$hostmask\]."
set addflags [lindex [split $rest] 2]
if {![string length $addflags]} {
puthelp "NOTICE $nick :$cmdtbslg No user flags included, I'm going to use my default flag \[${default-flags}\] for this user."
set addflags ${default-flags}
}
chattr $who $addflags
puthelp "NOTICE $nick :$cmdtbslg Standard user's flags $addflags now added for handle: $who ."
puthelp "NOTICE $nick :$cmdtbslg Saving user file."
save
puthelp "NOTICE $who :Welcome $who pleaase set a password by typing /msg $botnick pass <your new pass>."
puthelp "NOTICE $who :Once you have set a pass type /msg $botnick auth <yourpassword> each time you connect to irc to login"
putcmdlog "$cmdtbslg <<$nick>> !$hand! +user $who \[$hostmask\]." ; return 0
}
Here is the code corrected. It had several issues besides the one you mentioned. Here it is all cleaned up and ready for the big show.
Guess you didn't noticed this part of getchanhost documentation:
If a channel is not specified, bot will check all of its channels. If the nickname is not on the channel(s), "" is returned.
So, your foreach loop not only it should break on first match but it's useless by definition.
Instead of validuser $who I would go with nick2hand as user X may already be a known user to the bot registered when he had a different nick. If you don't want check if that handle already exists, then you should add the user check.
# Available types are:
# 0: *!user@host
# 1: *!*user@host
# 2: *!*@host
# 3: *!*user@*.host
# 4: *!*@*.host
# 5: nick!user@host
# 6: nick!*user@host
# 7: nick!*@host
# 8: nick!*user@*.host
# 9: nick!*@*.host
#
# You can also specify types from 10 to 19 which correspond to types
# 0 to 9, but instead of using a * wildcard to replace portions of the
# host, only numbers in hostnames are replaced with the '?' wildcard.
# Same is valid for types 20-29, but instead of '?', the '*' wildcard
# will be used.
set default-mask 1
proc msg_+user {nick uhost hand text} {
global default-flags default-mask cmdtbslg
if {![matchattr $hand Q]} {
puthelp "PRIVMSG $nick :$cmdtbslg You haven't authenticate Yourself. Type: \[/msg $botnick auth <password>\] to do so."
return
}
set count [scan $text {%s%s%s} user hostmask flags]
if {!$count} {
puthelp "PRIVMSG $nick :$cmdtbslg Command: /msg $botnick +user <handle> \[hostmask\] \[flags\]"
return
}
if {[llength [nick2hand $user]]} {
puthelp "PRIVMSG $nick :$cmdtbslg $user already exist in my user list."
return
}
if {$count == 1} {
set hostmask [getchanhost $user]
if {[!llength $hostmask]} {
puthelp "PRIVMSG $nick :$cmdtbslg $user is not on my channel(s), a <hostmask> must be included in the command."
return
} else {
set hostmask [maskhost "$user![getchanhost $user]" ${default-mask}]
}
}
if {[scan $hostmask {%[^!]!%[^@]@%s} n u h] != 3} {
puthelp "PRIVMSG $nick :$cmdtbslg Hostmask: \[$hostmask\] is not a valid hostmask."
return
}
adduser $user $hostmask
puthelp "PRIVMSG $nick :$cmdtbslg $user is now added to my user list with hostmask: \[$hostmask\]."
if {$count != 3} {
puthelp "PRIVMSG $nick :$cmdtbslg No user flags included, I'm going to use the standard user flags \[${default-flags}\] for this user."
set flags ${default-flags}
} else {
puthelp "PRIVMSG $nick :$cmdtbslg Adding user $user with $flags flags."
}
chattr $hand $flags
puthelp "PRIVMSG $nick :$cmdtbslg Saving user file."
save
puthelp "NOTICE $hand :Welcome $user pleaase set a password by typing /msg $botnick pass <your new pass>."
puthelp "NOTICE $hand :Once you have set a pass type /msg $::botnick auth <your password> each time you connect to irc to login"
putcmdlog "$cmdtbslg <<$nick>> !$handle! +user $user \[$hostmask\]."
}
Last edited by caesar on Sat Apr 28, 2012 12:22 pm, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.