Set follows gauge on startup
This commit is contained in:
parent
c022a62e98
commit
3b04182ea2
1 changed files with 6 additions and 3 deletions
|
@ -161,15 +161,15 @@ class JARVISTwitterStream(AsyncStream):
|
|||
except Exception:
|
||||
logger.debug(f"Failed to send message to {channel.id} in {channel.guild.name}")
|
||||
|
||||
gauge = twitter_gauge.labels(twitter_handle=status.user.screen_name)
|
||||
gauge.set(num_follows)
|
||||
|
||||
if num_follows == 0:
|
||||
logger.warning(f"Account {status.author.screen_name} no longer has followers, removing")
|
||||
account = await TwitterAccount.find_one(q(twitter_id=status.author.id))
|
||||
if account:
|
||||
await account.delete()
|
||||
self.disconnect()
|
||||
else:
|
||||
gauge = twitter_gauge.labels(twitter_handle=status.user.screen_name)
|
||||
gauge.set(num_follows)
|
||||
|
||||
|
||||
async def twitter(bot: Client) -> None:
|
||||
|
@ -205,6 +205,9 @@ async def twitter(bot: Client) -> None:
|
|||
if count == 0:
|
||||
logger.debug(f"Account {account.handle} has no followers, removing")
|
||||
await account.delete()
|
||||
else:
|
||||
gauge = twitter_gauge.labels(twitter_handle=account.handle)
|
||||
gauge.set(count)
|
||||
while True:
|
||||
accounts = TwitterAccount.find()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue