| View previous topic :: View next topic |
| Author |
Message |
Kaj Voice
Joined: 22 Sep 2013 Posts: 3
|
Posted: Thu Oct 16, 2014 11:32 am Post subject: Leave inactive channels automatically |
|
|
Hey,
I'd like to make a TCL script for my eggdrop that will let the bot leave inactive channels (e.g. channels where nothing was said past 2 days).
I have no idea how to do this so is there anyone that can give me any advice on how I should approach this problem?
Sincerely,
Kaj |
|
| Back to top |
|
 |
Kaj Voice
Joined: 22 Sep 2013 Posts: 3
|
Posted: Thu Dec 18, 2014 8:32 am Post subject: |
|
|
| bump |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Thu Dec 18, 2014 9:47 am Post subject: Re: Leave inactive channels automatically |
|
|
Is it because you know no TCL at all?
Would this be your first script?
We need more info from you, to know how to go about answering/helping you. Usually this can be determined by the poster such as yourself, posting the code that they have written and been trying so far.
Have you tried? Written any part or parts of it yourself, yet? |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Dec 19, 2014 4:59 am Post subject: |
|
|
Haven't tested this, so give it a try and report back if you got any problems.
By default ALL channels will be monitored and removed once the 24 hours deadline hits, so if you want any channels not to be checked then from DCC Chat/Telnet with the bot set them to +skipCheck with .chanset #channel +skipCheck
| Code: |
namespace eval inactiveCheck {
variable inactive "172800" # in seconds
setudef flag skipCheck
setudef int lastwords
bind pubm * * [namespace current]::save
bind cron - {?0*} [namespace current]::check
bind join * * [namespace current]::joined
proc save {nick uhost hand chan text} {
if {![channel get $chan skipCheck]} {
channel set $chan lastwords [unixtime]
} else {
channel set $chan lastwords 0
}
}
proc check {min hour day month weekday} {
variable inactive
foreach chan [channels] {
if {[channel get $chan skipCheck]} continue
set lastwords [channel get $chan lastwords]
if {$lastwords > 0} {
set difference [expr [unixtime] - $lastwords]
if {$difference >= $lastwords} {
channel remove $chan
putlog "inactiveCheck: removing inactive $chan channel cos last spoken words where [duration $difference] ago."
}
}
}
}
proc joined {nick uhost hand chan} {
if {[isbotnick $nick]} {
if {![channel get $chan skipCheck]} {
channel set $chan lastwords [unixtime]
} else {
channel set $chan lastwords 0
}
}
}
}
|
I've also moved this to Script Requests as it seems to fit this section better. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
|