| View previous topic :: View next topic |
| Author |
Message |
Amr Halfop

Joined: 14 Sep 2007 Posts: 94 Location: Egypt
|
Posted: Tue May 29, 2012 10:02 pm Post subject: deop/devoice on idle |
|
|
hello guys , any tcl script around which deop/devoice users after specific period when go idle
thanks in advance. |
|
| Back to top |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Tue May 29, 2012 11:23 pm Post subject: |
|
|
please always use your finger to search it first before requesting. There's a lot here _________________ Learning Knows No Boundaries!! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed May 30, 2012 12:43 am Post subject: |
|
|
| 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 |
|
 |
Amr Halfop

Joined: 14 Sep 2007 Posts: 94 Location: Egypt
|
Posted: Wed May 30, 2012 3:29 pm Post subject: |
|
|
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 |
|
 |
Amr Halfop

Joined: 14 Sep 2007 Posts: 94 Location: Egypt
|
Posted: Wed May 30, 2012 3:31 pm Post subject: |
|
|
| 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 |
|
 |
gasak Halfop
Joined: 09 Aug 2010 Posts: 45
|
Posted: Wed May 30, 2012 9:26 pm Post subject: |
|
|
What problem Amr? I did use one from BLaCkShaDoW and it works great. _________________ Learning Knows No Boundaries!! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu May 31, 2012 12:04 am Post subject: |
|
|
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 |
|
 |
Amr Halfop

Joined: 14 Sep 2007 Posts: 94 Location: Egypt
|
Posted: Thu May 31, 2012 3:51 am Post subject: |
|
|
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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu May 31, 2012 5:31 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Amr Halfop

Joined: 14 Sep 2007 Posts: 94 Location: Egypt
|
Posted: Thu May 31, 2012 1:27 pm Post subject: |
|
|
| 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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Jun 01, 2012 12:05 am Post subject: |
|
|
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 |
|
 |
Amr Halfop

Joined: 14 Sep 2007 Posts: 94 Location: Egypt
|
Posted: Sat Jun 02, 2012 6:28 am Post subject: |
|
|
| sadly yes , nothing happens. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sat Jun 02, 2012 3:31 pm Post subject: |
|
|
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 |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Jun 02, 2012 5:06 pm Post subject: |
|
|
| 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
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..  _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
Amr Halfop

Joined: 14 Sep 2007 Posts: 94 Location: Egypt
|
Posted: Sat Jun 02, 2012 9:50 pm Post subject: |
|
|
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 |
|
 |
|