diff --git a/gazouilleur/bot.py b/gazouilleur/bot.py index f961da8..c3a8616 100644 --- a/gazouilleur/bot.py +++ b/gazouilleur/bot.py @@ -141,6 +141,8 @@ def _get_chan_known_users(self, channel): @inlineCallbacks def joined(self, channel): NamesIRCClient.joined(self, channel) + conf = chanconf(channel) + conf["oauth2"] = None lowchan = channel.lower() self.logger[lowchan] = FileLogger(lowchan) loggirc("Joined.", channel) @@ -152,7 +154,6 @@ def joined(self, channel): self.filters[lowchan] = [keyword['keyword'].encode('utf-8') for keyword in filters] self.silent[lowchan] = datetime.today() self.feeders[lowchan] = {} - conf = chanconf(channel) # Get list of known users on the chan if welcome message activated self.users[lowchan] = set() if "WELCOME" in conf and conf["WELCOME"]: @@ -163,22 +164,20 @@ def joined(self, channel): if twuser: # Get OAuth2 tokens for twitter search extra limitrate try: - oauth2_token = Microblog("twitter", conf, get_token=True).get_oauth2_token() + conf["oauth2"] = Microblog("twitter", conf, get_token=True).get_oauth2_token() loggvar("Got OAuth2 token for %s on Twitter." % twuser, channel, "twitter") except Exception as e: - oauth2_token = None err = clean_oauth_error(e) loggerr("Could not get an OAuth2 token from Twitter for user @%s: %s" % (twuser, err), channel, "twitter") - conf["oauth2"] = oauth2_token # Follow Searched Tweets matching queries set for this channel with !follow - self.feeders[lowchan]['twitter_search'] = FeederFactory(self, channel, 'search', 90 if oauth2_token else 180, timeout=600, twitter_token=oauth2_token) + self.feeders[lowchan]['twitter_search'] = FeederFactory(self, channel, 'search', 90 if conf["oauth2"] else 180, timeout=600, twitter_token=conf["oauth2"]) # Follow Searched Tweets matching queries set for this channel with !follow via Twitter's streaming API - self.feeders[lowchan]['stream'] = FeederFactory(self, channel, 'stream', 5, timeout=90, twitter_token=oauth2_token) + self.feeders[lowchan]['stream'] = FeederFactory(self, channel, 'stream', 5, timeout=90, twitter_token=conf["oauth2"]) # Follow Stats for Twitter USER if chan_has_twitter(channel, conf): self.feeders[lowchan]['stats'] = FeederFactory(self, channel, 'stats', 600) # Follow Tweets sent by Twitter USER - self.feeders[lowchan]['mytweets_T'] = FeederFactory(self, channel, 'mytweets', 20 if oauth2_token else 30, twitter_token=oauth2_token) + self.feeders[lowchan]['mytweets_T'] = FeederFactory(self, channel, 'mytweets', 20 if conf["oauth2"] else 30, twitter_token=conf["oauth2"]) # Deprecated # Follow Tweets sent by and mentionning Twitter USER via IceRocket.com # self.feeders[lowchan]['mytweets'] = FeederFactory(self, channel, 'tweets', 289, pagetimeout=20, [getIcerocketFeedUrl('%s+OR+@%s' % (twuser, twuser))], tweets_search_page='icerocket')