added the ability to read unicode emojis

This commit is contained in:
2021-08-11 15:17:02 -05:00
parent e459c84e1e
commit 58a2464cb4
2 changed files with 56 additions and 36 deletions

View File

@@ -26,6 +26,7 @@ class RoboPage(discord.Client):
self.jokes = list(attrs)
self.lock = Lock()
self.emoji_regex = re.compile("^who is the most (?P<emoji>\w+)(?: in the past (?P<days>\d+) days)?\??$", re.IGNORECASE)
self.leaderboard_regex = re.compile('^most (?P<emoji>\w+) leaderboard$', re.IGNORECASE)
def run(self):
return super().run(os.getenv('DISCORD_TOKEN'))
@@ -37,8 +38,8 @@ class RoboPage(discord.Client):
self.data: msg.MsgData = await msg.MsgData.create(
client=self,
limit=3000,
# limit=20,
# limit=3000,
limit=20,
days=14,
)
self.data.to_sql('messages.db')
@@ -78,6 +79,7 @@ if __name__ == '__main__':
async def on_ready():
# print(len(list(client.get_all_members())))
await client.handle_ready()
print('\n'.join(client.data.reactions.index.get_level_values(1).drop_duplicates().sort_values()))
@client.event
@@ -88,13 +90,19 @@ if __name__ == '__main__':
@client.event
async def on_raw_reaction_add(payload):
LOGGER.info(payload)
await client.data.update_reaction(payload=payload, client=client)
try:
await client.data.update_reaction(payload=payload, client=client)
except AttributeError as e:
LOGGER.info(f'Robopage not initialized yet')
@client.event
async def on_raw_reaction_remove(payload):
LOGGER.info(payload)
await client.data.update_reaction(payload=payload, client=client)
try:
await client.data.update_reaction(payload=payload, client=client)
except AttributeError as e:
LOGGER.info(f'Robopage not initialized yet')
client.run()