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.

inactive op/voice control

Old posts that have not been replied to for several years.
Locked
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

inactive op/voice control

Post by SaPrOuZy »

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

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:
[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 :!:

[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 :? :!:
[23:55] <)Profanity> [16:55] SaPrOuZy: 0 = 1124312100 - 1124312100
thanks for your help...
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

Post by SaPrOuZy »

thanks for the quick reply, but...
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.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

SaPrOuZy wrote:thanks for the quick reply, but...
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.
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

Post by SaPrOuZy »

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 :)
thanks guys.
if it doesn't work , i'll ask again
g'night opposing , and good day demond hehe
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

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

Code: Select all

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.
==================================
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

Post by SaPrOuZy »

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.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

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.
==================================
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

Post by SaPrOuZy »

anyone figured out what's wrong with the script?
cause i suddenly have this prob in another script that was working! :shock:
the global variables aren't keeping their values from proc to proc
:!: :!:
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Remove the global line from outside the procs, and keep the ones inside the procs (uncomment them).
User avatar
SaPrOuZy
Halfop
Posts: 75
Joined: Wed Mar 24, 2004 7:38 am
Location: Lebanon

Post by SaPrOuZy »

that's how it was, but when it was doing this i tried doing it the way it's posted now
Locked