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:
|
except Exception:
|
||||||
logger.debug(f"Failed to send message to {channel.id} in {channel.guild.name}")
|
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:
|
if num_follows == 0:
|
||||||
logger.warning(f"Account {status.author.screen_name} no longer has followers, removing")
|
logger.warning(f"Account {status.author.screen_name} no longer has followers, removing")
|
||||||
account = await TwitterAccount.find_one(q(twitter_id=status.author.id))
|
account = await TwitterAccount.find_one(q(twitter_id=status.author.id))
|
||||||
if account:
|
if account:
|
||||||
await account.delete()
|
await account.delete()
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
|
else:
|
||||||
|
gauge = twitter_gauge.labels(twitter_handle=status.user.screen_name)
|
||||||
|
gauge.set(num_follows)
|
||||||
|
|
||||||
|
|
||||||
async def twitter(bot: Client) -> None:
|
async def twitter(bot: Client) -> None:
|
||||||
|
@ -205,6 +205,9 @@ async def twitter(bot: Client) -> None:
|
||||||
if count == 0:
|
if count == 0:
|
||||||
logger.debug(f"Account {account.handle} has no followers, removing")
|
logger.debug(f"Account {account.handle} has no followers, removing")
|
||||||
await account.delete()
|
await account.delete()
|
||||||
|
else:
|
||||||
|
gauge = twitter_gauge.labels(twitter_handle=account.handle)
|
||||||
|
gauge.set(count)
|
||||||
while True:
|
while True:
|
||||||
accounts = TwitterAccount.find()
|
accounts = TwitterAccount.find()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue