[feature]implement telegram for python version
geeks121 opened this issue · 0 comments
geeks121 commented
hi thank you for the bot,, can you implement this code to the python version... this code work for pancakeswap sniper ,, and listening to the telegram channel ,, but i think this also work with kucoin ,,
from telethon import TelegramClient, sync, events
-------------------------
async def message_handler(message, containing_fields=None):
if containing_fields is None:
containing_fields = ['The coin is']
if not (containing_fields[0] in message.lower()):
return
symbol = re.search('\(([^)]+)', message).group(1) # need to change this to work with capslock coin
response = await buy_token(symbol)
print(response)
if (str(type(response)) == "<class 'ValueError'>"):
response = ast.literal_eval(str(response))
response = '**Error Code**: {}\n**Error Message**: {}'.format(response['code'], response['message'])
else:
response = '**Transaction Hash**:\n```{}```'.format(str(response))
await send(response)
async def send(msg):
await client.send_message(to, msg)
usr_config = json.load(open('/config.json'))
to = usr_config['update_to']
scheduler = BackgroundScheduler()
client = TelegramClient('session_name', usr_config['api_id'], usr_config['api_hash'])
@client.on(events.NewMessage(chats=usr_config['channel'])) # channel is in config json
async def message_listenner(event): await message_handler(event.message.message)
with client:
client.run_until_disconnected()
here is the config.json
{
"api_id": 78
"api_hash": "#",
"channel": "kucoin_pump",
"update_to": "me",
}