1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Add significant level up notifications

This commit is contained in:
Steffo 2019-11-05 10:48:22 +01:00
parent 3f2cf1336c
commit 36c13bb23b

View file

@ -32,6 +32,14 @@ class LeagueoflegendsCommand(Command):
if self.interface.name == "telegram": if self.interface.name == "telegram":
self.loop.create_task(self._updater(900)) self.loop.create_task(self._updater(900))
async def _send(self, message):
client = self.interface.bot.client
await self.interface.bot.safe_api_call(client.send_message,
chat_id=self._telegram_group_id,
text=telegram_escape(message),
parse_mode="HTML",
disable_webpage_preview=True)
async def _notify(self, async def _notify(self,
obj: LeagueOfLegends, obj: LeagueOfLegends,
attribute_name: str, attribute_name: str,
@ -58,12 +66,11 @@ class LeagueoflegendsCommand(Command):
message = f"📉 [b]{obj.user}[/b] è sceso a {new_value} su League of Legends " \ message = f"📉 [b]{obj.user}[/b] è sceso a {new_value} su League of Legends " \
f"({queue_names[attribute_name]})." f"({queue_names[attribute_name]})."
# Send the message # Send the message
client = self.interface.bot.client await self._send(message)
await self.interface.bot.safe_api_call(client.send_message, # Level up!
chat_id=self._telegram_group_id, elif attribute_name == "summoner_level":
text=telegram_escape(message), if new_value == 30 or (new_value >= 50 and (new_value % 25 == 0)):
parse_mode="HTML", await self._send(f"🆙 [b]{obj.user}[/b] è salito al livello [b]{new_value}[/b] su League of Legends!")
disable_webpage_preview=True)
@staticmethod @staticmethod
async def _change(obj: LeagueOfLegends, async def _change(obj: LeagueOfLegends,