| View previous topic :: View next topic |
| Author |
Message |
Cerberus Voice
Joined: 01 Sep 2008 Posts: 7
|
Posted: Tue Apr 24, 2012 1:13 pm Post subject: adduser help |
|
|
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
| Code: | 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 |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Apr 24, 2012 2:59 pm Post subject: |
|
|
My first guess would be that your test for "onchan $who $chan" fails, having your script return instantly. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Cerberus Voice
Joined: 01 Sep 2008 Posts: 7
|
Posted: Tue Apr 24, 2012 3:00 pm Post subject: |
|
|
| agreed by how to fix it? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Apr 24, 2012 3:05 pm Post subject: |
|
|
Change it to something like this
| Code: | ...
foreach chan [channels] {
if {[onchan $who $chan]} {
set hostmask [getchanhost $who $chan]
break
}
}
if {![info exists hostmask]} {
puthelp "NOTICE $nick :$cmdtbslg Hostmask: \[$hostmask\] is not a valid hostmask."
return 0
}
... |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Cerberus Voice
Joined: 01 Sep 2008 Posts: 7
|
Posted: Tue Apr 24, 2012 3:06 pm Post subject: |
|
|
ok will try that thanks have put full code at top now to make debugging easier  |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Apr 24, 2012 3:11 pm Post subject: |
|
|
Ohh, you'll have to replace the "info exists" test with $hostmask == "" in my example _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Cerberus Voice
Joined: 01 Sep 2008 Posts: 7
|
Posted: Tue Apr 24, 2012 3:30 pm Post subject: |
|
|
nml375 your awesome that worked perfectly first time and had been blindly staring at that for hours not realising why it failed.
thanks so much now to sort my other little bug and bot is perfect (new thread for that) |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Tue Apr 24, 2012 6:54 pm Post subject: |
|
|
| Code: | 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. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Apr 25, 2012 1:47 am Post subject: |
|
|
Guess you didn't noticed this part of getchanhost documentation:
| Quote: |
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.
Here is how I would do this:
| Code: |
# 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\]."
}
|
_________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Sat Apr 28, 2012 12:22 pm; edited 1 time in total |
|
| Back to top |
|
 |
Cerberus Voice
Joined: 01 Sep 2008 Posts: 7
|
Posted: Sat Apr 28, 2012 3:15 am Post subject: |
|
|
caesar - your code fails with error, any ideas??
Tcl error [msg_+user]: can't read "text": no such variable
speachless - works perfectly thanks  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sat Apr 28, 2012 12:23 pm Post subject: |
|
|
This is why I don't debug other people code. I forgot to replace rest with text. It should be fine now. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
|