diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..553ab97 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +API_ID=12345 +API_HASH=0123456789abcdef0123456789abcdef +BOT_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11 diff --git a/.gitignore b/.gitignore index fb6655f..5700012 100644 --- a/.gitignore +++ b/.gitignore @@ -316,3 +316,7 @@ pyrightconfig.json # Ignore all local history of files .history .ionide + +### Telethon ### +*.session +*.session-journal diff --git a/src/Bot.py b/src/Bot.py new file mode 100644 index 0000000..87fcdb9 --- /dev/null +++ b/src/Bot.py @@ -0,0 +1,18 @@ +from dotenv import load_dotenv +from telethon import TelegramClient, events +from os import getenv + +def main() -> None: + load_dotenv() + + api_id = getenv("API_ID") + api_hash = getenv("API_HASH") + bot_token = getenv("BOT_TOKEN") + + app = TelegramClient('app', api_id, api_hash).start(bot_token=bot_token) + + @app.on(events.NewMessage(incoming=True, pattern='/start')) + async def start(event): + await event.reply("Hello!") + + app.run_until_disconnected() diff --git a/src/__main__.py b/src/__main__.py index e69de29..59b177a 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -0,0 +1,4 @@ +from Bot import main + +if __name__ == "__main__": + main()