Skip to content

Commit

Permalink
Merge pull request #7 from YeetCode-devs/staging/pranayadmn
Browse files Browse the repository at this point in the history
Migrate to Telethon from Pyrogram, create a basic bot based on Telethon and fix poetry.lock
  • Loading branch information
prathamdby authored Mar 18, 2024
2 parents 10b2abb + 07200d8 commit 595803c
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
API_ID=12345
API_HASH=0123456789abcdef0123456789abcdef
BOT_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,7 @@ pyrightconfig.json
# Ignore all local history of files
.history
.ionide

### Telethon ###
*.session
*.session-journal
85 changes: 68 additions & 17 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
g4f = {extras = ["all"], version = "^0.2.5.4"}
pyrogram = {extras = ["all"], version = "^2.0.106"}
telethon = "^1.34.0"

[tool.poetry.group.dev.dependencies]
black = "^24.3.0"
Expand Down
18 changes: 18 additions & 0 deletions src/Bot.py
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 4 additions & 0 deletions src/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from Bot import main

if __name__ == "__main__":
main()

0 comments on commit 595803c

Please sign in to comment.