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.

Auto voice script

Help for those learning Tcl or writing their own scripts.
Post Reply
T
TEK7
Voice
Posts: 10
Joined: Sat Apr 10, 2010 10:49 am

Auto voice script

Post by TEK7 »

I have this code.

Code: Select all

bind join - * join_av

proc join_av {nick uhost handle chan} {
 pushmode $chan +v $nick
}
But i want to put a command to active "+autovoice" and to desactive "-autovoice"

Can help me?

Thanks for all!

EDITED.
Done, here is the script

Code: Select all

set canal "#teamSIN"
set av "0"

bind join - * jjav
bind pub m "+autovoice" jav
bind pub m "-autovoice" jmav

proc jjav { nick uhost handle channel } {
  global canal av
  if { $channel == $canal } {
    if { $av == 1 } {
    pushmode $channel +v $nick
    }
  }
}

proc jav { nick uhost handle channel arg } {
  global canal av
  if { $channel == $canal } {
      if { $av == 0 } {
        set av 1
        putserv "NOTICE $nick :Auto Voice is now ON!"
    }
  }
}

proc jmav { nick uhost handle channel arg } {
  global canal av
  if { $channel == $canal } {
      if { $av == 1 } {
        set av 0
        putserv "NOTICE $nick :Auto Voice is now OFF!"
    }
  }
}

putlog "## AutoVoice by TEK7"
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I haven't coded in like a few years so bear with me. :D I would rather use 'setudef' (example: 'setudef flag avoice') than a variable in this case. Below I tried to make something for you, not sure 100% if it's ok or not, just test it and let me now and will make the required adjustments. :)

Code: Select all

setudef flag avoice

bind join - * voice:join
bind pub m ".autovoice" voice:setup

proc voice:join (nick uhost handle channel} {
	if {![channel get $channel avoice] || ![botisop $channel]} return
	pushmode $chan +v $nick
}

proc voice:setup (nick uhost handle channel text) {
	set len [llength $text]
	
	if (!$len) {
		putserv "NOTICE $nick :Usage: \002.autovoice <on/off> [#channel]\002, where the mode is required and the channel name is optional."
		return
	}
	
	if {$len == 1} {
		set chan $channel
		set mode [lindex [split $text] 0]
	} elseif {$len==2} {
		foreach (mode chan) [split $text] {break}
	}
	
	set status [channel get $chan avoice]
	switch $status {
		0 {
			set status2 "Disabled"
		}
		1 {
			set status2 "Enabled"
		}
	}

	switch [string tolowed $mode] {
		"on" {
			if (!$status) {
				channel set $chan +avoice
				putserv "NOTICE $nick :Auto voice for $chan channel has been enabled."
			} else {
				putserv "NOTICE $nick :Auto voice for $chan channel is already enabled."
			}
		}
		"off" {
			if ($status) {
				channel set $chan -avoice
				putserv "NOTICE $nick :Auto voice for $chan channel has been disabled."
			} else {
				putserv "NOTICE $nick :Auto voice for $chan channel is already disabled."
			}
		}
		"status" {
			putserv "NOTICE $nick :Auto voice for channel $chan is $status2"
		}
	} 
}
Oh, and in the future, stop comparing stuff like this:

Code: Select all

if { $channel == $canal } { 
cos the channel names can be uppercase or lowercase, so use instead:

Code: Select all

if {[string match -nocase $canal $channel]} { 
Once the game is over, the king and the pawn go back in the same box.
L
Luminous
Op
Posts: 146
Joined: Fri Feb 12, 2010 1:00 pm

Post by Luminous »

You do realize there is a flag "g" that does this already? But I can see why you'd want a new script for it-its slow. I just did something like this to replace it:

Code: Select all

bind join * * avoice
proc avoice {nick host hand chan} {
  if {[matchattr $hand |A $chan} {
    putquick $chan +v $nick
  }
 return
}
bind nick * * voice:nickchange
proc voice:nickchange {nick host hand chan newnick} {
  if {[matchattr [nick2hand $newnick $chan] |A $chan] && ![isvoice $newnick $chan]} {
      putquick "MODE $chan +v $newnick"
  }
 return
}
This creates the new channel flag "A", which should be faster than g. When I was using g, my bot used puthelp to voice. :( The second part will voice anyone who changes their nick to one that has flag A in the bot.user file. Just another idea for you, I've never been a fan of "voice-everyone" scripts.

Edit: whoops, left out the args. :S
Post Reply