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.

utimer problem [noob request]

Old posts that have not been replied to for several years.
A
Atomic
Voice
Posts: 25
Joined: Thu Jun 24, 2004 9:19 pm

utimer problem [noob request]

Post by Atomic »

hiya ppls

this is my 1st tcl script so sorry if its a bit lame..

im trying to add lame things to my bot
to make it a bit more interactive i have started this script
which i want the bot to do but im having trouble with the utimer
well the part after the utimer to be exact

what i want it to do is this
if someone says !iamgod in channel
i want the bot to moderate the channel
and only give +v to the user that did !iamgod

then after 30 seconds i want the bot to -m the channel
and take away the +v on the user to make them -v

then i want the bot to ignore that user from doing the cmd again for like 30 minutes or so... so they cant do it constantly (abuse it)

the script runs fine to begin with it moderates the channel and gives the user +v the utimer starts but then i get a error after the timer is up
saying can't read "channel": no such variable

i havent started the ignore part yet but any help starting me off
in the right direction would be cool :)

i have looked around the forum and done some reading but i cant seem to find anything that helps me.

here is my script :)

#Commands

bind pub - !iamgod pub_do_god

#----------------------------------------------------------------
#Make someone be a god
proc pub_do_god {nick host handle channel txt} {
if {![botisop $channel]} {
putserv "NOTICE $nick :I'm not op'd. I need to be op'd to do that."
return 1
}

putserv "PRIVMSG $channel :Watch out everyone! $nick has just decided that they will be playing god. So, heed the words of $nick !!!"
putquick "MODE $channel +m"
putquick "MODE $channel +v $nick"
utimer 30 {putquick "mode $channel -m"}
utimer 30 {putquick "mode $channel –v $nick"
utimer 30 {putquick "PRIVMSG $channel :Phew, You are no longer a god $nick"}
utimer 30 {putquick "PRIVMSG $channel :Normal Channel Operation resumed"}
return 1
}
}




#end of pub_do_iamgod


putlog " iamgod Script by atomic Loaded"

thank you
Atomic
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

well this should start you off:

don't use utimer $v {command $x $y}, use utimer $v [list command $x $y]

this will force evaluation of variables in [command $x $y] at the moment it's registered with utimer, and you won't get that error anymore
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Re: utimer problem [noob request]

Post by awyeah »

This is also an alternative way to do it:

Code: Select all

utimer 30 "putquick \"mode $channel -m\""
utimer 30 "putquick \"mode $channel –v $nick\""
utimer 30 "putquick \"PRIVMSG $channel :Phew, You are no longer a god $nick\""
utimer 30 "putquick "PRIVMSG $channel :Normal Channel Operation resumed\""
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
s
spock
Master
Posts: 319
Joined: Thu Dec 12, 2002 8:40 pm

Post by spock »

do what awyeah said if you want to [getfucced] :roll:
photon?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Here's a very old script of mine 'spock' which used todo the same with the utimer thing for UNBANNING, worked fine for me back then, I guess it can work now also. I don't use the same method anymore but it works.

Code: Select all

utimer your_time "your_[censored]_within_appropriate_quotations"

Code: Select all

bind join - "*" spam_nick

proc spam_nick {nick host hand chan} {
global botnick spambantime
set droneban1 "*!*@[lindex [split $host @] 1]"
set droneban2 "*!*$host"
set userident [string trimleft [string tolower [lindex [split $host "@"] 0]] "~"]
if {([string length $userident] >= 4) && ([string length $nick] >= 6) && ([string length $nick] <= 11) && (![regexp -nocase "a" $nick]) && (![regexp -nocase "e" $nick]) && (![regexp -nocase "i" $nick]) && (![regexp -nocase "o" $nick]) && (![regexp -nocase "u" $nick])} { 
foreach spamchan [channels] {
    if {[botisop $spamchan] && (![isop $nick $spamchan]) && (![isvoice $nick $spamchan]) && (![matchattr $hand mnf|mnf $spamchan]) && ([onchan $nick $spamchan])} {
	putquick "MODE $spamchan -o+bb $nick $droneban2 $droneban1"
	putquick "KICK $spamchan $nick :0,1 Random/Drone Nick Kick 12,0 - Possbile 2Spam/Trojan/Virus/Worm 12infected drone detected. 2Botnets/Spambots/Floodbots/Clonebots 12are strictly 2prohibited 12on this 2network/channel14 - 12Please 2/join #nohack 12or 2visit: http://www.nohack.net/ 12for more information."
      timer 120 "putserv \"mode $spamchan -bb $droneban2 $droneban1\""
      return 0
      }
    }
  }
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
s
spock
Master
Posts: 319
Joined: Thu Dec 12, 2002 8:40 pm

Post by spock »

what happens if $nick == [die]
or any tcl command for that matter?

edit: maybe i come off as a bit harsh but i thought this was day 5 type stuff
photon?
A
Atomic
Voice
Posts: 25
Joined: Thu Jun 24, 2004 9:19 pm

hmmm thank you but..

Post by Atomic »

hiya again :)

thank you for your fast replies but there are errors...

i tried both cmd lines

this one which i think you meant spock

script
#Commands

bind pub - !iamgod pub_do_god

#----------------------------------------------------------------
#Make someone be a god

proc pub_do_god {nick host handle channel txt} {
putquick "PRIVMSG $channel :Watch out everyone! $nick has just decided that they will be playing god. So, heed the words of $nick !!!"
putquick "MODE $channel +m"
putquick "MODE $channel +v $nick"
utimer 30 [list putquick "mode $channel –v $nick"]
utimer 30 [list putquick "mode $channel –m"]
utimer 30 [list putquick "PRIVMSG $channel :Phew, You are no longer a god $nick"]
utimer 30 [list putquick "PRIVMSG $channel :Normal Channel Operation resumed"]
return 1
}


#end of pub_do_iamgod


putlog " iamgod Script by atomic Loaded"

umm this one does not work as it does not unset the modes -v -m

and awyeah's cmd lines i added

script

#Commands

bind pub - !iamgod pub_do_god

#----------------------------------------------------------------
#Make someone be a god

proc pub_do_god {nick host handle channel txt} {
putquick "PRIVMSG $channel :Watch out everyone! $nick has just decided that they will be playing god. So, heed the words of $nick !!!"
putquick "MODE $channel +m"
putquick "MODE $channel +v $nick"
utimer 30 "putquick \"mode $channel –v $nick\""
utimer 30 "putquick \"mode $channel -m\""
utimer 30 "putquick \"PRIVMSG $channel :Phew, You are no longer a god $nick\""
utimer 30 "putquick \"PRIVMSG $channel :Normal Channel Operation resumed\""
return 1
}


#end of pub_do_iamgod


putlog " iamgod Script by atomic Loaded"

no this one does unset mode +m on the chanel but doesnt unset +v on the user... any ideas why guys..

i am sorry i have been scripting tcl for 1 day
obviously the script is flawed which i will proly learn
things that spring to mind are..

if the user changes nick while in god mode
i take it they will keep +v and i will get an error from the bot
if the user has a nick like [atomic] i htink this might also
cause problems in this script i have read about specail charactors in nicks
lik [] that cause problems ummm

i am not so advanced at tcl but i am willing to learn
sorry for the very noob questions :)
i am just doing very basic things i know
this is how i think i will learn this code :)
trial and error :)

not bad though after 1 day is it.. :)

thank you again
Atomic
s
spock
Master
Posts: 319
Joined: Thu Dec 12, 2002 8:40 pm

Post by spock »

Code: Select all

set ignorelist {}
bind pub - !iamgod pub_do_god 
proc pub_do_god {nick host handle channel txt} { 
  if {![botisop $channel]||[isop $nick $channel]||[isvoice $nick $channel]||[lsearch -exact $::ignorelist $host]!=-1} { 
    putserv "NOTICE $nick :I'm not op'd / you're opped / you're voiced / you're in my ignorelist" 
    return 1
  } 
  putserv "PRIVMSG $channel :Watch out everyone! $nick has just decided that they will be playing god. So, heed the words of $nick !!!" 
  putquick "MODE $channel +m" 
  putquick "MODE $channel +v $nick"
  utimer 30 [list endreign $nick $channel $host]
  return 1 
}
proc endreign {n c h} {
  putquick "mode $c -m"
  putquick "mode $c -v $n"
  putquick "PRIVMSG $c :Phew, You are no longer a god $n"
  putquick "PRIVMSG $c :Normal Channel Operation resumed"
  lappend ::ignorelist $h
  timer 30 [list cleanlist $h]
  return
}
proc cleanlist h {
  set ::ignorelist [lreplace $::ignorelist [set a [lsearch -exact $::ignorelist $h]] $a]
  return
}
photon?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Not sure about you spock, but it worked fine for me. There are sometimes more than one ways to solve a problem. Some trivial methods, some un-orthodox method's, either way both solutions have different problems, advantages and so forth.

If you are having problems with nicks, channels with special characters, such as {, }, [, ], \, ", then you can always add an extra "\" infront of them by using STRING MAP or a REGSUB filter.
Last edited by awyeah on Sat Jun 18, 2005 1:12 pm, edited 1 time in total.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
A
Atomic
Voice
Posts: 25
Joined: Thu Jun 24, 2004 9:19 pm

wow thank you

Post by Atomic »

wow your ace mate thank you

but it doesnt work :(

i get an error on partyline

Tcl error [pub_do_god]: invalid command name " "

sorry i have looked at it and cant figure it out

eek *blushes*
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

awyeah wrote:Not sure about you spock, but it worked fine for me. There are sometimes more than one ways to solve a problem. Some trivial methods, some un-orthodox method's, either way both solutions have different problems, advantages and so forth.

If you are having problems with nicks, channels with special characters, such as {, }, [, ], \, ", then you can always add an extra "" infront of them by using STRING MAP or a REGSUB filter.
he meant you will be exploited because of your code passing arbitrary input ($nick can be [die], and your bot will die) to Tcl's interpreter for evaluation - and that's because you actually force that evaluation using double quotes - you shouldn't do that, you should use braces or
  • if you need variable substitution
s
spock
Master
Posts: 319
Joined: Thu Dec 12, 2002 8:40 pm

Post by spock »

does his script work for you if you stick your
utimer 30 "putquick \"mode $channel –v $nick\""
in there, awyeah?

are you disputing the fact that the nick [thiswillbeexecuted] after 30 seconds if he happens to follow your suggestion? i didn't see you suggesting any string map or regsub to him, so it would break his [censored] no doubt! please try it before replying.

please dont lecture me on special characters, i am not the one having these problems.

edit: demond summed it up nicely
Last edited by spock on Sat Jun 18, 2005 1:25 pm, edited 1 time in total.
photon?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Yeah, but if I am aware with that, that [die] bug was pointed out to me very long ago by a friend of mine with older eggdrop versions and I beleive it has been rectified by the coders in the new versions.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

awyeah wrote:Yeah, but if I am aware with that, that [die] bug was pointed out to me very long ago by a friend of mine with older eggdrop versions and I beleive it has been rectified by the coders in the new versions.
it's not eggdrop's bug, it's your bug
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

spock wrote:does his script work for you if you stick your
utimer 30 "putquick "mode $channel –v $nick""
in there, awyeah?

are you disputing the fact that the nick [thiswillbeexecuted] after 30 seconds if he happens to follow your suggestion? i didn't see you suggesting any string map or regsub to him, so it would break his [censored] no doubt! please try it before replying.

please dont lecture me on special characters, i am not the one having these problems.

edit: demond summed it up nicely
Listen for me the same thing worked, a year ago on all of my scripts -- don't use it anymore, thought I'd give a second solution for the problem. We all in here know
  • works with utimer. As for the quotations, if you are keen in special characters use a filter and if you are that keen to ensure you bot doesn't execute [die] on a similar nick, check the damn nick if it is equal to 'die' or not else proceed.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked