Add random emojis to names

master
Tanner Collin 3 years ago
parent e5b94b30c8
commit d4fafe10c0
  1. 7
      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)

Loading…
Cancel
Save