add countdown items, which are put at a particular time, hopefully in the future

This commit is contained in:
Brian S. Stephan 2010-07-25 11:53:07 -05:00
parent 9183c6f81f
commit 50d99feaa7
1 changed files with 19 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import os
import re
import sys
from dateutil.parser import *
from dateutil.relativedelta import *
from dateutil.tz import *
import irclib
@ -129,6 +130,22 @@ def sub_change_nick(connection, event, nick, userhost, replypath, what, admin_un
config.set('IRC', 'nick', newnick)
connection.privmsg(replypath, 'changed nickname')
#####
# sub_add_countdown
# add a countdown item to the bot
#####
def sub_add_countdown(connection, event, nick, userhost, replypath, what, admin_unlocked):
whats = what.split(' ')
if whats[0] == 'countdown' and len(whats) >= 4:
if whats[1] == 'add':
item = whats[2]
target = parse(' '.join(whats[3:]))
if not config.has_section('countdown'):
config.add_section('countdown')
config.set('countdown', item, target.astimezone(tzutc()).isoformat())
#####
# on_connect
# handler for when the bot has connected to IRC
@ -177,6 +194,7 @@ def on_privmsg(connection, event):
# standard commands
sub_report_seen(connection, event, nick, userhost, replypath, what, admin_unlocked)
sub_add_countdown(connection, event, nick, userhost, replypath, what, admin_unlocked)
#####
# on_pubmsg
@ -217,6 +235,7 @@ def on_pubmsg(connection, event):
# standard commands
sub_report_seen(connection, event, nick, userhost, replypath, what, admin_unlocked)
sub_add_countdown(connection, event, nick, userhost, replypath, what, admin_unlocked)
#####
# init