From d4fafe10c0a9fa2a4b581a761dfa317fe8c4f6a3 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 2 Mar 2021 10:32:27 +0000 Subject: [PATCH] Add random emojis to names --- teledynmap.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/teledynmap.py b/teledynmap.py index 25da437..f331fda 100644 --- a/teledynmap.py +++ b/teledynmap.py @@ -1,5 +1,6 @@ import aiohttp import asyncio +import emoji import logging import re 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) web = None api = lambda route: settings.DYNMAP_ADDRESS + route +emojis = list(emoji.unicode_codes.UNICODE_EMOJI_ENGLISH.keys()) logging.basicConfig(level=logging.INFO) @bot.on(events.NewMessage(incoming=True)) @@ -43,7 +45,10 @@ async def main(): for update in j['updates']: if update['type'] != 'chat': 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 logging.info('[RECV] ' + message)