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.

Voice script

Old posts that have not been replied to for several years.
Locked
L
LiquidZoo
Voice
Posts: 12
Joined: Thu Nov 11, 2004 12:59 am

Voice script

Post by LiquidZoo »

Ok, I want to have a script that will activate on a /msg $botnick but look in a channel for the trigger phrase (well, character), when the users give that character (a single ' * ', I think I defined that right) it will voice that user and put their nick in a file to be used later, then on /msg $botnick voiceoff, it will read each of those users out of that file and devoice them. I think I have the second part right, but I can't get the first part to work correctly. Can anyone help me out? Here is the script that I have so far:

Code: Select all

 set ufile scripts/ufile.txt

set trigger "\*"

set tchan "#testchan"

bind msg - voiceon voiceon
bind msg - voiceoff voiceoff

proc voiceon {nick host hand chan args} {
	global ufile trigger tchan
	set fs [open $ufile a+]
		foreach $trigger $tchan {
			puts $fs "$nick"
			pushmode $tchan +v $nick
		}
	close $fs
}

proc voiceoff {args} {
	global ufile trigger tchan
	set fs [open $ufile r]
	while {![eof $fs]} { 
		  gets $fs line 
		  pushmode $tchan -v $line
	  }
	  close $fs
	  set fs [open $ufile w]
	  puts $fs ""
	  close $fs
}

putlog "Voice! Loaded"
Aside from the part that there aren't any comments there, can anyone help me get the voiceon proc to work the way I want it to?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

If you mean voice all nicks in the channel, the use:

Code: Select all

foreach trigger [chanlist $tchan] {
and to put each nick into the file and voice it use the variable $trigger instead of $nick.
L
LiquidZoo
Voice
Posts: 12
Joined: Thu Nov 11, 2004 12:59 am

Post by LiquidZoo »

I only want to voice those that use the trigger in the channel, how do I go about doing that?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

If you want to voice every user that msgs the bot with * in your channel then use something like this:

Code: Select all

set thevoicechan "#channel"

bind msg - * voice:user

proc voice:user {nick uhost hand arg} {
 if {[onchan $nick $::thevoicechan] && [botisop $::thevoicechan]} {
  pushmode $::thevoicechan +v $nick
 }
}
and add whatever other stuff you wanted to (i.e. add the nick to a file...etc)
L
LiquidZoo
Voice
Posts: 12
Joined: Thu Nov 11, 2004 12:59 am

Post by LiquidZoo »

That would make it so that everyone who sends a /msg to the bot with the trigger would be voiced, right? That's not exactly what I want. I want to turn on the script with a message to the bot, but have the trigger be something that is said in the channel text, not as a /msg

Is this even possible to do?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Well, I still don't understand what exactly you're asking for? If you mean you want the bot to voice those who say * in a channel only when you have voice set to on, then you can bind msg to voiceon for example, and set a variable to 1, then set it to 0 if voiceoff is sent. In the pub bind check if the variable is set to 1 then voice the nick.
L
LiquidZoo
Voice
Posts: 12
Joined: Thu Nov 11, 2004 12:59 am

Post by LiquidZoo »

Ok, I think I see what you're saying. Let me see if I got it right:

bind the msg to voiceon to start the script, then inside that set a variable to 1 that is default set to 0, and have another proc look for the trigger in the channel, but only if the variable is set to 1

So do I have the second bind check for the trigger? IE:

bind pub \* voice:on

proc voice:on { nick host hand chan args } {
if [$variable == 1] {
(add nick to file and voice nick in channel)
}
}

Something like that, right?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Yeah, that's it but you have some syntax errors.

Code: Select all

bind pub * voice:on 

proc voice:on {nick host hand chan arg} { 
 if {$::variable == 1} { 
  (add nick to file and voice nick in channel) 
 } 
}
When using the pub bind, * means the character '*' and not a wildcard (to match with wildcards use pubm) and don't use args in a proc as it has a special meaning, instead use arg for example. Also $variable should be global since you're gonna use it in diferent procs, that's why I used $::variable but you can simply add 'global variable' at the beginning of each proc and normally use $variable.
L
LiquidZoo
Voice
Posts: 12
Joined: Thu Nov 11, 2004 12:59 am

Post by LiquidZoo »

I've almost fot it, but it keeps giving me this error:

[10:36] Tcl error [voiceon]: invalid command name "0"

Like I'm trying to pass the zero as a command...

Here's what I've got:

Code: Select all

set ufile scripts/ufile.txt

set tchan "#musb-trivia"

set voiceVar 0

bind msg - voiceon voiceon
bind msg - voiceoff voiceoff

proc voiceon {nick uhost hand arg} {
        $::voiceVar = 1
        dovoice
}

bind pub - * dovoice

proc dovoice {nick host hand chan arg} {
        global ufile tchan
        if {[$::voiceVar == 1] && [$chan == $tchan]} {
                set fs [open $ufile a+]
                puts $fs "$nick"
                pushmode $tchan +v $nick
                close $fs
        }
}

proc voiceoff {args} {
        global ufile tchan
        set fs [open $ufile r]
        while {![eof $fs]} {
                  gets $fs line
                  pushmode $tchan -v $line
          }
          close $fs
          set fs [open $ufile w]
          puts $fs ""
          close $fs
          $::voiceVar = 0
}

putlog "Voice! Loaded"
I can't for the life of me figure out why it is reading it as a command and not as a value.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

It's

Code: Select all

if {$key1 == $key2} {
without the brackets [].

And unlike C, in tcl we initialize a variable like this:

Code: Select all

set variable <data>
so

Code: Select all

$::voiceVar = 1
should be

Code: Select all

set ::voiceVar 1
L
LiquidZoo
Voice
Posts: 12
Joined: Thu Nov 11, 2004 12:59 am

Post by LiquidZoo »

Still giving me a strange error about the number of args, but it works now. Thanks a lot.
Locked