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 

deop/devoice on idle
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Amr
Halfop


Joined: 14 Sep 2007
Posts: 94
Location: Egypt

PostPosted: Tue May 29, 2012 10:02 pm    Post subject: deop/devoice on idle Reply with quote

hello guys , any tcl script around which deop/devoice users after specific period when go idle

thanks in advance.
Back to top
View user's profile Send private message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Tue May 29, 2012 11:23 pm    Post subject: Reply with quote

please always use your finger to search it first before requesting. There's a lot here
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
caesar
Mint Rubber


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

PostPosted: Wed May 30, 2012 12:43 am    Post subject: Reply with quote

Code:

namespace eval idlemode {
   setudef flag idleMode
   setudef str idleExempt
   setudef int idleTime
   bind cron {*/10 * * * *} [namespace current]::idleCron

   proc idleCron {minute hour day month weekday} {
      foreach chan [channels] {
         if {![channel get $chan idleMode]} continue
            cronCheck $chan
      }
   }

   proc cronCheck {chan} {
      variable idle
      switch -- [catch {botisop $chan} err] {
         "0" {
            if {!$err} {
               putlog "idleMode error: I'm not oped in $chan channel."
               return
            }
         }
         "1" {
            putlog "idleMode error: $chan channel is not valid."
            return
         }
      }
      set users [lrange [chanlist $chan] 1 end]
      set excempt [channel get $chan idleExempt]
      set time [channel get $chan idleTime]
      foreach user $users {
         if {[lsearch -nocase $excempt $user] != -1} continue
         if {[isop $user $chan]} {
            lappend checkList $user:1
         }
         if {[isvoice $user $chan]} {
            if {[info exists checkList]} {
               set pos [lsearch -nocase $checkList $user:1]
               if {$pos == -1} {
                  lappend checkList $user:2
               } else {
                  set checkList [lreplace $checkList $pos $pos $user:3]
               }
            } else {
               lappend checkList $user:2
            }
         }
      }
      foreach ele [split $checkList] {
         scan $ele {%[^:]:%s} user count
         checkIdle $count $user $chan $time
      }
   }

   proc checkIdle {mode user chan time} {
      set idle [getchanidle $user $chan]
      if {$idle >= $time} {
         switch -- $mode {
            "1" {
               pushmode $chan -o $user
               putlog "idleMode: deoped $user in $chan cos was idle for $idle minutes"
            }
            "2" {
               pushmode $chan -v $user
               putlog "idleMode: devoiced $user in $chan cos was idle for $idle minutes"
            }
            "3" {
               puthelp "MODE $chan -ov $user $user"
               putlog "idleMode: deoped and devoiced $user in $chan cos was idle for $idle minutes"
            }
         }
      }
   }
}

putlog "idlemode.tcl loaded..."

Haven't tested this but should idle check every channel every 10 minutes. You will need to activate this on the channels you wish with .chanset #channel +idlemode, define the idle time with .chanset #channel idletime 60 (where 60 in my example means 60 minutes) and if you wish can add an exempt for each channel with .channel set #channel "user_1 user_2"

If you wish to have the exempt list in the .tcl file and don't want to be bothered with maintaining a list for each channel then replace:
Code:

setudef list idleExempt

with:
Code:

set idle(exempt) [list "user_1" "user_2" "user_3"]

where you replace user_1, user_2 and so on. with what you wish (case insensitive), remove:
Code:

set excempt [channel get $chan idleExempt]

and finally replace:
Code:

if {[lsearch -nocase $excempt $user] != -1} continue

with:
Code:

if {[lsearch -nocase $idle(excempt) $user] != -1} continue


If you wish to have the same idleTime for each channel in the .tcl file then replace:
Code:

setudef int idleTime

with:
Code:

set idle(time) "60"

where 60 in my example means 60 minutes, then remove:
Code:

set time [channel get $chan idleTime]

and replace:
Code:

if {$idle >= $time} {

with:
Code:

if {$idle >= $idle(time)} {

Oh, and please do reply back if you get any errors.

Edit #3: Changed and fixed the code. Now it should be working fine.
_________________
Once the game is over, the king and the pawn go back in the same box.


Last edited by caesar on Thu May 31, 2012 8:31 am; edited 5 times in total
Back to top
View user's profile Send private message
Amr
Halfop


Joined: 14 Sep 2007
Posts: 94
Location: Egypt

PostPosted: Wed May 30, 2012 3:29 pm    Post subject: Reply with quote

I got this error after running the bot;
Code:

[21:28:06] Tcl error in file 'eggdrop.conf':
[21:28:06] invalid type. Must be one of: flag, int, str
    while executing
"setudef list idleExempt"
    (in namespace eval "::idlemode" script line 3)
    invoked from within
"namespace eval idlemode {
   setudef flag idleMode
   setudef list idleExempt
   setudef int idleTime
   bind cron {*/10 * * * *} [namespace current]:..."
    (file "scripts/idlemode.tcl" line 1)
    invoked from within
"source scripts/idlemode.tcl"
    (file "eggdrop.conf" line 996)
[21:28:06] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)


Last edited by Amr on Wed May 30, 2012 3:33 pm; edited 2 times in total
Back to top
View user's profile Send private message
Amr
Halfop


Joined: 14 Sep 2007
Posts: 94
Location: Egypt

PostPosted: Wed May 30, 2012 3:31 pm    Post subject: Reply with quote

gasak wrote:
please always use your finger to search it first before requesting. There's a lot here


I did already and tried all of them , but they all have problems.
Back to top
View user's profile Send private message
gasak
Halfop


Joined: 09 Aug 2010
Posts: 45

PostPosted: Wed May 30, 2012 9:26 pm    Post subject: Reply with quote

What problem Amr? I did use one from BLaCkShaDoW and it works great.
_________________
Learning Knows No Boundaries!!
Back to top
View user's profile Send private message
caesar
Mint Rubber


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

PostPosted: Thu May 31, 2012 12:04 am    Post subject: Reply with quote

Meh.. replace:
Code:

setudef list idleExempt

with:
Code:

setudef str idleExempt

_________________
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
Amr
Halfop


Joined: 14 Sep 2007
Posts: 94
Location: Egypt

PostPosted: Thu May 31, 2012 3:51 am    Post subject: Reply with quote

okay now loaded normally , I had enabled it on a channel and I set the idletime , but I got no response from the bot after the specific period which is 10 minutes.

gasak wrote:
What problem Amr? I did use one from BLaCkShaDoW and it works great.

it deops voiced users not opers plus it deops normal users which don't have +/@.
Back to top
View user's profile Send private message
caesar
Mint Rubber


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

PostPosted: Thu May 31, 2012 5:31 am    Post subject: Reply with quote

I've tested the above code and all seems to be working fine, except the cron bind that apparently is ignored on my Windrop. Don't have an eggdrop to actually test this.. Please test this out and reply back if you have any issues with it. Smile
_________________
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
Amr
Halfop


Joined: 14 Sep 2007
Posts: 94
Location: Egypt

PostPosted: Thu May 31, 2012 1:27 pm    Post subject: Reply with quote

Amr wrote:
okay now loaded normally , I had enabled it on a channel and I set the idletime , but I got no response from the bot after the specific period which is 10 minutes.
Back to top
View user's profile Send private message
caesar
Mint Rubber


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

PostPosted: Fri Jun 01, 2012 12:05 am    Post subject: Reply with quote

In the previous code yes, I had an issue and it wouldn't execute properly. Have you given this new code a test and still nothing happens?
_________________
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
Amr
Halfop


Joined: 14 Sep 2007
Posts: 94
Location: Egypt

PostPosted: Sat Jun 02, 2012 6:28 am    Post subject: Reply with quote

sadly yes , nothing happens.
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 02, 2012 3:31 pm    Post subject: Reply with quote

Let's try with time then. Replace:
Code:

bind cron {*/10 * * * *} [namespace current]::idleCron
proc idleCron {minute hour day month weekday}

with:
Code:

bind time - {*/10 * * * *} [namespace current]::idleTime
proc idleTime {min hour day month year}

test and report back.
_________________
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
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Jun 02, 2012 5:06 pm    Post subject: Reply with quote

caesar wrote:
Code:
bind time - {*/10 * * * *} [namespace current]::idleTime
proc idleTime {min hour day month year}


You forgot to change more than just "cron" to "time".
Which of course means no testing required, we already know this won't work.

Code:
bind time - {?0*} [namespace current]::idleTime
proc idleTime {args} {


The code above works every 10 minutes Smile

Also, just wondering...

proc idleTime {min hour day month year}
proc idleCron {minute hour day month weekday}

Why you cutely rename variable assignments that you don't even use? Why not just use args.. Wink
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Amr
Halfop


Joined: 14 Sep 2007
Posts: 94
Location: Egypt

PostPosted: Sat Jun 02, 2012 9:50 pm    Post subject: Reply with quote

I got this error;

Code:
[03:51:00] Tcl error [::idlemode::idleTime]: bad option "-nocase": must be -all, -ascii, -decreasing, -dictionary, -exact, -glob, -increasing, -inline, -integer, -not, -real, -regexp, -sorted, or -start
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
Goto page 1, 2, 3  Next
Page 1 of 3

 
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