DeadEd.com
IRC Bots, Java Game Query and Control Libraries, and More ...
Sign Up!
Login
Welcome to DeadEd.com
Monday, September 25 2017 @ 01:07 AM CDT

 Forum Index > DeadEd.com > IRC Bots
 Last seen function
 |  Printable Version
By: Tayotoshi (offline) on Thursday, August 12 2010 @ 01:49 AM CDT (Read 3136 times)  
Tayotoshi

I would like to write a "last seen" command, so that when a user types !seen nickname, the bot

returns information how long it has been since he's seen that person in that channel.

I've been thinking up this:

 

Bot joins channel

Create txt file with channel name

Get user list for channel

Write nicks + current time in millis to txt file

 

When a new user joins the channel

Write nick + current time in millis to txt file

 

When a user parts the channel or quits the server

Search the nick in the textfile, and change the recorded time into the current time in millis


When a user changes nickname

Search the nick in the textfile and replace it with the new nick


When the !seen <nick> command is used in channel abcd

Get channel user list

If user list contains nick

       send message "the user is in the channel"

else

     if nick found

          Search the nick in the textfile, get the recorded time in millis.

          current time in millis - recorded time in millis = time since we last saw this user

          convert time in millis to time in hours/minutes

          send message "user was last seen in this channel xx hours xx min ago"

     else

          send message "haven't seen this user"

    

 

 

 

I'm looking for some hints in the right direction.

Greets

Tayo

 

 


Forum Junior
Junior

Status: offline

Registered: 08/11/10
Posts: 26

Profile      
   
By: DeadEd (offline) on Thursday, August 12 2010 @ 03:47 AM CDT  
DeadEd

That seems like you have it well covered - long time since I've seen someone use pseudo code and actually think it through before hitting the code Smile

Only thing that I can think to ask is ... Are you making it a !seen per channel on purpose?  Wouldn't any visibility of that nick in any shared channel be the seen result?

 


Forum Moderator
Moderator

Status: offline

Registered: 06/01/04
Posts: 602

Profile Email Website  
   
By: Tayotoshi (offline) on Thursday, August 12 2010 @ 05:52 AM CDT  
Tayotoshi

I thought of two issues:

 

1. Multiple channels

   Imagine a person is/has been present in 10 different channels, entering them and leaving them at different times.

   How would I generate output for that, without making it ugly and impractical for the user? Doesn't seem right to list

   all of the channels + the times they were last seen in those.

   More practically, a user could search when <nick> was last seen in a particular channel.

 

2. Private channels

   People in private channels don't always like if any people on the server can see in which private channels they are.

   Separate txt files would make sure people can not search cross-channel to get info about channels in which they are

   not allowed.

 

I'm doubting whether to use textfiles or a MS Access database. I'm better acquianted with MS Access in java than txt files,

but maybe connecting with a database for every query would make it slow?


Forum Junior
Junior

Status: offline

Registered: 08/11/10
Posts: 26

Profile      
   
By: DeadEd (offline) on Thursday, August 12 2010 @ 08:17 AM CDT  
DeadEd

Not had too much experience with DBs myself, I have tended to use XML files for storage.  In some cases I have used MySQL where the DB is somewhere else, so a remote connection is needed, and I hadn't noticed any slowdown because of this.  There are also embedded options, such as Derby. 

 

In your case, I'd try MS Access first and see if there really are any performance issues. 

 


Forum Moderator
Moderator

Status: offline

Registered: 06/01/04
Posts: 602

Profile Email Website  
   



 All times are CDT. The time is now 01:07 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

My Account





Sign up as a New User
Lost your password?

What's New

Stories

No new stories

Comments last 2 days

No new comments

Files last 14 days

No new files
No new comments

Links last 2 weeks

No new links