python - Keep track of items in array with timer -


i apologize couldn't find proper title, let me explain i'm working on:

i have python irc bot, , want able keep track of how long users have been idle in channel, , allow them earn things (i have tied skype/minecraft/my website) each x amount of hours they're idle in channel.

i have keep track of each user , have them validated site , stuff, not sure how keep track of time they're idle.

i have capture on join/leave/part messages. how can timer set when join, , keep timer running, along other times of users in channel, , each hour they've been idle (not @ same time) restart timer on them?

two general ways:

  1. create separate timer each user when joins, when timer fires , destroy when user leaves.

  2. have 1 timer set fire, say, every second (or ten seconds) , iterate on users when fires see how long have been idle.

a more precise answer require deeper insight architecture, i’m afraid.


Comments