Start basic telethon bot + aiohttp server

This commit is contained in:
Tanner Collin 2021-08-20 20:54:26 +00:00
parent be038a90f5
commit 8d71f71a1d
2 changed files with 23 additions and 0 deletions

1
.gitignore vendored
View File

@ -106,3 +106,4 @@ ENV/
db.sqlite3 db.sqlite3
data/* data/*
settings.py

22
main.py Normal file
View File

@ -0,0 +1,22 @@
import settings
import asyncio
from telethon import TelegramClient, events
from aiohttp import web
bot = TelegramClient('data/bot', settings.API_ID, settings.API_HASH).start(bot_token=settings.API_TOKEN)
@bot.on(events.NewMessage(incoming=True))
async def new_message(event):
text = event.raw_text
print(text)
async def submit(request):
data = await request.post()
print(data)
if __name__ == '__main__':
bot.start()
app = web.Application()
app.router.add_post('/', submit)
web.run_app(app, port=8123)