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 

!idle alike script which is probably easy.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Gewan
Voice


Joined: 25 Dec 2010
Posts: 27

PostPosted: Sat Dec 25, 2010 7:58 pm    Post subject: !idle alike script which is probably easy. Reply with quote

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~
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sat Dec 25, 2010 10:19 pm    Post subject: Reply with quote

Code:

# 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. Smile


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. Smile
The only way to find out if it works on your network, is to give it a try.

I hope this helps.
Back to top
View user's profile Send private message
Anahel
Halfop


Joined: 03 Jul 2009
Posts: 48
Location: Dom!

PostPosted: Sun Dec 26, 2010 7:28 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Trixar_za
Op


Joined: 18 Nov 2009
Posts: 143
Location: South Africa

PostPosted: Sun Dec 26, 2010 9:53 am    Post subject: Reply with quote

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/ccosmos.html#Heading373
_________________
http://www.trixarian.net/Projects
Back to top
View user's profile Send private message Visit poster's website
Gewan
Voice


Joined: 25 Dec 2010
Posts: 27

PostPosted: Sun Dec 26, 2010 10:24 am    Post subject: Reply with quote

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! Smile
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun Dec 26, 2010 10:46 am    Post subject: Reply with quote

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


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

_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sun Dec 26, 2010 11:03 am    Post subject: Reply with quote

Gewan wrote:
First off, thank you _a lot_ willyw, much(!) appreciated.


You're welcome.

Quote:

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


Quote:

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.

Quote:

Anything would be of interest.
I'm really thankful! Smile


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/
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sun Dec 26, 2010 11:14 am    Post subject: Reply with quote

speechles wrote:


Code:
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
Back to top
View user's profile Send private message
Anahel
Halfop


Joined: 03 Jul 2009
Posts: 48
Location: Dom!

PostPosted: Sun Dec 26, 2010 11:54 am    Post subject: Reply with quote

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/ccosmos.html#Heading373


yeah, i didn't notice it, but still "whois nick nick" doesn't work on few networks
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun Dec 26, 2010 12:04 pm    Post subject: Reply with quote

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:
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.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sun Dec 26, 2010 12:13 pm    Post subject: Reply with quote

speechles wrote:

...
This is why I made those corrections for you.


Excellent!

I'm glad I asked you to explain it.
Back to top
View user's profile Send private message
Gewan
Voice


Joined: 25 Dec 2010
Posts: 27

PostPosted: Sun Dec 26, 2010 3:16 pm    Post subject: Works like a charm! Reply with quote

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

Cheers! Very Happy
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sun Dec 26, 2010 4:10 pm    Post subject: Re: Works like a charm! Reply with quote

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.

Quote:

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

Quote:

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:

putserv "whois [split $text 0] [split $text 0]"


and remove it - replacing it with:
Code:

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:
"!idle jack[3]"

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

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



Quote:

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

Cheers! Very Happy


10 hours? ... whew...
I'm sure you'll pass along to your group of friends then, that this forum is an excellent one. Smile 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. Smile
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.
Back to top
View user's profile Send private message
Gewan
Voice


Joined: 25 Dec 2010
Posts: 27

PostPosted: Sun Dec 26, 2010 4:34 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
Gewan
Voice


Joined: 25 Dec 2010
Posts: 27

PostPosted: Thu Feb 17, 2011 12:08 pm    Post subject: Reply with quote

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

Ty in advance~
Regards~
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
Goto page 1, 2  Next
Page 1 of 2

 
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