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.

check channel modes and unlock channel if locked

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

check channel modes and unlock channel if locked

Post by simo »

greetings, im using this tcl at the moment it checks for the modes that lock channel incase some OP forgot to remove them i was wondering if it could be modified to only remove the actuall modes that are set and detected unlike as it is now where it removes the modes anyway regardless if they are set or not

Code: Select all

########################################################################
###  checklock.tcl v.1.0                                             ###
###        checklock.tcl v1.0 has been made and development          ###
###                             BY                                   ###
###        (c) SnowBot (ha0) Script Team Development (c)             ###
###  *** Copyright (C) 1999-2002 Clovis  #Mania @ DalNet ***         ###
###  The purpose from this script is for educational only            ###
###  Not available for commercial purpose                            ###
###  For contact you can email me at hendra_asianto@hotmail.com      ###
###  Our Homepage on www.snowbot.s5.com or visit our chan on #mania  ###
########################################################################
#######################################################################
## --- Don't change anything below here if you don't know how ! --- ###
## ---------------------------------------------------------------- ###

## NOTE : THIS SCRIPT CAN SET BECOME AUTO AWAY .TCL  WITH RANDOM AWAY MSG :)
##  DEPEND'S YOUR IDEAL :)NOW... I JUST CAN GIVE A LITTLE WAY

# Set how long that bot must check modelock back again.
set timechks 30

# Version number - DON'T TOUCH!

### Start Call Command
timer $timechks snowbotchk

proc snowbotchk {} {
global timechks
foreach chan [channels] {
if {[botisop $chan]} {
  if {[string match +*m* [lindex [getchanmode $chan] 0]] || [string match +*i* [lindex [getchanmode $chan] 0]] || [string match +*N* [lindex [getchanmode $chan] 0]] || [string match +*R* [lindex [getchanmode $chan] 0]] || [string match +*M* [lindex [getchanmode $chan] 0]] || [string match +*c* [lindex [getchanmode $chan] 0]]} {
      putserv "MODE $chan -cimMNR"
   } 
}
}
timer $timechks snowbotchk
}

putlog " . . : : checklock . T C L : : . .Loaded Successfuly..."
 
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Try this.

Code: Select all

########################################################################
###  checklock.tcl v.1.0                                             ###
###        checklock.tcl v1.0 has been made and development          ###
###                             BY                                   ###
###        (c) SnowBot (ha0) Script Team Development (c)             ###
###  *** Copyright (C) 1999-2002 Clovis  #Mania @ DalNet ***         ###
###  The purpose from this script is for educational only            ###
###  Not available for commercial purpose                            ###
###  For contact you can email me at hendra_asianto@hotmail.com      ###
###  Our Homepage on www.snowbot.s5.com or visit our chan on #mania  ###
########################################################################
#######################################################################
## --- Don't change anything below here if you don't know how ! --- ###
## ---------------------------------------------------------------- ###

## NOTE : THIS SCRIPT CAN SET BECOME AUTO AWAY .TCL  WITH RANDOM AWAY MSG :)
##  DEPEND'S YOUR IDEAL :)NOW... I JUST CAN GIVE A LITTLE WAY

# Set how long that bot must check modelock back again.
set timechks 30

# Version number - DON'T TOUCH!

### Start Call Command (made safe from rehash starting double loops)
if {![info exists chklock_running]} {
  timer $timechks [list snowbotchk]
  set chklock_running 1
}

proc snowbotchk {} {
  global timechks
  foreach chan [channels] {
    if {[botisop $chan]} {  set modes ""

      set chanmode [lindex [split [getchanmode $chan]] 0]

      if {[string match +*c* $chanmode]} { append modes c }
      if {[string match +*i* $chanmode]} { append modes i }
      if {[string match +*m* $chanmode]} { append modes m }
      if {[string match +*M* $chanmode]} { append modes M }
      if {[string match +*N* $chanmode]} { append modes N }
      if {[string match +*R* $chanmode]} { append modes R }

      if {$modes ne ""} {  putserv "MODE $chan -$modes"  }

    }
  }
  timer $timechks [list snowbotchk]
}

putlog " . . : : checklock . T C L : : . .Loaded Successfuly..."

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

oh that one seems working too tnx spike^^
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Honestly I would rather rely on a bind time of one minute or whatever suits your need than to use timers.

Code: Select all

namespace eval lockCheck {
	setudef str lockModes

	bind time * * [namespace current]::check

	proc check {args} {
		foreach chan [channels] {
			if {![botisop $chan]} continue
			set modes [split [channel get $chan lockModes] ""]
			set cm [lindex [split [getchanmode $chan] +] 1]
			if {[string first k $cm] != -1} {
				scan $cm {%s%s} cm key
			}
			foreach m [split $cm ""] {
				if {[lsearch -nocase $modes $m] != -1} {
					if {$m eq "k"} {
						pushmode $chan -k $key
					} else {
						pushmode $chan -$m
					}
				}
			}
		}
	}
}
Difference between mine and yours?
- can have different lock modes to be removed for each channel in particular, just .chanset #channel lockModes mki for #channel and .chanset #anotherchannel lockModes for #anotherchannel for instance, or to be more specific .chanset #channel lockModes cimMNR
- supports removal of a channel key if such a mode is desired to be removed
- doesn't require any change of the actual script file so all changes in channel lock modes are on-the-fly
- by using pushmode it will push all mode changes in just one line rather than spamming with multiple mode changes
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

nice tnx caesar
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

hi SpiKe^^
but its tcl lacks some ways that should be

example: k l S

it is possible to add these modes ???
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The one I posted takes care of that as well.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i tried yours caesar it seems to not make difference between lower and upper case while there is a difference for example we want to use N not n and use T not t as they both are default modes and shouldnt be removed ever




.chanset * lockModes cimMRcSNk

resulted in:


10:24:23 +ctcp Sets Mode on #Cappuccino to: +imk kjhffd
10:25:01 &Hawk Sets Mode on #Cappuccino to: -imCnk kjhffd
10:25:02 &ChanServ Sets Mode on #Cappuccino to: +n
10:26:01 &Hawk Sets Mode on #Cappuccino to: -n
10:26:02 &ChanServ Sets Mode on #Cappuccino to: +n
10:27:01 &Hawk Sets Mode on #Cappuccino to: -n
10:27:01 &ChanServ Sets Mode on #Cappuccino to: +n


is there a way to use with pub cmd like

!checklock NRMcSk
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

namespace eval lockCheck {
	setudef str lockModes

	bind time * * [namespace current]::timedCheck
	bind pub m|m !checklock [namespace current]::chanCheck

	proc check {chan {modes ""}} {
		if {![string length $modes]} {
			set modes [split [channel get $chan lockModes] ""]
		}
		set cm [lindex [split [getchanmode $chan] +] 1]
		if {[string first k $cm] != -1} {
			scan $cm {%s%s} cm key
		}
		foreach m [split $cm ""] {
			if {[string first $m $modes] != -1} {
				if {$m eq "k"} {
					pushmode $chan -k $key
				} else {
					pushmode $chan -$m
				}
			}
		}
	}
	
	proc timedCheck {args} {
		foreach chan [channels] {
			if {![botisop $chan]} continue
			check $chan
		}
	}

	proc chanCheck {nick uhost hand chan text} {
		if {[scan $text {%s} modes] != 1} {
			puthelp "NOTICE $nick :Usage: !checklock <modes>"
		} else {
			check $chan $modes
		}
	}
}
Changed the above code to make it case sensitive and got the !checklock inside. Haven't tested but in theory should work as expected.

PS: You should restart the bot to remove the old binds cos have been changed in the new code.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1071
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tested some modes it doesnt seem to react to i did like

LockModes: cimMSNROAk

yet when setting like +A on channel it didnt remove
Post Reply