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.

deop/devoice on idle

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
Amr
Halfop
Posts: 94
Joined: Fri Sep 14, 2007 7:13 am
Location: Egypt

deop/devoice on idle

Post by Amr »

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

thanks in advance.
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

please always use your finger to search it first before requesting. There's a lot here
Learning Knows No Boundaries!!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

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: Select all

setudef list idleExempt
with:

Code: Select all

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: Select all

set excempt [channel get $chan idleExempt]
and finally replace:

Code: Select all

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

Code: Select all

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: Select all

setudef int idleTime
with:

Code: Select all

set idle(time) "60"
where 60 in my example means 60 minutes, then remove:

Code: Select all

set time [channel get $chan idleTime]
and replace:

Code: Select all

if {$idle >= $time} {
with:

Code: Select all

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.
Last edited by caesar on Thu May 31, 2012 8:31 am, edited 5 times in total.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Amr
Halfop
Posts: 94
Joined: Fri Sep 14, 2007 7:13 am
Location: Egypt

Post by Amr »

I got this error after running the bot;

Code: Select all

[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.
User avatar
Amr
Halfop
Posts: 94
Joined: Fri Sep 14, 2007 7:13 am
Location: Egypt

Post by Amr »

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.
g
gasak
Halfop
Posts: 45
Joined: Mon Aug 09, 2010 11:09 pm

Post by gasak »

What problem Amr? I did use one from BLaCkShaDoW and it works great.
Learning Knows No Boundaries!!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Meh.. replace:

Code: Select all

setudef list idleExempt
with:

Code: Select all

setudef str idleExempt
Once the game is over, the king and the pawn go back in the same box.
User avatar
Amr
Halfop
Posts: 94
Joined: Fri Sep 14, 2007 7:13 am
Location: Egypt

Post by Amr »

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 +/@.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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. :)
Once the game is over, the king and the pawn go back in the same box.
User avatar
Amr
Halfop
Posts: 94
Joined: Fri Sep 14, 2007 7:13 am
Location: Egypt

Post by Amr »

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.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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.
User avatar
Amr
Halfop
Posts: 94
Joined: Fri Sep 14, 2007 7:13 am
Location: Egypt

Post by Amr »

sadly yes , nothing happens.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Let's try with time then. Replace:

Code: Select all

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

Code: Select all

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.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

caesar wrote:

Code: Select all

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: Select all

bind time - {?0*} [namespace current]::idleTime
proc idleTime {args} {
The code above works every 10 minutes :)

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.. ;)
User avatar
Amr
Halfop
Posts: 94
Joined: Fri Sep 14, 2007 7:13 am
Location: Egypt

Post by Amr »

I got this error;

Code: Select all

[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
Post Reply