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 

Leave inactive channels automatically

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


Joined: 22 Sep 2013
Posts: 3

PostPosted: Thu Oct 16, 2014 11:32 am    Post subject: Leave inactive channels automatically Reply with quote

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
View user's profile Send private message
Kaj
Voice


Joined: 22 Sep 2013
Posts: 3

PostPosted: Thu Dec 18, 2014 8:32 am    Post subject: Reply with quote

bump
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Thu Dec 18, 2014 9:47 am    Post subject: Re: Leave inactive channels automatically Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


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

PostPosted: Fri Dec 19, 2014 4:59 am    Post subject: Reply with quote

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
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