This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

stop continution. [SOLVED]

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

stop continution. [SOLVED]

Post by iamdeath »

Hi,

I've been posting questons regarding this small script I've created it with the help of you guys, now there is only 1 problem coming up.

The code is:

Code: Select all

set ac(chan) "#channel"
set notifyusers "owner"
set ac(bot_username) "username"
set ac(owner_username) "owner"

bind dcc n bonus ac:bonus
bind notc - "USER: * ACCESS: *" ac:bonus_points

proc ac:bonus {hand idx arg} {
 global ac baccess
 set arg [split $arg]
 set username1 [lindex $arg 0]
 set reason1 [lrange $arg 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"
  }
 }
}
Now the thing is, when I type:
.bonus <CService USername> <Reason>
The bot is increasing/modifying +5 to him BUT whenver bot recieves this message, the bot starts modifying other people too.

Code: Select all

-X- USER: username ACCESS: 123 LU
-X- CHANNEL: #channel -- AUTOMODE: OP
-X- LAST SEEN: 0 days, 00:07:07 ago.
-X- End of access list
So the bot will increase + 5 to " username ".. When the bot should'nt, it should only modify which is given in the partyline. The continuation of this script should stop, is that possible?. Now you must be asking why will the bot get that X notice again and again, well I've another TCL going on, which shows that data to the bot of all the usernames every minute.

I will be grateful to you if you kindly fix / help me out of it.

Thanks.
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Add

Code: Select all

unset baccess($user)
at the end of the ac:bonus_points proc.
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

ok let me try
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

This is what I did:

Code: Select all

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"
  }
 }
}
unset baccess($user)

The bot crashed after .rehash

Code: Select all

[03:56] <Cricket`-> [04:00] can't read "user": no such variable
[03:56] <Cricket`->     while executing
[03:56] <Cricket`-> "unset baccess($user)"
[03:56] <Cricket`->     (file "bonus.tcl" line 37)
[03:56] <Cricket`->     invoked from within
[03:56] <Cricket`-> "source bonus.tcl"
[03:56] <Cricket`->     (file "Cricket.conf" line 251)
[03:56] <Cricket`-> [04:00] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

I do not think Sir_Fz meant outside of the proc, by "at the end of the ac:bonus_points proc" he meant just before the last closing brace. :)

Code: Select all

  }
 }
unset baccess($user)
}
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

yaaaaaaa! Thanks mate :P
it worked ;)
Post Reply