Created
June 2, 2021 02:20
-
-
Save david-lev/eadce3a5025cfbefcf84ff387b41d70b to your computer and use it in GitHub Desktop.
a simple telegram bot to get id for channels, groups and users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyrogram import Client, filters, types | |
token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
app = Client("get_id_bot", 777074324, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX", bot_token=token) | |
@app.on_message(filters.group) | |
def group(_, msg:types.Message): | |
msg.reply(f"מזהה הקבוצה: `{msg.chat.id}`") | |
msg.chat.leave() | |
@app.on_message(filters.private & filters.forwarded) | |
def forwarded(_, msg:types.Message): | |
if msg.forward_from_chat and msg.forward_from_chat.type == "channel": | |
msg.reply(f"מזהה הערוץ: `{msg.forward_from_chat.id}`") | |
@app.on_message(filters.private & ~filters.forwarded) | |
def private(_, msg:types.Message): | |
msg.reply(f"המזהה שלך הוא: `{msg.from_user.id}`") | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment