Add random emojis to names

This commit is contained in:
Tanner Collin 2021-03-02 10:32:27 +00:00
parent e5b94b30c8
commit d4fafe10c0

View File

@ -1,5 +1,6 @@
import aiohttp import aiohttp
import asyncio import asyncio
import emoji
import logging import logging
import re import re
import settings import settings
@ -8,6 +9,7 @@ from telethon import TelegramClient, events
bot = TelegramClient('bot', settings.API_ID, settings.API_HASH).start(bot_token=settings.API_TOKEN) bot = TelegramClient('bot', settings.API_ID, settings.API_HASH).start(bot_token=settings.API_TOKEN)
web = None web = None
api = lambda route: settings.DYNMAP_ADDRESS + route api = lambda route: settings.DYNMAP_ADDRESS + route
emojis = list(emoji.unicode_codes.UNICODE_EMOJI_ENGLISH.keys())
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
@bot.on(events.NewMessage(incoming=True)) @bot.on(events.NewMessage(incoming=True))
@ -43,7 +45,10 @@ async def main():
for update in j['updates']: for update in j['updates']:
if update['type'] != 'chat': continue if update['type'] != 'chat': continue
if update['playerName'].endswith('(TG)'): continue if update['playerName'].endswith('(TG)'): continue
message = '<{}> {}'.format(update['playerName'], update['message'])
name = update['playerName']
icon = emojis[hash(name) % len(emojis)]
message = '{} <{}> {}'.format(icon, name, update['message'])
if message == last_msg: continue if message == last_msg: continue
logging.info('[RECV] ' + message) logging.info('[RECV] ' + message)