Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Telethon from Pyrogram, create a basic bot based on Telethon and fix poetry.lock #7

Merged
merged 4 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading