Python telegram.ext.Filters.private() Examples
The following are 9
code examples of telegram.ext.Filters.private().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
telegram.ext.Filters
, or try the search function
.
Example #1
Source File: misc.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def get_id(bot: Bot, update: Update, args: List[str]): user_id = extract_user(update.effective_message, args) if user_id: if update.effective_message.reply_to_message and update.effective_message.reply_to_message.forward_from: user1 = update.effective_message.reply_to_message.from_user user2 = update.effective_message.reply_to_message.forward_from update.effective_message.reply_text( "The original sender, {}, has an ID of `{}`.\nThe forwarder, {}, has an ID of `{}`.".format( escape_markdown(user2.first_name), user2.id, escape_markdown(user1.first_name), user1.id), parse_mode=ParseMode.MARKDOWN) else: user = bot.get_chat(user_id) update.effective_message.reply_text("{}'s id is `{}`.".format(escape_markdown(user.first_name), user.id), parse_mode=ParseMode.MARKDOWN) else: chat = update.effective_chat # type: Optional[Chat] if chat.type == "private": update.effective_message.reply_text("Your id is `{}`.".format(chat.id), parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text("This group's id is `{}`.".format(chat.id), parse_mode=ParseMode.MARKDOWN)
Example #2
Source File: misc.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def gps(bot: Bot, update: Update, args: List[str]): message = update.effective_message try: geolocator = Nominatim(user_agent="SkittBot") location = " ".join(args) geoloc = geolocator.geocode(location) chat_id = update.effective_chat.id lon = geoloc.longitude lat = geoloc.latitude the_loc = Location(lon, lat) gm = "https://www.google.com/maps/search/{},{}".format(lat,lon) bot.send_location(chat_id, location=the_loc) message.reply_text("Open with: [Google Maps]({})".format(gm), parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True) except AttributeError: message.reply_text("I can't find that") # /ip is for private use
Example #3
Source File: misc.py From Marie-2.0-English with GNU General Public License v3.0 | 6 votes |
def getsticker(bot: Bot, update: Update): msg = update.effective_message chat_id = update.effective_chat.id if msg.reply_to_message and msg.reply_to_message.sticker: bot.sendChatAction(chat_id, "typing") update.effective_message.reply_text("Hello " + "[{}](tg://user?id={})".format(msg.from_user.first_name, msg.from_user.id) + ", Please check the file you requested below." "\nPlease use this feature wisely!", parse_mode=ParseMode.MARKDOWN) bot.sendChatAction(chat_id, "upload_document") file_id = msg.reply_to_message.sticker.file_id newFile = bot.get_file(file_id) newFile.download('sticker.png') bot.sendDocument(chat_id, document=open('sticker.png', 'rb')) bot.sendChatAction(chat_id, "upload_photo") bot.send_photo(chat_id, photo=open('sticker.png', 'rb')) else: bot.sendChatAction(chat_id, "typing") update.effective_message.reply_text("Hello " + "[{}](tg://user?id={})".format(msg.from_user.first_name, msg.from_user.id) + ", Please reply to sticker message to get sticker image", parse_mode=ParseMode.MARKDOWN) # /ip is for private use
Example #4
Source File: misc.py From EmiliaHikari with GNU General Public License v3.0 | 5 votes |
def stats(update, context): send_message(update.effective_message, tl(update.effective_message, "Statistik saat ini:\n") + "\n".join([mod.__stats__() for mod in STATS])) # /ip is for private use
Example #5
Source File: misc.py From Marie-2.0-English with GNU General Public License v3.0 | 5 votes |
def get_id(bot: Bot, update: Update, args: List[str]): user_id = extract_user(update.effective_message, args) if user_id: if update.effective_message.reply_to_message and update.effective_message.reply_to_message.forward_from: user1 = update.effective_message.reply_to_message.from_user user2 = update.effective_message.reply_to_message.forward_from update.effective_message.reply_text( "The original sender, {}, has an ID of `{}`.\nThe forwarder, {}, has an ID of `{}`.".format( escape_markdown(user2.first_name), user2.id, escape_markdown(user1.first_name), user1.id), parse_mode=ParseMode.MARKDOWN) else: user = bot.get_chat(user_id) update.effective_message.reply_text("{}'s id is `{}`.".format(escape_markdown(user.first_name), user.id), parse_mode=ParseMode.MARKDOWN) else: chat = update.effective_chat # type: Optional[Chat] if chat.type == "private": update.effective_message.reply_text("Your id is `{}`.".format(chat.id), parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text("This group's id is `{}`.".format(chat.id), parse_mode=ParseMode.MARKDOWN)
Example #6
Source File: misc.py From tgbot with GNU General Public License v3.0 | 5 votes |
def get_id(bot: Bot, update: Update, args: List[str]): user_id = extract_user(update.effective_message, args) if user_id: if update.effective_message.reply_to_message and update.effective_message.reply_to_message.forward_from: user1 = update.effective_message.reply_to_message.from_user user2 = update.effective_message.reply_to_message.forward_from update.effective_message.reply_text( "The original sender, {}, has an ID of `{}`.\nThe forwarder, {}, has an ID of `{}`.".format( escape_markdown(user2.first_name), user2.id, escape_markdown(user1.first_name), user1.id), parse_mode=ParseMode.MARKDOWN) else: user = bot.get_chat(user_id) update.effective_message.reply_text("{}'s id is `{}`.".format(escape_markdown(user.first_name), user.id), parse_mode=ParseMode.MARKDOWN) else: chat = update.effective_chat # type: Optional[Chat] if chat.type == "private": update.effective_message.reply_text("Your id is `{}`.".format(chat.id), parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text("This group's id is `{}`.".format(chat.id), parse_mode=ParseMode.MARKDOWN)
Example #7
Source File: misc.py From tgbot with GNU General Public License v3.0 | 5 votes |
def stats(bot: Bot, update: Update): update.effective_message.reply_text("Current stats:\n" + "\n".join([mod.__stats__() for mod in STATS])) # /ip is for private use
Example #8
Source File: private_msg.py From channel-helper-bot with GNU General Public License v3.0 | 4 votes |
def check_channel_message(bot, message): logger = Logger.logger chat_id = message.chat_id if not message.forward_from_chat: helper_global.send_intro_template(bot, chat_id, helper_const.DEFAULT_LANG, "register_invalid", "register_cmd_invalid") return chat_type = message.forward_from_chat.type if not chat_type == "channel": helper_global.send_intro_template(bot, chat_id, helper_const.DEFAULT_LANG, "register_invalid", "register_cmd_invalid") return channel_username = message.forward_from_chat.username channel_id = message.forward_from_chat.id user_id = message.from_user.id logger.msg({ "user_id": chat_id, "channel_id": channel_id, "action": "check channel" }, tag="private", log_level=90) bot_id = int(helper_const.BOT_TOKEN.split(":")[0]) try: chat_members = bot.get_chat_administrators(chat_id=channel_id).result() chat_member_ids = [member.user.id for member in chat_members] if not user_id in chat_member_ids: helper_global.send_intro_template(bot, chat_id, helper_const.DEFAULT_LANG, "register_not_admin", "register_cmd_not_admin") return for member in chat_members: if member.user.id == bot_id: post_permission = member.can_post_messages if member.can_post_messages else False edit_permission = member.can_edit_messages if member.can_edit_messages else False delete_permission = member.can_delete_messages if member.can_delete_messages else False if not post_permission or not edit_permission or not delete_permission: helper_global.send_intro_template(bot, chat_id, helper_const.DEFAULT_LANG, "register_no_permission", "register_cmd_no_permission") return break except: helper_global.send_intro_template(bot, chat_id, helper_const.DEFAULT_LANG, "register_no_info", "register_cmd_no_info") return try: helper_database.add_channel_config(channel_id, helper_const.DEFAULT_LANG, 1, 10, channel_username, chat_id, 1, 1) except: helper_global.assign(str(chat_id) + "_status", "0,0") helper_global.send_intro_template(bot, chat_id, helper_const.DEFAULT_LANG, "register_failed", "register_cmd_failed") return helper_global.assign(str(chat_id) + "_status", "0,0") helper_global.send_intro_template(bot, chat_id, helper_const.DEFAULT_LANG, "register_success", "register_cmd_success")
Example #9
Source File: misc.py From EmiliaHikari with GNU General Public License v3.0 | 4 votes |
def get_id(update, context): args = context.args user_id = extract_user(update.effective_message, args) if user_id and user_id != "error": if update.effective_message.reply_to_message and update.effective_message.reply_to_message.forward_from: user1 = update.effective_message.reply_to_message.from_user user2 = update.effective_message.reply_to_message.forward_from text = tl(update.effective_message, "Pengirim asli, {}, memiliki ID `{}`.\nSi penerus pesan, {}, memiliki ID `{}`.").format( escape_markdown(user2.first_name), user2.id, escape_markdown(user1.first_name), user1.id) if update.effective_message.chat.type != "private": text += "\n" + tl(update.effective_message, "Id grup ini adalah `{}`.").format(update.effective_message.chat.id) send_message(update.effective_message, text, parse_mode=ParseMode.MARKDOWN) else: user = context.bot.get_chat(user_id) text = tl(update.effective_message, "Id {} adalah `{}`.").format(escape_markdown(user.first_name), user.id) if update.effective_message.chat.type != "private": text += "\n" + tl(update.effective_message, "Id grup ini adalah `{}`.").format(update.effective_message.chat.id) send_message(update.effective_message, text, parse_mode=ParseMode.MARKDOWN) elif user_id == "error": try: user = context.bot.get_chat(args[0]) except BadRequest: send_message(update.effective_message, "Error: Unknown User/Chat!") return text = tl(update.effective_message, "Id Anda adalah `{}`.").format(update.effective_message.from_user.id) text += "\n" + tl(update.effective_message, "Id grup tersebut adalah `{}`.").format(user.id) if update.effective_message.chat.type != "private": text += "\n" + tl(update.effective_message, "Id grup ini adalah `{}`.").format(update.effective_message.chat.id) send_message(update.effective_message, text, parse_mode=ParseMode.MARKDOWN) else: chat = update.effective_chat # type: Optional[Chat] if chat.type == "private": send_message(update.effective_message, tl(update.effective_message, "Id Anda adalah `{}`.").format(update.effective_message.from_user.id), parse_mode=ParseMode.MARKDOWN) else: send_message(update.effective_message, tl(update.effective_message, "Id Anda adalah `{}`.").format(update.effective_message.from_user.id) + "\n" + tl(update.effective_message, "Id grup ini adalah `{}`.").format(chat.id), parse_mode=ParseMode.MARKDOWN)