#!/usr/bin/env python # Daily countdown update script for Knab factoids # Copyright (C) 2008 Michael Gorven # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . from datetime import date from irclib import IRC from time import sleep target = date(2009,01,01) days = (target - date.today()).days channel = 'recipient' nick = 'nick' server = 'irc.example.com' port = 6667 def connected(connection, event): connection.privmsg(channel, "no, Outsider.countdown is %s days (%s)" % (days, date.today())) def messaged(connection, event): connection.quit('') def disconnected(connection, event): exit(0) irc = IRC() connection = irc.server().connect(server, port, nick) connection.add_global_handler("welcome", connected) connection.add_global_handler("disconnect", disconnected) connection.add_global_handler("privmsg", messaged) irc.process_forever()