| View previous topic :: View next topic |
| Author |
Message |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Thu Apr 26, 2007 8:08 am Post subject: notice script |
|
|
Hi, I am trying to write a code which will send a command to NS when a user type .accountinfo nickname. Then the bot recieves notices and I want those notices to be shown in a channel. Now it;s not working I wonder where is the problem. Can you help me out.
| Code: | ## -NS- Account information for hitshy:
## -NS- Registered on: Sat Jul 30 13:21:23 2005
## -NS- Last seen: Right now!
## -NS- Infoline: None
## -NS- Email address: hitshy@msn.com
## -NS- Flags: +hc
## -NS- Epithet: a Webmaster
## -NS- Last quit hostmask: hitshy@208.98.5.219
## -NS- Nickname(s): Hitshy dean
## -NS- Hostmask(s): *@*
## -NS- Channel(s): 100:#snoopy 300:#opers 499:#NutShells 499:#music 100:#monitor 500:#leb ## -498:#lady 2:#jabal 400:#gudy ## 100:#exempt 500:#Druze 300:#Beirut 499:#a7la3alam
## -NS- Current nickname(s): hitshy
set scriptchannel "#helpers"
bind pub -|- .accountinfo script:text
bind notc -|- "*Account information*" script:notices
bind notc -|- "*Registered on*" script:notices1
bind notc -|- "*Last seen: Right*" script:notices2
bind notc -|- "*Infoline*" script:notices3
# bind notc -|- "*Email address*" script:notices4
# bind notc -|- "*Flags*" script:notices5
# bind notc -|- "*Epithet:*" script:notices6
# bind notc -|- "*Last quit hostmask*" script:notices7
# bind notc -|- "*Nickname(s):*" script:notices8
# bind notc -|- "*Hostmask(s):*" script:notices9
# bind notc -|- "*Channel(s):*" script:notices10
# bind notc -|- "*Current nickname(s)*" script:notices11
proc script:text { nick host handle chan text } {
global botnick
set text [split $text]
set text [lindex $text 0]
if {$text == ""} {puthelp "NOTICE $nick :You need to supply a nickname."; return}
putserv "PRIVMSG ns :accountinfo $text"
}
proc script:notices {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set username [lindex $text 3]
}
proc script:notices1 {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set rdate [lrange $text 2 end]
}
proc script:notices2 {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set lastseen [lrange $text 2 end]
}
proc script:notices3 {nick uhost hand text dest} {
global scriptchannel username rdate lastseen
set text [split $text]
set infoline [lindex $text 1]
putserv "PRIVMSG $scriptchannel :$username $rdate $lastseen"
}
proc script:notices4 {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set email [lindex $text 2]
}
proc script:notices5 {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set rflags [lindex $text 1]
}
proc script:notices6 {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set Epithet [lrange $text 1 end]
}
proc script:notices7 {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set lastquit [lindex $text 3]
}
proc script:notices8 {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set rnicknames [lrange $text 1 end]
}
proc script:notices9 {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set rhost [lindex $text 1]
}
proc script:notices10 {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set rchannels [lrange $text 1 end]
}
proc script:notices11 {nick uhost hand text dest} {
global scriptchannel username rdate lastseen infoline email rflags Epithet lastquit rnicknames rhost rchannels
set text [split $text]
set currentnick [lindex $text 2]
putserv "PRIVMSG $scriptchannel :$username $rdate $lastseen $infoline $email $rflags $Epithet $lastquit $rnicknames $rhost $rchannels"
}
putlog "ns info script loaded by iamdeath.." |
For the test purpose I am currently using first 3 notc binds rest are disabled.
| Code: | [17:16] <Help> [14:16] -NS (NS@service.beirut.com)- Account information for Stefano:
[17:16] <Help> [14:16] -NS (NS@service.beirut.com)- Registered on: Thu Apr 7 12:55:19 2005
[17:16] <Help> [14:16] -NS (NS@service.beirut.com)- Last seen: Right now!
[17:16] <Help> [14:16] Tcl error [script:notices3]: can't read "rdate": no such variable
[17:16] <Help> [14:16] -NS (NS@service.beirut.com)- Infoline: ... FORZA ITALIA !!! ... |
It's not sharing global $rdate $lastseen.
I fixed it 
Last edited by iamdeath on Thu Apr 26, 2007 8:27 am; edited 1 time in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Apr 26, 2007 8:22 am Post subject: |
|
|
| doc/tcl-commands.doc wrote: | (7) NOTC (stackable)
bind notc <flags> <mask> <proc>
procname <nick> <user@host> <handle> <text> <dest>
Description: dest will be a nickname (the bot's nickname,
obviously) or a channel name. mask is matched against the entire
notice and can contain wildcards. It is considered a breach of
protocol to respond to a /notice on IRC, so this is intended for
internal use (logging, etc.) only. Note that server notices do
| not trigger the NOTC bind. If the proc returns 1, Eggdrop will
| not log the message that triggered this bind.
New Tcl procs should be declared as
proc notcproc {nick uhost hand text {dest ""}} {
global botnick; if {$dest == ""} {set dest $botnick}
...
}
for compatibility.
Module: server
|
Services will thus NOT trigger this binding, so this might be one cause. Ignores would obviously inhibit bindings from triggering (except raw bindings).
Could you verify that any of your bindings ever triggered (ie, the hit count for each binding should be greater than 0). _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Thu Apr 26, 2007 8:37 am Post subject: |
|
|
thanks it's fixed.. but could you help me with another thing.
This is the reply I am now getting from the bot.
| Code: | | [17:30] <Help> Stefano: Registered on: Thu Apr {} 7 12:55:19 2005 Last seen: Right now! {} Infoline: ... FORZA ITALIA !!! ... |
What's with {} how do I get rid of them?
NS replies to the bot like:
[17:33] <Help> [14:33] -NS (NS@service.beirut.com)- Account information for Stefano:
[17:33] <Help> [14:33] -NS (NS@service.beirut.com)- Registered on: Thu Apr 7 12:55:19 2005
[17:33] <Help> [14:33] -NS (NS@service.beirut.com)- Last seen: Right now!
[17:33] <Help> [14:33] -NS (NS@service.beirut.com)- Infoline: ... FORZA ITALIA !!! ...
1 more thing with lrange, if you notice I am using
| Code: | proc script:notices1 {nick uhost hand text dest} {
global scriptchannel rdate
set text [split $text]
set rdate [lrange $text 2 end]
} |
So the bot should return only the date not the whole notice. but the bot is replying with
Registered on: Thu Apr {} 7 12:55:19 2005
and I need it to show only
Thu Apr {} 7 12:55:19 2005
so is the case with Lastseen can you guide me on that |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Apr 26, 2007 8:46 am Post subject: |
|
|
as for rdate, etc; you'll have to either make them global in any and all proc's that use 'em, or use full namespace-path (ie ::rdate) when accessing them.
As for the {}, it's because you get empty list-entities while splitting when there's multiple whitespaces. Also, you forget to convert the list back to a string, which reveals these structure-tokens... try using "join" to convert them back into a string... _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Thu Apr 26, 2007 8:50 am Post subject: |
|
|
| What about the lrange problem can you guide me on that? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Apr 26, 2007 8:53 am Post subject: |
|
|
| Code: | | join [lrange [split "Registered on: Thu Apr 7 12:55:19 2005"] 2 end] | works just fine for me (without the join aswell).
Your first post does not make rdate global, as the one in your second last post does; doublechecked that you access the global variable and not just the localspace? _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Thu Apr 26, 2007 8:58 am Post subject: |
|
|
Thanks alot nml but the thing is that, the date changes everytime when a user send a request for another user.
Registered on: Thu Apr 7 12:55:19 2005 every user has a different date, could you tell me another better command for that. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Apr 26, 2007 9:00 am Post subject: |
|
|
I simply took the output from your previous post to simulate your code... _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Thu Apr 26, 2007 9:15 am Post subject: |
|
|
| yes but lrange isn't giving me the appropriate results I want. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Apr 26, 2007 9:19 am Post subject: |
|
|
As I stated, the lrange part works like a charm... you've screwed up somewhere else... (or in bugzilla style INVALID:WORKSFORME) _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Thu Apr 26, 2007 5:14 pm Post subject: |
|
|
iamdeath, nml375 gave you an example on how join solves your problem so you apply it in your code.
| Code: | | set rdate [join [lrange $text 2 end]] |
Now that's not so hard, is it? _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Thu Apr 26, 2007 7:33 pm Post subject: |
|
|
| Thanks alot guys. |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Fri Apr 27, 2007 8:56 pm Post subject: |
|
|
| Code: | #-NS- Account information for hitshy:
## -NS- Registered on: Sat Jul 30 13:21:23 2005
## -NS- Last seen: Right now!
## -NS- Infoline: None
## -NS- Email address: hitshy@msn.com
## -NS- Flags: +hc
## -NS- Epithet: a Webmaster
## -NS- Last quit hostmask: hitshy@208.98.5.219
## -NS- Nickname(s): Hitshy dean
## -NS- Hostmask(s): *@*
## -NS- Channel(s): 100:#snoopy 300:#opers 499:#NutShells 499:#music 100:#monitor 500:#leb ## -498:#lady 2:#jabal 400:#gudy ## 100:#exempt 500:#Druze 300:#Beirut 499:#a7la3alam
## -NS- Current nickname(s): hitshy
set scriptchannel "#helpers"
bind pub -|- .accountinfo script:text
bind notc -|- "*has not been registered.*" script:notices12
bind notc -|- "*outranks you (command has no effect)*" script:notices13
bind notc -|- "*Account information*" script:notices
bind notc -|- "*Registered on*" script:notices1
bind notc -|- "*Last seen: Right*" script:notices2
bind notc -|- "*Infoline*" script:notices3
bind notc -|- "*Email address*" script:notices4
bind notc -|- "*Flags*" script:notices5
bind notc -|- "*Epithet:*" script:notices6
bind notc -|- "*Last quit hostmask*" script:notices7
bind notc -|- "*Nickname(s):*" script:notices8
bind notc -|- "*Hostmask(s):*" script:notices9
bind notc -|- "*Channel(s):*" script:notices10
bind notc -|- "*Current nickname(s)*" script:notices11
proc script:text { nick host handle chan text } {
global scriptchannel rusername rdate lastseen infoline email rflags Epithet lastquit rnicknames rhost rchannels currentnick
set text [split $text]
set text [lindex $text 0]
if {$text == ""} {puthelp "NOTICE $nick :You need to supply a nickname."; return}
putserv "PRIVMSG ns :accountinfo *$text"
}
proc script:notices12 {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set baduser [lindex $text 1]
putquick "PRIVMSG $scriptchannel :\00303Account\003 \00307$baduser\003 \00303has not been registered.\003"
return
}
proc script:notices13 {nick uhost hand text dest} {
global scriptchannel
set text [split $text]
set outrank [lindex $text 0]
putquick "PRIVMSG $scriptchannel :\00307$outrank\003 \00303outranks you (command has no effect).\003"
return
}
proc script:notices {nick uhost hand text dest} {
global scriptchannel rusername
set text [split $text]
set rusername [lindex $text 3]
}
proc script:notices1 {nick uhost hand text dest} {
global scriptchannel rdate
set rdate [lrange $text 2 end]
}
proc script:notices2 {nick uhost hand text dest} {
global scriptchannel lastseen
set lastseen [lrange $text 2 end]
}
proc script:notices3 {nick uhost hand text dest} {
global scriptchannel infoline
set infoline [lrange $text 1 end]
}
proc script:notices4 {nick uhost hand text dest} {
global scriptchannel email
set email [lrange $text 2 end]
}
proc script:notices5 {nick uhost hand text dest} {
global scriptchannel rflags
set rflags [lrange $text 1 end]
}
proc script:notices6 {nick uhost hand text dest} {
global scriptchannel Epithet
set Epithet [lrange $text 1 end]
}
proc script:notices7 {nick uhost hand text dest} {
global scriptchannel lastquit
set lastquit [lrange $text 3 end]
}
proc script:notices8 {nick uhost hand text dest} {
global scriptchannel rnicknames
set rnicknames [lrange $text 1 end]
}
proc script:notices9 {nick uhost hand text dest} {
global scriptchannel rhost
set rhost [lrange $text 1 end]
}
proc script:notices10 {nick uhost hand text dest} {
global scriptchannel rchannels
set rchannels [lrange $text 1 end]
}
proc script:notices11 {nick uhost hand text dest} {
global scriptchannel rusername rdate lastseen infoline email rflags Epithet lastquit rnicknames rhost rchannels currentnick
set currentnick [lrange $text 2 end]
} |
Ok as you see I've collected data from Notices now I want to perfom them to the channel, how do I and which proc should I create to do that?.
this is the text I need to perform now.
| Code: | regsub -all {\{\}} $rflags "" rflags
regsub -all {\{\}} $rdate "" rdate
regsub -all {\{\}} $infoline "" infoline
regsub -all {\{\}} $Epithet "" Epithet
regsub -all {\{\}} $rnicknames "" rnicknames
regsub -all {\{\}} $rhost "" rhost
regsub -all {\{\}} $rchannels "" rchannels
regsub -all {\{\}} $currentnick "" currentnick
regsub -all {\{\}} $lastquit "" lastquit
regsub -nocase {Registered on:} $rdate "\00303Registered on:\003" rdate
regsub -nocase {Last seen:} $lastseen "\00303Last Seen:\003" lastseen
regsub -nocase {Infoline:} $infoline "\00303Infoline:\003" infoline
regsub -nocase {Email address:} $email "\00303Email Address:\003" email
regsub -nocase {Flags:} $rflags "\00303Flags:\003" rflags
regsub -nocase {Epithet:} $Epithet "\00303Epithet:\003" Epithet
regsub -nocase {Last quit hostmask:} $lastquit "\00303Last quit hostmask:\003" lastquit
regsub -nocase {Nickname\(s\):} $rnicknames "\00303Nickname(s):\003" rnicknames
regsub -nocase {Hostmask\(s\):} $rhost "\00303Hostmask(s):\003" rhost
regsub -nocase {Channel\(s\):} $rchannels "\00303Channel(s):\003" rchannels
regsub -nocase {Current nickname\(s\):} $currentnick "\00303Current nickname(s):\003" currentnick
putserv "PRIVMSG $scriptchannel :\00303Account information for:\003 \00307$rusername\003"
putserv "PRIVMSG $scriptchannel :\00303Registered on:\003 \00314$rdate\003"
putserv "PRIVMSG $scriptchannel :\00303Last Seen:\003 \00314$lastseen\003"
putserv "PRIVMSG $scriptchannel :\00303Infoline:\003 \00314$infoline\003"
putserv "PRIVMSG $scriptchannel :\00303Email Address:\003 \00314$email\003"
putserv "PRIVMSG $scriptchannel :\00303Flags:\003 \00314$rflags\003"
putserv "PRIVMSG $scriptchannel :\00303Epithet:\003 \00314$Epithet\003"
putserv "PRIVMSG $scriptchannel :\00303Last quit hostmask:\003 \00310$lastquit\003"
putserv "PRIVMSG $scriptchannel :\00303Nickname(s):\003 \00307$rnicknames\003"
putserv "PRIVMSG $scriptchannel :\00303Hostmask(s):\003 \00314$rhost\003"
putserv "PRIVMSG $scriptchannel :\00303Channel(s):\003 \00314$rchannels\003"
putserv "PRIVMSG $scriptchannel :\00303Current nickname(s):\003 \00307$currentnick\003"
}
putlog "ns info script loaded by iamdeath.." |
|
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Apr 28, 2007 6:52 am Post subject: |
|
|
So you didn't apply anything we told you here in your script. Before asking how to output the info, learn how to write eggdrop Tcl scripts that won't choke on special characters.
Tip: when using [lindex] on a string, [split] the string (e.g. lindex [split $arg] 0) same for [lrange] (e.g. lrange [split $arg] 0 2) and then apply join to convert it back to a string (e.g. join [lrange [split $arg] 0 2]). _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Apr 28, 2007 8:04 am Post subject: |
|
|
<Rant>I find it amazing how you manage to remove the part of the code that's actually proper and should work, while at the same time you add new code that does not work at all, and yet call this progress.</Rant>
Now to your (scripts) issues..
First, whenever you use list commands such as lindex and lrange, you need to use lists (create them using the list-command, or convert strings to lists using the split-command). Once you're done with your list operations, and wish to print the result out as a string, use the join-command to convert it back into a string (this will remove excessive {} and such).
So, join would make those 9 first regsub pointless, and it does it alot more efficiently. It would also handle a few other cases where your regsub's would be inadequate.
Secondly, keep track of your namespace variables. Any variable without a full namespace path, being set or read, will work in "localspace" - that is, the variable will only exist within that proc. If you wish to access a "globalspace" (namespace :: ) variable, you'll either have to link the local variable to the global one (using the command global), or use a full namespace path such as ::myglobalvariable.
Example:
| Code: | global mybadvar #Since we're in globalspace, this command is pretty pointless.
set mybadvar "FooBar" #Define the variable mybadvar in namespace ::
proc mybadproc {} {
#This code will choke as I'm trying to access the localspace
#variable myvar, which has not yet been defined.
puts stdout "$mybadvar"
}
set mygoodvar "FooBar FooBar" #Define the variable mygoodvar in namespace ::
proc mygoodproc1 {} {
global mygoodvar
#This will work since I've linked the localspace variable to the globalspace variable,
#thus accessing the globalspace variable ::mygoodvar using the local alias mygoodvar.
puts stdout "$mygoodvar"
}
proc mygoodproc2 {}
#This will work since I use a full namespace path to access the ::mygoodvar variable.
puts stdout "$::mygoodvar"
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|