# Twitter init print "Verifying Twitter credentials..." user = api.verify_credentials() if user: print "Authenticated with Twitter as @%s" % user.screen_name else: print "Could not verify credientials. Check your Twitter credentials in config.py!" sys.exit(1) # main irc = IRCConnection( server=config.server, port=config.port, password=config.password, nick=config.nick, realname=config.realname, user=config.user, channels=[config.chan], ) irc.on("privmsg", handle_privmsg) irc.on("kick", handle_kick) # irc.on('*', handle_unknown) t = threading.Thread(target=twitter_mentions_thread, args=(api, irc)) t.daemon = True t.start() irc.connect()
sleep(mentions_interval) for tweet in api.mentions_timeline(): if tweet.created_at > datetime.utcnow() - timedelta(seconds=mentions_interval): irc.notice(config.chan, ("Tweet von @%s: %s" % (tweet.user.screen_name, unescape(tweet.text).replace('\n', ' '))).encode('utf-8')) except Exception, e: log_error("!!! Exception in twitter_mentions_thread: %s" % e) # Twitter init log("Verifying Twitter credentials...") user = api.verify_credentials() if user: log('Authenticated with Twitter as @%s' % user.screen_name) else: log('Could not verify credientials. Check your Twitter credentials in config.py!') sys.exit(1) # main irc = IRCConnection(server=config.server, port=config.port, ssl=config.ssl, password=config.password, nick=config.nick, realname=config.realname, user=config.user, channels=[config.chan]) irc.on('privmsg', handle_privmsg) irc.on('kick', handle_kick) irc.on('quit', handle_quit) irc.on('error', handle_error) irc.on('ERR_NICKNAMEINUSE', handle_err_nicknameinuse) #irc.on('*', handle_unknown) t = threading.Thread(target=twitter_mentions_thread, args=(api, irc)) t.daemon = True t.start() irc.connect()
while True: try: sleep(30) for tweet in api.mentions(): if tweet.created_at > datetime.utcnow() - timedelta(seconds=30): irc.notice(config.chan, ("Tweet von @%s: %s" % (tweet.user.screen_name, unescape(tweet.text).replace('\n', ' '))).encode('utf-8')) except Exception, e: print "!!! Exception in twitter_mentions_thread:" print e # Twitter init print "Verifying Twitter credentials..." user = api.verify_credentials() if user: print 'Authenticated with Twitter as @%s' % user.screen_name else: print 'Could not verify credientials. Check your Twitter credentials in config.py!' sys.exit(1) # main irc = IRCConnection(server=config.server, port=config.port, password=config.password, nick=config.nick, realname=config.realname, user=config.user, channels=[config.chan]) irc.on('privmsg', handle_privmsg) irc.on('kick', handle_kick) #irc.on('*', handle_unknown) t = threading.Thread(target=twitter_mentions_thread, args=(api, irc)) t.daemon = True t.start() irc.connect()