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 

check channel modes and unlock channel if locked

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Tue Apr 07, 2015 8:50 pm    Post subject: check channel modes and unlock channel if locked Reply with quote

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:
########################################################################
###  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..."
 
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 505
Location: Tennessee, USA

PostPosted: Tue Apr 07, 2015 10:10 pm    Post subject: Reply with quote

Try this.
Code:

########################################################################
###  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
Back to top
View user's profile Send private message Visit poster's website
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Tue Apr 07, 2015 11:09 pm    Post subject: Reply with quote

oh that one seems working too tnx spike^^
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Wed Apr 08, 2015 6:11 am    Post subject: Reply with quote

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

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
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Wed Apr 08, 2015 6:22 pm    Post subject: Reply with quote

nice tnx caesar
Back to top
View user's profile Send private message
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 144
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Sat Apr 25, 2015 10:26 am    Post subject: Reply with quote

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

example: k l S

it is possible to add these modes ???
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Sun Apr 26, 2015 3:34 am    Post subject: Reply with quote

The one I posted takes care of that as well.
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Mon Jan 23, 2017 5:33 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Mon Jan 23, 2017 11:47 am    Post subject: Reply with quote

Code:

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.
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Tue Jan 24, 2017 7:38 am    Post subject: Reply with quote

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

LockModes: cimMSNROAk

yet when setting like +A on channel it didnt remove
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 -> Script Requests 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