Start basic telethon bot + aiohttp server
This commit is contained in:
parent
be038a90f5
commit
8d71f71a1d
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -106,3 +106,4 @@ ENV/
|
|||
db.sqlite3
|
||||
|
||||
data/*
|
||||
settings.py
|
||||
|
|
22
main.py
Normal file
22
main.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user