X-Git-Url: https://jfr.im/git/z_archive/twitter.git/blobdiff_plain/f4d2155a0c6dc2f6e91e3ba04c3cb770d1fa4ca0..1e28b4c31f31bcb6cb8d8dcdf883fbed4e79e43b:/twitter/ircbot.py diff --git a/twitter/ircbot.py b/twitter/ircbot.py index b870a1e..ee6adee 100644 --- a/twitter/ircbot.py +++ b/twitter/ircbot.py @@ -54,10 +54,10 @@ import traceback import os import os.path -from api import Twitter, TwitterError -from oauth import OAuth, read_token_file -from oauth_dance import oauth_dance -from util import htmlentitydecode +from .api import Twitter, TwitterError +from .oauth import OAuth, read_token_file +from .oauth_dance import oauth_dance +from .util import htmlentitydecode PREFIXES = dict( cats=dict( @@ -97,10 +97,10 @@ class SchedTask(object): def __repr__(self): return "" %( - self.task.__name__, self.next, self.delta) + self.task.__name__, self.__next__, self.delta) def __cmp__(self, other): - return cmp(self.next, other.next) + return cmp(self.__next__, other.__next__) def __call__(self): return self.task() @@ -114,7 +114,7 @@ class Scheduler(object): def next_task(self): now = time.time() task = heappop(self.task_heap) - wait = task.next - now + wait = task.__next__ - now task.next = now + task.delta heappush(self.task_heap, task) if (wait > 0): @@ -160,8 +160,8 @@ class TwitterBot(object): debug("In check_statuses") try: updates = reversed(self.twitter.statuses.friends_timeline()) - except Exception, e: - print >> sys.stderr, "Exception while querying twitter:" + except Exception as e: + print("Exception while querying twitter:", file=sys.stderr) traceback.print_exc(file=sys.stderr) return @@ -179,7 +179,7 @@ class TwitterBot(object): # to people who are not on our following list. if not text.startswith("@"): self.privmsg_channels( - u"%s %s%s%s %s" %( + "%s %s%s%s %s" %( get_prefix(), IRC_BOLD, update['user']['screen_name'], IRC_BOLD, text.decode('utf-8'))) @@ -338,11 +338,11 @@ def main(): if not os.path.exists(configFilename): raise Exception() load_config(configFilename) - except Exception, e: - print >> sys.stderr, "Error while loading ini file %s" %( - configFilename) - print >> sys.stderr, e - print >> sys.stderr, __doc__ + except Exception as e: + print("Error while loading ini file %s" %( + configFilename), file=sys.stderr) + print(e, file=sys.stderr) + print(__doc__, file=sys.stderr) sys.exit(1) bot = TwitterBot(configFilename)