| View previous topic :: View next topic |
| Author |
Message |
Youri Voice
Joined: 08 Feb 2005 Posts: 6
|
Posted: Tue Sep 04, 2007 5:40 am Post subject: My request script. [wont validate.] |
|
|
Dear boys, and girls
I made my own script but there's a little problem. If i request the bot, the bot checks if the [requestedchannel] is in the blocklist, if it is he quits the validation. Thats all good, but if the channel is not in the blocklist a error comes up. The bot says [APPROVED] has been approved, validation will begin in a couple seconds. thats also good, the bot joins but does not continue with request:join_chan (the next chan).
View code below:
| Code: | ###########################################################
# Package Name: Request #
# Package Author: Youri < xeonnn@gmail.com > #
# Package Version: 1 #
###########################################################
bind pub -|- .request pub:request
bind msg -|- .help pub:help
proc pub:help {nick uhost handle text} {
putserv "PRIVMSG $nick : \[HELP\] To request the bot, typ .request <channel>"
putserv "PRIVMSG $nick : \[HELP\] The channel needs to have minium 20 people, and you need a operator status."
putserv "PRIVMSG $nick : \[HELP\] If the requested channel doesnt require the rules the bot will leave."
}
proc pub:request {nick uhost handle chan text} {
set requestchannel [string tolower [lindex $text 0]]
set requestnick [split $nick]
set blocked(active) no
set blocked(channels) {
"#help"
"#xeoN.development"
}
foreach block $blocked(channels) {
if { $block == $requestchannel } { set blocked(active) yes }
}
if { $blocked(active) == yes } {
putserv "PRIVMSG $nick : \[ERROR\] $requestchannel has been blocked from the request service."
} else {
channel add $requestchannel
putserv "PRIVMSG $nick : \[APPROVED\] $requestchannel has been approved, validation will begin in a couple seconds."
request:join_chan $requestchannel $requestnick
}
}
proc request:join_chan { requestchannel requestnick } {
set t_users [llength [chanlist $requestchannel]]
set usercheck [expr $t_users - 1]
if { $usercheck >= 20 && [isop $requestnick] } {
putserv "PRIVMSG $requestnick : \[VALIDATION\] Found 20, or more users in $requestchannel ."
putserv "PRIVMSG $requestnick : \[VALIDATION\] You have operator(@)."
putserv "PRIVMSG $requestnick : [\VALIDATION\] The channel meets the requirements, the bot will stay."
} else {
putserv "PRIVMSG $requestnick : \[ERROR\] The channel does not meet the requirements."
putserv "PRIVMSG $requestnick : \[ERROR\] Typ .help to see the requirements."
channel remove $requestchannel
}
} |
|
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Sep 04, 2007 6:01 am Post subject: |
|
|
The problem is most likely due to the fact that your bot most likely hav'nt had time to gather any information about the channel by the time you call request:join_chan. The time for this may be from just a few secs for small channels, to 20secs or more for large channels (basically the time it takes to retrieve the output, and parse it, from a "WHO #channel" request).
I would probably use a timer to delay the member-check a minute or two.
A somewhat more advanced way of doing it would be to manually capturing the data of the who-request using raw bindings. Making any mistakes here might result in your bot behaving very oddly however. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Youri Voice
Joined: 08 Feb 2005 Posts: 6
|
Posted: Tue Sep 04, 2007 9:09 am Post subject: |
|
|
| nml375 wrote: | The problem is most likely due to the fact that your bot most likely hav'nt had time to gather any information about the channel by the time you call request:join_chan. The time for this may be from just a few secs for small channels, to 20secs or more for large channels (basically the time it takes to retrieve the output, and parse it, from a "WHO #channel" request).
I would probably use a timer to delay the member-check a minute or two.
A somewhat more advanced way of doing it would be to manually capturing the data of the who-request using raw bindings. Making any mistakes here might result in your bot behaving very oddly however. |
So the request:join_chan isnt wrong or something? |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Tue Sep 04, 2007 9:43 am Post subject: Re: My request script. [wont validate.] |
|
|
| Youri wrote: | | Code: | putserv "PRIVMSG $requestnick : \[VALIDATION\] You have operator(@)."
putserv "PRIVMSG $requestnick : [\VALIDATION\] The channel meets the requirements, the bot will stay."
|
|
"[\" != "\[" _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
Youri Voice
Joined: 08 Feb 2005 Posts: 6
|
Posted: Tue Sep 04, 2007 10:05 am Post subject: |
|
|
thanks user, works HALFY now
i think i need to work with a timer indeed.  |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Tue Sep 04, 2007 2:15 pm Post subject: |
|
|
Shouldn't need any timers, since the bot will wait til the result of [chanlist] is returned before doing the next commands..
Try putting some "putcmdlog" lines into your script to aid in debugging the process. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Sep 04, 2007 2:19 pm Post subject: |
|
|
chanlist will output the content of eggdrop's internal list of channel-members, it will not trigger a fetch from the server. Thus, if you call it too soon from your eggie joining a channel, you will not get a list of the channel members.
Hence, you'd need to delay that process until the internal list has been fully updated... Either using a timer, or a raw binding triggering on the numeric for "End of who". _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Tue Sep 04, 2007 2:59 pm Post subject: |
|
|
i bind to raw 315 (end of /who), and then continue.
| Code: | ###########################################################
# Package Name: Request #
# Package Author: Youri < xeonnn@gmail.com > #
# Package Version: 1 #
###########################################################
bind pub -|- .request pub:request
bind msg -|- .help pub:help
set requestchannel ""
set requestnick ""
proc pub:help {nick uhost handle text} {
putserv "PRIVMSG $nick : \[HELP\] To request the bot, typ .request <channel>"
putserv "PRIVMSG $nick : \[HELP\] The channel needs to have minium 20 people, and you need a operator status."
putserv "PRIVMSG $nick : \[HELP\] If the requested channel doesnt require the rules the bot will leave."
}
proc pub:request {nick uhost handle chan text} {
global requestchannel requestnick
set requestchannel [string tolower [lindex $text 0]]
set requestnick [split $nick]
set blocked(active) no
set blocked(channels) {
"#help"
"#xeoN.development"
}
foreach block $blocked(channels) {
if { $block == $requestchannel } { set blocked(active) yes }
}
if { $blocked(active) == yes } {
putserv "PRIVMSG $nick : \[ERROR\] $requestchannel has been blocked from the request service."
} else {
catch {bind raw - {315} request:endofwho}
channel add $requestchannel
putserv "PRIVMSG $nick : \[APPROVED\] $requestchannel has been approved, validation will begin in a couple seconds."
}
}
proc request:endofwho {from raw arg} {
global requestchannel requestnick
if {[string equal -nocase [lindex [split $arg] 1] $requestchannel]} {
request:join_chan $requestchannel $requestnick
catch {unbind raw - {315} request:endofwho}
}
}
proc request:join_chan { requestchannel requestnick } {
set t_users [llength [chanlist $requestchannel]]
set usercheck [expr $t_users - 1]
if { $usercheck >= 20 && [isop $requestnick] } {
putserv "PRIVMSG $requestnick : \[VALIDATION\] Found 20, or more users in $requestchannel ."
putserv "PRIVMSG $requestnick : \[VALIDATION\] You have operator(@)."
putserv "PRIVMSG $requestnick : [\VALIDATION\] The channel meets the requirements, the bot will stay."
} else {
putserv "PRIVMSG $requestnick : \[ERROR\] The channel does not meet the requirements."
putserv "PRIVMSG $requestnick : \[ERROR\] Typ .help to see the requirements."
channel remove $requestchannel
}
} |
Might work, might not. _________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Sep 04, 2007 3:11 pm Post subject: |
|
|
Idea looks good, a few thoughts tho..
When working with raw-bindings, the returncode of the proc is very important, as it determines wether any further processing will be done, and bindings added with scripts trigger before those built in. If a return-value is not provided explicitly, an implicit return-value will be generated from the last executed command within the proc (in this case; catch {unbind raw - {315} request:endofwho})
Also, would'nt it be easier to keep the binding active at all times, extract the channel-name from the message body, and check wether this matches the channel you're trying to validate (in theory, the triggered binding may be from a different who-query, although very unlikely). _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Tue Sep 04, 2007 3:24 pm Post subject: |
|
|
if you want the bind active all the time, remove the catch lines and add the bind raw line under the other pub/msg bind lines. _________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Sep 04, 2007 3:29 pm Post subject: |
|
|
Still have to add proper return-values to prevent your eggie from going nuts...
| doc/tcl-commands.doc wrote: | (17) RAW (stackable)
bind raw <flags> <keyword> <proc>
procname <from> <keyword> <text>
Description: previous versions of Eggdrop required a special compile
option to enable this binding, but it's now standard. The keyword
is either a numeric, like "368", or a keyword, such as "PRIVMSG".
from will be the server name or the source user (depending on
the keyword); flags are ignored. The order of the arguments is
identical to the order that the IRC server sends to the bot. The
pre-processing only splits it apart enough to determine the
keyword. If the proc returns 1, Eggdrop will not process the line
any further (this could cause unexpected behavior in some cases).
Module: server
|
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Tue Sep 04, 2007 4:58 pm Post subject: |
|
|
Updated:
| Code: | ###########################################################
# Package Name: Request #
# Package Author: Youri < xeonnn@gmail.com > #
# Package Version: 1 #
###########################################################
bind pub -|- .request pub:request
bind msg -|- .help pub:help
bind raw - {315} request:endofwho
set requestchannel ""
set requestnick ""
proc pub:help {nick uhost handle text} {
putserv "PRIVMSG $nick : \[HELP\] To request the bot, typ .request <channel>"
putserv "PRIVMSG $nick : \[HELP\] The channel needs to have minium 20 people, and you need a operator status."
putserv "PRIVMSG $nick : \[HELP\] If the requested channel doesnt require the rules the bot will leave."
}
proc pub:request {nick uhost handle chan text} {
global requestchannel requestnick
set requestchannel [string tolower [lindex $text 0]]
set requestnick [split $nick]
set blocked(active) no
set blocked(channels) {
"#help"
"#xeoN.development"
}
foreach block $blocked(channels) {
if { $block == $requestchannel } { set blocked(active) yes }
}
if { $blocked(active) == yes } {
putserv "PRIVMSG $nick : \[ERROR\] $requestchannel has been blocked from the request service."
} else {
channel add $requestchannel
putserv "PRIVMSG $nick : \[APPROVED\] $requestchannel has been approved, validation will begin in a couple seconds."
}
}
proc request:endofwho {from raw arg} {
global requestchannel requestnick
if {[string equal -nocase [lindex [split $arg] 1] $requestchannel]} {
request:join_chan $requestchannel $requestnick
return 1
}
}
proc request:join_chan { requestchannel requestnick } {
set t_users [llength [chanlist $requestchannel]]
set usercheck [expr $t_users - 1]
if { $usercheck >= 20 && [isop $requestnick] } {
putserv "PRIVMSG $requestnick : \[VALIDATION\] Found 20, or more users in $requestchannel ."
putserv "PRIVMSG $requestnick : \[VALIDATION\] You have operator(@)."
putserv "PRIVMSG $requestnick : [\VALIDATION\] The channel meets the requirements, the bot will stay."
} else {
putserv "PRIVMSG $requestnick : \[ERROR\] The channel does not meet the requirements."
putserv "PRIVMSG $requestnick : \[ERROR\] Typ .help to see the requirements."
channel remove $requestchannel
}
} |
_________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Tue Sep 04, 2007 11:29 pm Post subject: |
|
|
| nml375 wrote: | chanlist will output the content of eggdrop's internal list of channel-members, it will not trigger a fetch from the server. Thus, if you call it too soon from your eggie joining a channel, you will not get a list of the channel members.
Hence, you'd need to delay that process until the internal list has been fully updated... Either using a timer, or a raw binding triggering on the numeric for "End of who". |
I was not aware of that. Learned something new <tips hat>  |
|
| Back to top |
|
 |
awyeah Revered One

Joined: 26 Apr 2004 Posts: 1580 Location: Switzerland
|
Posted: Wed Sep 05, 2007 4:51 am Post subject: |
|
|
| rosc2112 wrote: | | nml375 wrote: | chanlist will output the content of eggdrop's internal list of channel-members, it will not trigger a fetch from the server. Thus, if you call it too soon from your eggie joining a channel, you will not get a list of the channel members.
Hence, you'd need to delay that process until the internal list has been fully updated... Either using a timer, or a raw binding triggering on the numeric for "End of who". |
I was not aware of that. Learned something new <tips hat>  |
Also you can use the raw binding, with the command: /NAMES #channel
This can be done immediately on join and does not need any delay when called. It will give you the member-list of the channel from the server. Also nicks with ops and voices will have their respective operator sign infront of them. _________________ ·awyeah·
==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
================================== |
|
| Back to top |
|
 |
Youri Voice
Joined: 08 Feb 2005 Posts: 6
|
Posted: Wed Sep 05, 2007 7:23 am Post subject: |
|
|
you missed a ] at | Code: | proc request:endofwho {from raw arg} {
global requestchannel requestnick
if {[string equal -nocase [lindex [split $arg] 1]] $requestchannel]} {
request:join_chan $requestchannel $requestnick
return 1
}
} |
|
|
| Back to top |
|
 |
|