egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Auto voice script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
TEK7
Voice


Joined: 10 Apr 2010
Posts: 10

PostPosted: Sat Jun 26, 2010 8:37 am    Post subject: Auto voice script Reply with quote

I have this code.

Code:
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:
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"
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Sat Jun 26, 2010 5:35 pm    Post subject: Reply with quote

I haven't coded in like a few years so bear with me. Very Happy 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. Smile

Code:

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:

if { $channel == $canal } {

cos the channel names can be uppercase or lowercase, so use instead:
Code:

if {[string match -nocase $canal $channel]} {

_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Luminous
Op


Joined: 12 Feb 2010
Posts: 146

PostPosted: Mon Jul 05, 2010 10:32 am    Post subject: Reply with quote

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:
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. Sad 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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber