[twitter] Add username to twitter bots

This commit is contained in:
Cathy Hu 2020-08-31 14:08:21 +02:00
parent b66f906f88
commit a7f0898fd7
2 changed files with 4 additions and 0 deletions

View file

@ -38,6 +38,9 @@ class TwitterBot(Censor):
if self.twitter_model.dms_since_id is None: if self.twitter_model.dms_since_id is None:
logger.debug('since_id is None in model, fetch newest dm id') logger.debug('since_id is None in model, fetch newest dm id')
await self._poll_direct_messages() await self._poll_direct_messages()
user = await self.client.user
if user.screen_name:
await self.twitter_model.update(username=user.screen_name)
logger.debug('Starting Twitter bot: %s' % self.twitter_model.__dict__) logger.debug('Starting Twitter bot: %s' % self.twitter_model.__dict__)
await gather(self.poll(), self.push()) await gather(self.poll(), self.push())
except CancelledError: except CancelledError:

View file

@ -13,6 +13,7 @@ class Twitter(Model):
mentions_since_id: Integer(allow_null=True) = None mentions_since_id: Integer(allow_null=True) = None
access_token: Text() access_token: Text()
access_token_secret: Text() access_token_secret: Text()
username: Text(allow_null=True) = None
verified: Boolean() = False verified: Boolean() = False
enabled: Boolean() = False enabled: Boolean() = False