evgfilim1 / userbot Goto Github PK
View Code? Open in Web Editor NEWMy Telegram userbot with some specific features I use
License: MIT License
My Telegram userbot with some specific features I use
License: MIT License
This will require wrapping the original message class from Pyrogram into something that will behave almost the same but will support drafts.
Handling requires registering RawUpdateHandler
like this:
Lines 72 to 75 in 2d862d1
userbot/userbot/commands/chat_admin.py
Lines 131 to 140 in 2d862d1
UpdateDraftMessage
will be received when something is saved as a draft:
https://docs.pyrogram.org/telegram/types/update-draft-message#pyrogram.raw.types.UpdateDraftMessage
Implementing this may open new abilities like silent execution without having to edit sources, looped execution, etc.
.rhadd <reply> <key> <text...> — adds a runtime trigger <key> on <text> that sends <reply>
.rhs — list all runtime triggers
.rhdel <key> — removes a runtime trigger
.stats — show some stats for the bot and the user
Example output:
⚙ Uptime: 1h2m3s
⭐️ Doesn't have premium
💬 Total chats: 1000
💬 Unread: 2
📥 Archived chats: 50
👤 Private chats: 400
👥 Groups: 400
📢 Channels: 200
🎞 Saved GIFs: 300
📑 Saved stickers: 200
🕒 Archived stickers: 300
...
Take appropriate icons from https://t.me/addemoji/IconsInTg for premium users
w|weather [city] — Gets the hourly weather for the city
If city is not specified, use the default one from config
Weather API with free per-hour forecast: https://www.tomorrow.io/weather-api/
Geocoding API to get coordinates from city name: https://openweathermap.org/api/geocoding-api
.help command
: userbot/userbot/modules/commands.py
Lines 388 to 403 in 2d862d1
userbot/userbot/modules/commands.py
Lines 423 to 426 in 2d862d1
.clearsvcs [period] — Clear service messages for a period.
period
can be a timedelta (e.g. "1d3h") or a time string (e.g. "12:30" or "2022-12-31_23:59").
If period is not specified, assume "1d"
Lines 109 to 117 in 4bfb02f
.wakastats — Fetch wakatime.com stats for myself
.pydoc <query> — Search Python documentation
.tbapidoc <query> — Search Telegram Bot API documentation
Same behavior as in .remind
and .remindme
Lines 109 to 117 in 4bfb02f
.lang — Set default language for a chat
If not set, en is assumed
Something like this: https://github.com/evgfilim1/spin_everyday_bot/blob/d5cb7917dfa4408832cebf8339a3257d8ea93973/spin_everyday_bot/lang/translation.py#L20-L45
Start here
diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml
index 833fcde..77cf54c 100644
--- a/.github/workflows/lint.yaml
+++ b/.github/workflows/lint.yaml
@@ -45,6 +45,7 @@ jobs:
run: |
isort --check --diff userbot
black --check --diff userbot
+ mypy userbot
- name: Check message catalog template is up-to-date
run: python potctl.py --diff
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 390cec5..41f7d7e 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,3 +1,5 @@
Babel~=2.10.3
black~=22.10.0
isort~=5.10.1
+mypy~=0.982
+types-aiofiles~=22.1.0
diff --git a/pyproject.toml b/pyproject.toml
index bcb9333..e1c88f9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -7,3 +7,52 @@ line_length = 100
py_version = '310' # (2022-10-28) isort 5.10.1 doesn't support 3.11
profile = 'black'
known_first_party = ['userbot']
+
+[tool.mypy]
+# Config file
+warn_unused_configs = true
+
+# Import discovery
+namespace_packages = true
+
+# Platform configuration
+python_version = "3.11"
+
+# Disallow dynamic typing
+#disallow_any_explicit = true
+disallow_any_generics = true
+disallow_subclassing_any = true
+
+# Untyped definitions and calls
+disallow_untyped_calls = true
+disallow_untyped_defs = true
+disallow_incomplete_defs = true
+check_untyped_defs = true
+disallow_untyped_decorators = true
+
+# None and Optional handling
+no_implicit_optional = true
+
+# Configuring warnings
+warn_redundant_casts = true
+warn_unused_ignores = true
+warn_return_any = true
+warn_unreachable = true
+
+# Miscellaneous strictness flags
+local_partial_types = true
+# Pyrogram doesn't explicitly export some attributes, so this has to be disabled
+no_implicit_reexport = false
+strict_equality = true
+strict = true
+
+# Configuring error messages
+show_error_context = true
+show_column_numbers = true
+show_error_codes = true
+pretty = true
+
+# Advanced options
+plugins = [
+]
+warn_incomplete_stub = true
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.