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 

inactive op/voice control

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
SaPrOuZy
Halfop


Joined: 24 Mar 2004
Posts: 75
Location: Lebanon

PostPosted: Wed Aug 17, 2005 5:21 pm    Post subject: inactive op/voice control Reply with quote

hello there,
this script i made is getting on my nerves, i can't figure out what's wrong,
if anyone can take an outside look maybe you'll catch a bug that am missing.

the purpose of the script is to deop/devoice inactive users on a chan (not idle, cause they can be active in other chans, so they wouldn't be idle)


here's the code:
Code:

bind pubm - * update_timers
bind mode - "*+*o*" nick_got_oped
bind mode - "*+*v*" nick_got_voiced
bind mode - "*-*o*" nick_got_Doped
bind mode - "*-*v*" nick_got_Dvoiced


set list_of_chans "#aub"
set check_interval 2
set op_allowed_time 180
set vo_allowed_time 60

global time_op time_vo

proc update_timers {nick uhost hand chan text } {
#   global time_op time_vo

   if {[isop $nick $chan]} {
      set time_op($chan,$nick) [unixtime]
      putlog "timer updated for $nick (+o for another 40 min) - timer is now $time_op($chan,$nick)"
   }      
   if {[isvoice $nick $chan]} {
      set time_vo($chan,$nick) [unixtime]
      putlog "timer updated for $nick (+v for another 6 min)"
   }
}

proc nick_got_oped {nick uhost hand chan mode target} {
#   global time_op
   set time_op($chan,$target) [unixtime]
   putlog "$target just got oped , starting timer: $time_op($chan,$target)"
}

proc nick_got_voiced {nick uhost hand chan mode target} {
#   global time_vo
   set time_vo($chan,$target) [unixtime]
   putlog "$target just got voiced , starting timer: $time_vo($chan,$target)"
}

proc nick_got_Doped {nick uhost hand chan mode target} {
#   global time_op
   if {[info exists time_op($chan,$target)]} { unset time_op($chan,$target) }
   putlog "removed timer for $target (-o)"
}

proc nick_got_Dvoiced {nick uhost hand chan mode target} {
#   global time_vo
   if {[info exists time_vo($chan,$target)]} { unset time_vo($chan,$target) }
   putlog "removed timer for $target (-v)"
}

proc run_checking_timer { } {
   global list_of_chans check_interval
#   time_vo time_op
   foreach check_chan [split $list_of_chans] {
      putlog "Checking for inactive: \002$check_chan\002"
      inactive_checker $check_chan
   }
   timer $check_interval run_checking_timer
}
proc inactive_checker { chan } {
   global check_interval op_allowed_time vo_allowed_time botnick
#   time_vo time_op    

   foreach usernick [chanlist $chan] {
      if {[isop $usernick $chan] && $usernick != $botnick } {
         if {![info exists time_op($chan,$usernick)]} {
            set time_op($chan,$usernick) [unixtime]
            putlog "info for OP $usernick doesn't exist , setting time to $time_op($chan,$usernick)"
         }
         set inactivity_time [expr [unixtime] - $time_op($chan,$usernick)]
         putlog "$usernick: $inactivity_time = [unixtime] - $time_op($chan,$usernick)"
         if { $inactivity_time  > $op_allowed_time } {
            putlog "Inactive OP: $usernick - time: [expr $inactivity_time / 60] mins."
            pushmode $chan -o $usernick
            unset time_op($chan,$usernick)
         }   
      }
      if {[isvoice $usernick $chan] && $usernick != $botnick } {
         if {![info exists time_vo($chan,$usernick)]} {set time_vo($chan,$usernick) [unixtime] }
         set inactivity_time [expr [unixtime] - $time_vo($chan,$usernick)]
         if { $inactivity_time > $vo_allowed_time } {
            putlog "Inactive VO: $usernick - time: [expr $inactivity_time / 60] mins."
            pushmode $chan -v  $usernick
            unset time_vo($chan,$usernick)
         }   
      }
   }
}



timer $check_interval run_checking_timer

putlog "\[LOADED\] Inactive op/voice control - by SaPrOuZy."


i have alot of putlog to try to debug it, here's the result:
Quote:

[23:49] <)Profanity> [16:49] Checking for inactive: #aub
[23:49] <)Profanity> [16:49] info for OP Dilemma doesn't exist , setting time to 1124311740
[23:49] <)Profanity> [16:49] Dilemma: 0 = 1124311740 - 1124311740
[23:49] <)Profanity> [16:49] info for OP SaPrOuZy doesn't exist , setting time to 1124311740
[23:49] <)Profanity> [16:49] SaPrOuZy: 0 = 1124311740 - 1124311740
[23:49] <)Profanity> [16:49] info for OP Algorithm doesn't exist , setting time to 1124311740
[23:49] <)Profanity> [16:49] Algorithm: 0 = 1124311740 - 1124311740

[23:51] <)Profanity> [16:51] Checking for inactive: #aub
[23:51] <)Profanity> [16:51] Dilemma: 120 = 1124311860 - 1124311740
[23:51] <)Profanity> [16:51] SaPrOuZy: 120 = 1124311860 - 1124311740
[23:51] <)Profanity> [16:51] Algorithm: 120 = 1124311860 - 1124311740

[23:53] <)Profanity> [16:53] Checking for inactive: #aub
[23:53] <)Profanity> [16:53] Dilemma: 241 = 1124311981 - 1124311740
[23:53] <)Profanity> [16:53] Inactive OP: Dilemma - time: 4 mins.
[23:53] <)Profanity> [16:53] SaPrOuZy: 241 = 1124311981 - 1124311740
[23:53] <)Profanity> [16:53] Inactive OP: SaPrOuZy - time: 4 mins.
[23:53] <)Profanity> [16:53] Algorithm: 241 = 1124311981 - 1124311740
[23:53] <)Profanity> [16:53] Inactive OP: Algorithm - time: 4 mins.
[23:53] <)Profanity> [16:53] removed timer for Dilemma (-o)
[23:53] <)Profanity> [16:53] removed timer for SaPrOuZy (-o)
[23:53] <)Profanity> [16:53] removed timer for Algorithm (-o)
[23:53] <)Profanity> [16:53] SaPrOuZy just got oped , starting timer: 1124311982 <---------- it was just set here Exclamation

[23:55] <)Profanity> [16:55] Checking for inactive: #aub
[23:55] <)Profanity> [16:55] info for OP SaPrOuZy doesn't exist , setting time to 1124312100 <----------- here it can't read it Confused Exclamation
[23:55] <)Profanity> [16:55] SaPrOuZy: 0 = 1124312100 - 1124312100


thanks for your help...
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Aug 17, 2005 5:39 pm    Post subject: Reply with quote

your logic is unnecessarily complicated (and incorrect) - simply use [getchanidle], it gives you the inactivity time you need on the channel you are interested in, not the IRC idle time

also, the [bind mode] mask should be in the format "#chan +o" and similar, no need of asterisk there
Back to top
View user's profile Send private message Visit poster's website
SaPrOuZy
Halfop


Joined: 24 Mar 2004
Posts: 75
Location: Lebanon

PostPosted: Wed Aug 17, 2005 5:46 pm    Post subject: Reply with quote

thanks for the quick reply, but...

Quote:

getchanidle <nickname> <channel>
Returns: number of minutes that person has been idle; 0 if the
specified user isn't on the channel


it doesn't specify that it's the idletime on the chan, and as i have noticed from using it, it returns the irc idle time.

and i think the logic is very correct , it checks the difference between the current time, and the last time that the person said anything (or got oped)
if the person was already oped before the script started running, then logically the info shouldn't exist and thus it would set the time as now, and starts checking from then.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed Aug 17, 2005 5:55 pm    Post subject: Reply with quote

SaPrOuZy wrote:
thanks for the quick reply, but...

Quote:

getchanidle <nickname> <channel>
Returns: number of minutes that person has been idle; 0 if the
specified user isn't on the channel


it doesn't specify that it's the idletime on the chan, and as i have noticed from using it, it returns the irc idle time.

A little test on your eggdrop doesn't hurt, it returns the idle time of the user on the channel.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
SaPrOuZy
Halfop


Joined: 24 Mar 2004
Posts: 75
Location: Lebanon

PostPosted: Wed Aug 17, 2005 5:58 pm    Post subject: Reply with quote

it could have been a coincidence that the idle time for the chan and irc where the same for the cases i checked, i'll look more into it tomorrow Smile
thanks guys.
if it doesn't work , i'll ask again
g'night opposing , and good day demond hehe
Back to top
View user's profile Send private message
awyeah
Revered One


Joined: 26 Apr 2004
Posts: 1580
Location: Switzerland

PostPosted: Wed Aug 17, 2005 9:16 pm    Post subject: Reply with quote

Put this in a procedure and call it every 5-10 seconds or when ever you like.

Code:

if {![botisop $chan]} { return 0 }
foreach user [chanlist $chan] {
 if {[isvoice $user $chan] && ([getchanidle $user $chan] >= $vo_allowed_time)} { pushmode $chan -v $user
 } elseif {[isop $user $chan] && ([getchanidle $user $chan] >= $op_allowed_time)} { pushmode $chan -o $user
 }
}

_________________
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
SaPrOuZy
Halfop


Joined: 24 Mar 2004
Posts: 75
Location: Lebanon

PostPosted: Thu Aug 18, 2005 1:40 am    Post subject: Reply with quote

thanks awyeah, i already have a script based on getchanidle,
i thought it gets the IRC idle time, not the chan idle time...
i didn't get the time to test it again,but you guys seem to be sure about it
anyways, regardless of the logic of my script, could anyone tell me what's wrong. why isn't it keeping the info for time_op / time_vo in all the procs.
i tried declaring them as global in each proc, and i tried declaring them as global outside the procs (like the code now) but in both cases it was the same.
Back to top
View user's profile Send private message
awyeah
Revered One


Joined: 26 Apr 2004
Posts: 1580
Location: Switzerland

PostPosted: Thu Aug 18, 2005 2:04 am    Post subject: Reply with quote

Another method can be to get the idle time using a /ctcp FINGER. However, some people change their finger ctcp replies to random texts and messages, so NOT always the idle time in seconds shows up in replies.
_________________
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
SaPrOuZy
Halfop


Joined: 24 Mar 2004
Posts: 75
Location: Lebanon

PostPosted: Sat Aug 20, 2005 3:14 am    Post subject: Reply with quote

anyone figured out what's wrong with the script?
cause i suddenly have this prob in another script that was working! Shocked
the global variables aren't keeping their values from proc to proc
Exclamation Exclamation
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Aug 20, 2005 5:45 am    Post subject: Reply with quote

Remove the global line from outside the procs, and keep the ones inside the procs (uncomment them).
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
SaPrOuZy
Halfop


Joined: 24 Mar 2004
Posts: 75
Location: Lebanon

PostPosted: Sat Aug 20, 2005 5:47 am    Post subject: Reply with quote

that's how it was, but when it was doing this i tried doing it the way it's posted now
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive 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