Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

Deploying async version to Heroku #431

Open
Kuper007 opened this issue Nov 26, 2018 · 0 comments
Open

Deploying async version to Heroku #431

Kuper007 opened this issue Nov 26, 2018 · 0 comments

Comments

@Kuper007
Copy link

Hello, I need some help with deploying async version to Heroku. For now it's running with 'heroku run python *.py' but of course I want it to run automatically. I know that I need to use Flask and I've already tried doing it as in example with no-async version but I just don't understand how it works. Maybe you can explain me better.

import asyncio
import telepot
import telepot.aio
import pprint
from telepot.aio.loop import MessageLoop
from telepot.namedtuple import ReplyKeyboardMarkup, KeyboardButton, ReplyKeyboardRemove

TOKEN = '************'
bot = telepot.Bot(TOKEN)

async def handle(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
    pprint.pprint(msg)
    if content_type == 'text':
        message=msg['text']
        await bot.sendMessage(chat_id,'Hi!')
        return

bot = telepot.aio.Bot(TOKEN)
loop = asyncio.get_event_loop()

loop.create_task(MessageLoop(bot, handle).run_forever())
print('Listening ...')

loop.run_forever()

This is just a little part of my code but if you manage to help me with deploying to Heroku, I will be able to deploy my full code by myself.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant