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.

on/off script

Old posts that have not been replied to for several years.
Locked
D
Dizzle
Op
Posts: 109
Joined: Thu Apr 28, 2005 11:21 am
Contact:

on/off script

Post by Dizzle »

Hello, i have a little question

i have an antiadverise and an badword script scripted on my own

i just want a little feature too be build in

i like too activate one of the features in the script by typing for example

!badword on/off
!antiadver on/off

whats the right way too make this ?

part of the script

Code: Select all


proc badword {nick uhost handle channel arg} {
global botnick globalbantime badwordbanmsg activechans
if {[lsearch [string tolower $activechans] [string tolower $channel]] == -1} { return } 
if {![isop $botnick $channel]} {return 0}
if {[isop $nick $channel]} {return 0}
putserv "MODE $channel +b *!$uhost"
putserv "KICK $channel $nick :$badwordbanmsg"
timer $globalbantime [subst {putserv "MODE $channel -b *!$uhost"}]
}

Plz help me with this, thanks in advance  :D 

K
KevKev
Halfop
Posts: 67
Joined: Fri Oct 03, 2003 5:15 am

Post by KevKev »

Basicly you just need to add a few things.

First. Add a variable for each "switch". i.e. $badword_status and $antiadver_status

In your procs for these add at the very start a check to see if the switches are turned off. if the switch is off return from the proc without doing anything. (optionallly you can add some debugging stuff to putlog on a specific flag that the proc was triggered but tuned off or some such).

here's an example using your current code.

Code: Select all

proc badword {nick uhost handle channel arg} {
global botnick globalbantime badwordbanmsg activechans badword_status
if {$badword_status < 1} {return 0}
if {[lsearch [string tolower $activechans] [string tolower $channel]] == -1} { return }
if {![isop $botnick $channel]} {return 0}
if {[isop $nick $channel]} {return 0}
putserv "MODE $channel +b *!$uhost"
putserv "KICK $channel $nick :$badwordbanmsg"
timer $globalbantime [subst {putserv "MODE $channel -b *!$uhost"}]
} 
manually set the vars to on and off and make sure things work.

Now write a simple proc to flip the switches.
I
Ian-Highlander
Op
Posts: 165
Joined: Mon Sep 24, 2001 8:00 pm
Location: Ely, Cambridgeshire

Post by Ian-Highlander »

I built an on/off switch into my trivia script "Trivia 2000" many years ago that you could easily adapt to do what you want. Here's the snippets of code for the switch ripped direct from my script.

Code: Select all

bind pub o|o !game game_onoff

#Switch game on or off as default (0 for off, 1 for on)
set gameonoff 1

#Tells the bot wether or not the game is already running, leave set to 0
set gameplaying 0

#On/off switch (useful if the game is annoying people!) :o)
proc game_onoff {nick uhost handle channel args} {
 global botnick gameonoff gameplaying gamechan
if {[string tolower $channel] != [string tolower $gamechan]} {
putserv "PRIVMSG $channel :Sorry $nick, \002\Trivia 2000\002 is not running in $channel, try going to $gamechan, its playing there :o)"
return
}
set chan $gamechan
  set onoff [string tolower [ string trim [lindex [split $args] 0] "{}" ]]
  if {($onoff == "on") && ($gameonoff == 0)} {
   set gameonoff 1
    putserv "PRIVMSG $chan :Game is now switched on! Enter !start to play."
return
}
   if {($onoff == "on") && ($gameonoff != 0)} {
    putserv "PRIVMSG $chan :Game is already switched on!"
return
 }
  if {($onoff == "off") && ($gameonoff != 0)} {
   set gameonoff 0
    set gameplaying 0
     kill_timers
      putserv "PRIVMSG $chan :Game is now switched off!"
return
}
  if {($onoff == "off") && ($gameonoff == 0)} {
    putserv "PRIVMSG $chan :Game is already switched off!"
return
}
putserv "PRIVMSG $chan :To switch game on or off use !game on/off"
return
}
Then at the top of each proc just add these (again edit for your own use).

Code: Select all

  if {$gameplaying != 0} {
  putserv "PRIVMSG $chan :Game is already running, please either wait for it to finish or enter !stop then !choose again to set category"
	return
}
  if {$gameonoff == 0} {
  putserv "PRIVMSG $chan :\0034Sorry $nick but the game isn't switched on right now, please try later!"
	return
}
Hope this helps.
"Insanity Takes Its Toll, Please Have Exact Change"
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

a one liner, using a custom channel setting (ie. +/-badword) would also work..
D
Dizzle
Op
Posts: 109
Joined: Thu Apr 28, 2005 11:21 am
Contact:

Post by Dizzle »

you mean like this

Code: Select all


setudef flag badword

proc badword {nick uhost handle channel arg} { 
global botnick globalbantime badwordbanmsg activechans
foreach i [channel info $chan] {
if ([string match "+badword" $i])} {
if {![isop $botnick $channel]} {return 0} 
if {[isop $nick $channel]} {return 0} 
putserv "MODE $channel +b *!$uhost" 
putserv "KICK $channel $nick :$badwordbanmsg" 
timer $globalbantime [subst {putserv "MODE $channel -b *!$uhost"}] 
} 

like this gb

so the user can actived it in any channel they want ( .chanset #chan +/-badword]

sounds good 8)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I would use

Code: Select all

if {[channel get $i badword]} {
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Yup, That would seem alot smarter.

Code: Select all

setudef flag badword
setudef flag antiadver

bind PUB m|m !antiadver adver:switch
bind PUB m|m !badword  badword:switch

proc adver:switch {nick host hand chan text} {
 set option [lindex [split $text] 0]
 switch $option {
   on { channel set $chan +antiadver }
   off { channel set $chan -antiadver }
  default { putserv "PRIVMSG $chan :Please choose on or off." }
  }
}

proc badword:switch {nick host hand chan text} {
 set option [lindex [split $text] 0]
 switch $option {
   on { channel set $chan +badword }
   off { channel set $chan -badword }
  default { putserv "PRIVMSG $chan :Please choose on or off." }
  }
}
Note, This is just a simple example :)
D
Dizzle
Op
Posts: 109
Joined: Thu Apr 28, 2005 11:21 am
Contact:

Post by Dizzle »

know if have this

i have editted it al, butt it aint responding when i typ

Code: Select all


setudef flag badword
setudef flag antiadver

bind PUB m|m !antiadver adver:switch
bind PUB m|m !badword badword:switch

proc adver:switch {nick host hand chan text} {
   set option [lindex [split $text] 0]
   switch $option {
      on { channel set $chan +antiadver }
      puthelp "NOTICE $nick : Anti-advertise is 9ON9"
      off { channel set $chan -antiadver }
      puthelp "NOTICE $nick : Anti-advertise is 4OFF4"
   }
}

proc badword:switch {nick host hand chan text} {
   set option [lindex [split $text] 0]
   switch $option {
      on { channel set $chan +badword }
      puthelp "NOTICE $nick : Anti-Badword is 9ON9"
      off { channel set $chan -badword }
      puthelp "NOTICE $nick : Anti-Badword is 4OFF4"
   }
}

proc badword {nick uhost handle channel arg} {
   global botnick globalbantime badwordmsg
   foreach i [channel info $chan] {
      if {[channel get $i badword]} {
         if {![isop $botnick $channel]} {return 0}
         if {[isop $nick $channel]} {return 0}
         putserv "MODE $channel +b *!$uhost"
         putserv "KICK $channel $nick :$badwordbanmsg"
         timer $globalbantime [subst {putserv "MODE $channel -b *!$uhost"}]
      }
   }
}

proc advertise {nick uhost handle channel arg} {
   global botnick globalbantime advermsg
   foreach i [channel info $chan] {
      if {[channel get $i antiadver]} {
         if {![isop $botnick $channel]} {return 0}
         if {[isop $nick $channel]} {return 0}
         putserv "MODE $channel +b *!$uhost"
         putserv "KICK $channel $nick : $advermsg"
         timer $globalbantime [subst {putserv "MODE $channel -b *!$uhost"}]
      }
   }
}

plz some advice
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

setudef flag badword 
setudef flag antiadver 

bind PUB m|m !antiadver adver:switch 
bind PUB m|m !badword badword:switch 
bind PUBM - * badword
bind PUBM - * advertise

proc adver:switch {nick host hand chan text} { 
 set option [lindex [split $text] 0] 
 switch -- $option { 
  "on" {
   channel set $chan +antiadver  
   puthelp "NOTICE $nick : Anti-advertise is 9ON9" 
  }
  "off" { 
   channel set $chan -antiadver
   puthelp "NOTICE $nick : Anti-advertise is 4OFF4" 
  }
 } 
} 

proc badword:switch {nick host hand chan text} { 
 set option [lindex [split $text] 0] 
 switch -- $option { 
  "on" {
   channel set $chan +badword
   puthelp "NOTICE $nick : Anti-Badword is 9ON9"
  }
  "off" {
   channel set $chan -badword
   puthelp "NOTICE $nick : Anti-Badword is 4OFF4" 
  }
 } 
} 

proc badword {nick uhost handle channel arg} { 
 global botnick globalbantime badwordmsg 
 if {[channel get $channel badword]} { 
  if {![botisop $channel] || [isop $nick $chann]} {return 0} 
  putserv "MODE $channel +b *!$uhost" 
  putserv "KICK $channel $nick :$badwordbanmsg" 
  timer $globalbantime [list putserv "MODE $channel -b *!$uhost"] 
 } 
} 

proc advertise {nick uhost handle channel arg} { 
 global globalbantime advermsg 
 if {[channel get $channel antiadver]} { 
  if {![botisop $channel] || [isop $nick $channe;]} {return 0} 
  putserv "MODE $channel +b *!$uhost" 
  putserv "KICK $channel $nick : $advermsg" 
  timer $globalbantime [list putserv "MODE $channel -b *!$uhost"] 
 } 
}
!antiadver on/off to switch on/off
!badwordon/off to swtich on/off
Locked