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

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Sun May 07, 2006 8:55 am Post subject: variable not found. |
|
|
I am trying to write a small DCC code, in which I will type
.bonus username reason
That will add +5 of the current access of a username in X (Undernet)
| Code: | set ac(chan) "#channel"
set notifyusers "owner"
set ac(bot_username) "botusername"
set ac(owner_username) "ownerusername"
bind notc - "USER: * ACCESS: *" ac:bonus_points
bind dcc n bonus ac:bonus
proc ac:bonus_points {nick uhost hand text dest} {
set text [split $text]
set baccess [lindex $text 3]
}
proc ac:bonus { handle idx text } {
global ac user_names notifyusers baccess
set text [split $text]
set username1 [lindex $text 0]
set reason1 [lrange $text 1 end]
if {$username1 == ""} { putdcc $idx "Syntax: .bonus <CService Username> <Reason>"; return }
if {$username1 == "$ac(bot_username)"} { putdcc $idx "You can't bonus me or I can't modify myself."; return }
if {$username1 == "ac(owner_username)"} { putdcc $idx "Do you think $ac(owner_username) needs modification?, get a life."; return }
if {$reason1 == ""} { putdcc $idx "Syntax: .bonus <CService Username> <Reason>. You're required to mention reason for bonus."; return }
puthelp "PRIVMSG X :ACCESS $ac(chan) $username1"
puthelp "PRIVMSG X :MODINFO $ac(chan) ACCESS $username1 [expr $baccess + 5]"
if {$notifyusers != "" && $notifyusers != " "} {
foreach notfuser $notifyusers {
sendnote IDA_SYSTEM $notfuser "Bonus +5 given to $username1 by $handle in $ac(chan). The reason was: $reason1"
}
}
} |
but I am getting this error.
| Code: | | [17:54] Tcl error [ac:bonus]: can't read "baccess": no such variable |
normal X reply when someone types: /msg x access #Channel username
| Code: | -X- USER: cricket ACCESS: 400 LU
-X- CHANNEL: #Cricket -- AUTOMODE: OP
-X- LAST SEEN: 0 days, 00:07:16 ago.
-X- LAST MODIFIED: (iamdeath) |AmDeAtH!~iamdeath@iamdeath.users.undernet.org (1 day, 21:12:14 ago)
-X- End of access list |
Can you suggest me.
Thanks.
Last edited by iamdeath on Sun May 07, 2006 2:24 pm; edited 1 time in total |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun May 07, 2006 8:59 am Post subject: |
|
|
In your code, baccess is set only when the bot recieves a notice. What you need to do is initialize to some number (probably 0) outside the procs. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Sun May 07, 2006 9:47 am Post subject: |
|
|
could you please give me an idea how could I do that?
Thanks |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun May 07, 2006 11:13 am Post subject: |
|
|
| Code: | set ac(chan) "#channel"
set notifyusers "owner"
set ac(bot_username) "botusername"
set ac(owner_username) "ownerusername"
set baccess 0 ;# initialized baccess to 0 |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Sun May 07, 2006 2:07 pm Post subject: |
|
|
Did'nt work actually, the actuall access of tht person was 300 so the bot was supposed to add 5 but the bot makes it "5" the whole removed 300  |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Sun May 07, 2006 3:04 pm Post subject: |
|
|
well, how do you know whos baccess is in the var anyway? the expr expression is calculated before the access request leaves your bot, so there will of course be no reply yet either. You must include this calculation within the proc which handles the feedbacks. you should then of course also read whos feedback you are getting and, if you actually wanted to modify it (you never know when someone might make your bot to recieve a reply). _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Sun May 07, 2006 5:04 pm Post subject: |
|
|
| I did;nt get your point, sorry ;/ |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun May 07, 2006 5:25 pm Post subject: |
|
|
What you need to do, iamdeath, is issue the service command when the dcc command is triggered. Then, you wait for the notice and perform the needed action. Ofcourse you will need a variable which will contain the needed info for the notc proc to process it. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Mon May 08, 2006 5:58 am Post subject: |
|
|
This works fine, do you think that's right? |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon May 08, 2006 7:36 pm Post subject: |
|
|
What I mean is something like this:
| Code: | set ac(chan) "#channel"
set notifyusers "owner"
set ac(bot_username) "botusername"
set ac(owner_username) "ownerusername"
bind dcc n bonus ac:bonus
bind notc - "USER: * ACCESS: *" ac:bonus_points
proc ac:bonus {hand idx arg} {
global ac baccess
set text [split $text]
set username1 [lindex $text 0]
set reason1 [lrange $text 1 end]
if {$username1 == ""} { putdcc $idx "Syntax: .bonus <CService Username> <Reason>"; return }
if {$username1 == "$ac(bot_username)"} { putdcc $idx "You can't bonus me or I can't modify myself."; return }
if {$username1 == "$ac(owner_username)"} { putdcc $idx "Do you think $ac(owner_username) needs modification?, get a life."; return }
if {$reason1 == ""} { putdcc $idx "Syntax: .bonus <CService Username> <Reason>. You're required to mention reason for bonus."; return }
puthelp "PRIVMSG X :ACCESS $ac(chan) $username1"
set baccess([string tolower $username1]) [list $hand $reason1]
}
proc ac:bonus_points {nick uhost hand arg dest} {
global ac baccess notifyusers
if {![isbotnick $dest]} {return 0}
if {![string equal -nocase X $nick]} {return 0}
set user [string tolower [lindex [split $arg] 1]]
if {![info exists baccess($user)]} {return 0}
foreach {handle reason} $baccess($user) {break}
set access [lindex [split $arg] 3]
puthelp "PRIVMSG X :MODINFO $ac(chan) ACCESS $user [expr {$access + 5}]"
if {$notifyusers != "" && $notifyusers != " "} {
foreach notfuser $notifyusers {
sendnote IDA_SYSTEM $notfuser "Bonus +5 given to $user by $handle in $ac(chan). The reason was: $reason"
}
}
} |
Note that baccess is being used as an array here, so you might want to .restart after loading this (or .tcl unset baccess before loading). _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Tue May 09, 2006 6:03 am Post subject: |
|
|
That work, thanks alot
Thanks once again. |
|
| Back to top |
|
 |
|