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.

!idle alike script which is probably easy.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
G
Gewan
Voice
Posts: 27
Joined: Sat Dec 25, 2010 7:50 pm

!idle alike script which is probably easy.

Post by Gewan »

Hi guys!

This is my first time posting. I admit, I don't know anything about TCL so I couldn't write the simplest script how badly I ever wanted to. Now, nevertheless, I have this request for a function. I have seen several !idle scripts that simply keeps track on the particular user's idle time on specified channel (where the eggdrop must obviously be on).

However, I'm looking for a much easier function. I'm simply looking for eggdrop to grep the idle time that is reported by '/whois <nick <nick>' (twice, if users are on different servers on network). I.e. how long the user has been idle on the server as such. Do you get my deal here?

In my desired script, I would be to type in a channel:
<Gewan> !idle Ajnag

This would then give something say like:
<Eggdrop> Ajnag has been idle for 0 days 0 hours 41 mins 32 secs [signon: Sat Dec 25 04:52:53 2010]


Real simple, see?
Would be really awesome if any of you guys who have experience in TCL scripting could write this script and throw me an Pastebin URL or something. Hopefully, it would not require more than approx. 50 lines of code, perhaps much less. Like I said, my TCL experience is NULL. Nonetheless, I would be thrilled if someone had the time and will to help me out here, hehe.


Ty in adv~
Regards~
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Code: Select all

# Dec. 25, 2010
# forum request
#
# http://forum.egghelp.org/viewtopic.php?t=18208
#
# I'm simply looking for eggdrop to grep the idle time that is reported by '/whois <nick <nick>' 
# (twice, if users are on different servers on network). I.e. how long the user has been idle on the server as such. 
#
# In my desired script, I would be to type in a channel:
# <Gewan> !idle Ajnag
# 
# This would then give something say like:
# <Eggdrop> Ajnag has been idle for 0 days 0 hours 41 mins 32 secs [signon: Sat Dec 25 04:52:53 2010] 
#
#

 

bind pub - "!idle" do:whois


proc do:whois {nick uhost handle chan text} {
global workingchan

	if {"$text" == ""} {
		putserv "privmsg $chan :Syntax: !idle <nick> "
		return
	   }

	bind raw - 317 watch:317
	bind raw - 402 watch:402

	putserv "whois [split $text 0] [split $text 0]"
	set workingchan $chan
}


proc watch:317 {from keyword text} {
global workingchan

	putserv "privmsg $workingchan :[lindex [split $text] 1] has been idle [duration [lindex [split $text] 2]] \[signon [ctime [lindex [split $text] 3]]\]"

	unbind raw - 317 watch:317
	unbind raw - 402 watch:402
}


proc watch:402 {from keyword text} {
global workingchan

	putserv "privmsg $workingchan :\"[string trimleft [lindex $text 2] :] [lrange [split $text] 3 end]\""

	unbind raw - 317 watch:317
	unbind raw - 402 watch:402
}


putlog "Loaded Idle Time determined from WHOIS   ...  :)     see:  http://forum.egghelp.org/viewtopic.php?t=18208 "



Give this a try. :)


To use - just like you described:
!idle <nick>

Try it three ways:
!idle <nick>
!idle
!idle <non-existing nick>

First above is normal use.
Second is just the bare command, with nothing following it.
Third is giving it a nick that is not currently online.

It should react properly to all three scenarios.

I tested on one network. Works for me. :)
The only way to find out if it works on your network, is to give it a try.

I hope this helps.
User avatar
Anahel
Halfop
Posts: 48
Joined: Fri Jul 03, 2009 6:18 pm
Location: Dom!

Post by Anahel »

hmm, it wouldn't work properly in network with more than 1 server, as in most cases "whois" will display sigon/idle time only for people who are on server you both are
User avatar
Trixar_za
Op
Posts: 143
Joined: Wed Nov 18, 2009 1:44 pm
Location: South Africa
Contact:

Post by Trixar_za »

Anahel wrote:hmm, it wouldn't work properly in network with more than 1 server, as in most cases "whois" will display sigon/idle time only for people who are on server you both are
Actually it would. Note the putserv "whois [split $text 0] [split $text 0]", basicaly being whois nickname nickname - which is how you get the whois idle time request off a network. It works by forwarding the request to the right server and returning a response.

Reference: http://www.irchelp.org/irchelp/misc/cco ... Heading373
G
Gewan
Voice
Posts: 27
Joined: Sat Dec 25, 2010 7:50 pm

Post by Gewan »

First off, thank you _a lot_ willyw, much(!) appreciated.
I have now tested the script. Something's a bit weird though.
When I pull '!idle nicknotonchannel' it returns the perfect string set:

<@Eggdrop> Rapidboy has been idle 2 hours 13 minutes 22 seconds [signon Sun Dec 26 12:17:20 2010]

Also, when I pull '!idle offlinenick' I get:

<@Eggdrop> "No such server"

Will probably define it to something like "<nick> is not online", but function (the important) is flawless. Neat.

However, when I drop '!idle nickONchannel', then I will not get anything in return. When I look in the Eggdrop console, I see the following:

[15:18] Tcl error [watch:402]: unmatched open brace in list


Any ideas?
Anything would be of interest.
I'm really thankful! :)
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Gewan wrote:However, when I drop '!idle nickONchannel', then I will not get anything in return. When I look in the Eggdrop console, I see the following:

[15:18] Tcl error [watch:402]: unmatched open brace in list


Any ideas?
Anything would be of interest.
I'm really thankful! :)

Code: Select all

putserv "privmsg $workingchan :"[string trimleft [lindex $text 2] :] [lrange [split $text] 3 end]"" 
  • This up here ----^ should be like this down there ----v

Code: Select all

putserv "privmsg $workingchan :"[string trimleft [lindex [split $text] 2] :] [join [lrange [split $text] 3 end]]"" 
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Gewan wrote:First off, thank you _a lot_ willyw, much(!) appreciated.
You're welcome.
I have now tested the script. Something's a bit weird though.
When I pull '!idle nicknotonchannel' it returns the perfect string set:

<@Eggdrop> Rapidboy has been idle 2 hours 13 minutes 22 seconds [signon Sun Dec 26 12:17:20 2010]

Also, when I pull '!idle offlinenick' I get:

<@Eggdrop> "No such server"

Will probably define it to something like "<nick> is not online", but function (the important) is flawless. Neat.
Good.
And yes, it can be made to say anything you wish to indicate that the given nick is not online.
I went with what you see simply because that is the text that the server returned.

Edit it to whatever you like. :)

However, when I drop '!idle nickONchannel', then I will not get anything in return. When I look in the Eggdrop console, I see the following:

[15:18] Tcl error [watch:402]: unmatched open brace in list


Any ideas?
This is interesting.
Procedure watch:402 is called when a Raw 402 is returned.
That's what happens when you have it look for a nick that is not online.
And, you've reported that it works fine for that.
Yet, somehow, at another time when watch:402 was called, it errored?
There's something that I'm not understanding.....

Have you edited the script at all yet?
If so, can you copy-n-paste another original copy from this thread, and start over, and try that experiment again?

Next very curious item: It should make no difference if the given nick is in a channel with the bot, or not.
Anything would be of interest.
I'm really thankful! :)
And thank you for reporting back.

If anyone else reading along has input, perhaps they will post too.


p.s. The list of raw numerics that I used for reference can be found here:
http://www.mirc.net/raws/
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

speechles wrote:

Code: Select all

putserv "privmsg $workingchan :"[string trimleft [lindex $text 2] :] [lrange [split $text] 3 end]"" 
hehehe
As evidenced elsewhere, that is not my norm - to not split the string.
Thanks for catching it.


But, ( and I haven't had my cup of tea yet today ) I not seeing whatever is causing the error that he mentioned.
Especially since he reported that it worked fine one way, and not another.

Your thoughts?


Thanks
User avatar
Anahel
Halfop
Posts: 48
Joined: Fri Jul 03, 2009 6:18 pm
Location: Dom!

Post by Anahel »

Trixar_za wrote:
Anahel wrote:hmm, it wouldn't work properly in network with more than 1 server, as in most cases "whois" will display sigon/idle time only for people who are on server you both are
Actually it would. Note the putserv "whois [split $text 0] [split $text 0]", basicaly being whois nickname nickname - which is how you get the whois idle time request off a network. It works by forwarding the request to the right server and returning a response.

Reference: http://www.irchelp.org/irchelp/misc/cco ... Heading373
yeah, i didn't notice it, but still "whois nick nick" doesn't work on few networks
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

willyw wrote:This is interesting.
Procedure watch:402 is called when a Raw 402 is returned.
That's what happens when you have it look for a nick that is not online.
And, you've reported that it works fine for that.
Yet, somehow, at another time when watch:402 was called, it errored?
There's something that I'm not understanding.....
I showed you where this was. It is in how you catch the raw reply.

Code: Select all

putserv "privmsg $workingchan :"[string trimleft [lindex $text 2] :] [lrange [split $text] 3 end]"" 
You fail to split $text and tcl expects a list with properly escaped special characters. When a reply returns from any nicknames that contain uneven-braces, you will witness this error. What this does is break pairings and causes the unbalanced list error. You also failed to join your lrange back into a string. This will make for visible bracings and/or escapes to show. This is why I made those corrections for you.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

speechles wrote: ...
This is why I made those corrections for you.
Excellent!

I'm glad I asked you to explain it.
G
Gewan
Voice
Posts: 27
Joined: Sat Dec 25, 2010 7:50 pm

Works like a charm!

Post by Gewan »

Hi again guys!

Very much thanks to willyw & speechles; magnificent work!

Script now works flawless. Oh, you wanna know something funny? Check this out. At first it was failing -- what seemed -- intermittent (only from time to time), and I couldn't see the picture clearly, you feel me? I had made no modifications at the script, other than the correction speechles suggested. Now, the eggdrop console didn't bring up any errors, but !idle checks gave me "No such server". And hey, you wanna know what gave me the weird idea about "It seems to work but not with users who are in eggdrop's channel"..? Hehe, now comes the fun part. I'm an irssi user, and -- per default -- irssi's auto-completion adds a blank space after nicknames, so I ended up with string '!idle LameIRCer ' instead of '!idle LameIRCer'; notice the lack of blank space in the last example. This was -- of course -- causing the "Not found" return.

Now, after executing !idle strings without the ending blank space, script works _flawlessly_. Would it be much pain (an additional 50 lines of code or so*) to add so that script will except/omit any blank space, since no IRCd (that I know of) supports multi-word nicknames, such feature couldn't cause any harm.

However, it's "surplus" and really not essential. When triggering the script as it's ment to be '!idle <nick>' it works flawlessly, and it's really not that much pain for the irssi end-user to hit backspace once after auto-completion has kicked in, hehe.

Again. Thanks _a lot_ for this brilliant script. IMHO, you guys should post it on the official eggdrop script page. Me and my friends had the idea that this would be a neat feature for our channel, but after Googling for ~10h all I found was several idle scripts, but all those only kept internal track on users on particular channels etc, i.e. not what I was looking for. This one is minimalistic yet pure and brilliant. Will be used on a daily basis in our little group of fellows. You did great! :)

Cheers! :D
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Re: Works like a charm!

Post by willyw »

Gewan wrote: ...
I'm an irssi user, and -- per default -- irssi's auto-completion adds a blank space after nicknames, so I ended up with string '!idle LameIRCer ' instead of '!idle LameIRCer'; notice the lack of blank space in the last example. This was -- of course -- causing the "Not found" return.
Great!
I'm glad you pinned it down.
Now, after executing !idle strings without the ending blank space, script works _flawlessly_. Would it be much pain (an additional 50 lines of code or so*) to add so that script will except/omit any blank space, since no IRCd (that I know of) supports multi-word nicknames, such feature couldn't cause any harm.

However, it's "surplus"
Actually, this is 'fine tuning'. To fix it, that is. :)
and really not essential. When triggering the script as it's ment to be '!idle <nick>' it works flawlessly, and it's really not that much pain for the irssi end-user to hit backspace once after auto-completion has kicked in, hehe.
Ready to try something?

Find this line:

Code: Select all

putserv "whois [split $text 0] [split $text 0]" 
and remove it - replacing it with:

Code: Select all

putserv "whois [join [string trimright [split $text 0]]] [join [string trimright [split $text 0]]]"
Then please do test.

Here, on a test bot, with just a couple quick tests, it works.
I used a nick like this: jack[3]

and tested with:

Code: Select all

"!idle jack[3]" 
and again with:

Code: Select all

"!idle jack[3] "
and again with:

Code: Select all

"!idle jack[3]        "
Again. Thanks _a lot_ for this brilliant script. IMHO, you guys should post it on the official eggdrop script page. Me and my friends had the idea that this would be a neat feature for our channel, but after Googling for ~10h all I found was several idle scripts, but all those only kept internal track on users on particular channels etc, i.e. not what I was looking for. This one is minimalistic yet pure and brilliant. Will be used on a daily basis in our little group of fellows. You did great! :)

Cheers! :D
10 hours? ... whew...
I'm sure you'll pass along to your group of friends then, that this forum is an excellent one. :) And perhaps they will visit with us here some from time to time.

As for posting it in the TCL archive - I always feel like a script is "not quite done"... like there is room for some improvement.
Or... worse... that I've made some error that just has not shown up yet... witness what happened with the first try at this script, above. :)
I'm not a TCL guru... just self taught and like to fiddle with it.
But - maybe someday I'll get motivated and take the risk and post some of my favorites.

That's another advantage of a forum like this - more eyes on the project, are more apt to spot something and point it out, quicker.

I hope this works/helps.
G
Gewan
Voice
Posts: 27
Joined: Sat Dec 25, 2010 7:50 pm

Post by Gewan »

Oh man. I love this community. Script now runs _flawless_ from point A to Z.
I'm _so_ archiving it, since I'll probably be formatting disks and/or switching eggdrop hosting at least at some time.
And by then I will (probably) have lost track of this thread completely, and Google may not carry me here at the simplest search term, hehe.

Cheers, and again, many thanks!
G
Gewan
Voice
Posts: 27
Joined: Sat Dec 25, 2010 7:50 pm

Post by Gewan »

The script has served me and friends with perfection for the last months. Now, it seems I have found the very first bug. Check this out:

<@Gewan> !i shroomill
<@Eggdrop> shroomill has been idle 1 hour 40 minutes 52 seconds [signon Thu Feb 17 11:22:36 2011]
<@Gewan> !i davVE^BARCA
<@Eggdrop> davVE^BARCA has been idle 17 hours 25 minutes [signon Tue Feb 15 21:47:15 2011]
<@Gewan> !i iCC0\xD^DASS
<@Eggdrop> "No such server"


Of course, iCC0\tM^DASS is indeed in the channel. My spontaneous guess tells me that the backslash is what's messing the script's parse. What do you guys think? Suggestions? Anyone care to join for a simple fix? ;)

Ty in advance~
Regards~
Post Reply