Python telegram.ParseMode.MARKDOWN Examples
The following are 30
code examples of telegram.ParseMode.MARKDOWN().
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.ParseMode
, or try the search function
.
Example #1
Source File: stickers.py From SkittBot with GNU General Public License v3.0 | 7 votes |
def makepack_internal(msg, user, png_sticker, emoji, bot, packname, packnum): name = user.first_name name = name[:50] try: extra_version = "" if packnum > 0: extra_version = " " + str(packnum) success = bot.create_new_sticker_set(user.id, packname, f"{name}s kang pack" + extra_version, png_sticker=png_sticker, emojis=emoji) except TelegramError as e: print(e) if e.message == "Sticker set name is already occupied": msg.reply_text("Your pack can be found [here](t.me/addstickers/%s)" % packname, parse_mode=ParseMode.MARKDOWN) elif e.message == "Peer_id_invalid": msg.reply_text("Contact me in PM first.", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton( text="Start", url=f"t.me/{bot.username}")]])) elif e.message == "Internal Server Error: created sticker set not found (500)": msg.reply_text("Sticker pack successfully created. Get it [here](t.me/addstickers/%s)" % packname, parse_mode=ParseMode.MARKDOWN) return if success: msg.reply_text("Sticker pack successfully created. Get it [here](t.me/addstickers/%s)" % packname, parse_mode=ParseMode.MARKDOWN) else: msg.reply_text("Failed to create sticker pack. Possibly due to blek mejik.")
Example #2
Source File: misc.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def safe_mode(bot: Bot, update: Update, args: List[str]): chat = update.effective_chat message = update.effective_message if not args: message.reply_text("This chat has its Safe Mode set to *{}*".format(is_safemoded(chat.id).safemode_status), parse_mode=ParseMode.MARKDOWN) return if str(args[0]).lower() in ["on", "yes"]: set_safemode(chat.id, True) message.reply_text("Safe Mode has been set to *{}*".format(is_safemoded(chat.id).safemode_status), parse_mode=ParseMode.MARKDOWN) return elif str(args[0]).lower() in ["off", "no"]: set_safemode(chat.id, False) message.reply_text("Safe Mode has been set to *{}*".format(is_safemoded(chat.id).safemode_status), parse_mode=ParseMode.MARKDOWN) return else: message.reply_text("I only recognize the arguments `{}`, `{}`, `{}` or `{}`".format("Yes", "No", "On", "Off"), parse_mode=ParseMode.MARKDOWN)
Example #3
Source File: userinfo.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def about_bio(bot: Bot, update: Update, args: List[str]): message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if user_id: user = bot.get_chat(user_id) else: user = message.from_user info = sql.get_user_bio(user.id) if info: update.effective_message.reply_text("*{}*:\n{}".format(user.first_name, escape_markdown(info)), parse_mode=ParseMode.MARKDOWN) elif message.reply_to_message: username = user.first_name update.effective_message.reply_text("{} hasn't had a message set about themselves yet!".format(username)) else: update.effective_message.reply_text("You haven't had a bio set about yourself yet!")
Example #4
Source File: userinfo.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def about_me(bot: Bot, update: Update, args: List[str]): message = update.effective_message # type: Optional[Message] user_id = extract_user(message, args) if user_id: user = bot.get_chat(user_id) else: user = message.from_user info = sql.get_user_me_info(user.id) if info: update.effective_message.reply_text("*{}*:\n{}".format(user.first_name, escape_markdown(info)), parse_mode=ParseMode.MARKDOWN) elif message.reply_to_message: username = message.reply_to_message.from_user.first_name update.effective_message.reply_text(username + " hasn't set an info message about themselves yet!") else: update.effective_message.reply_text("You haven't set an info message about yourself yet!")
Example #5
Source File: disable.py From EmiliaHikari with GNU General Public License v3.0 | 6 votes |
def commands(update, context): chat = update.effective_chat user = update.effective_user conn = connected(context.bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: if update.effective_message.chat.type == "private": send_message(update.effective_message, languages.tl(update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM")) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title text = build_curr_disabled(chat.id) send_message(update.effective_message, text, parse_mode=ParseMode.MARKDOWN)
Example #6
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 #7
Source File: notes.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def list_notes(bot: Bot, update: Update): chat_id = update.effective_chat.id note_list = sql.get_all_chat_notes(chat_id) msg = "*Notes in chat:*\n" for note in note_list: note_name = escape_markdown(" - {}\n".format(note.name)) if len(msg) + len(note_name) > MAX_MESSAGE_LENGTH: update.effective_message.reply_text(msg, parse_mode=ParseMode.MARKDOWN) msg = "" msg += note_name if msg == "*Notes in chat:*\n": update.effective_message.reply_text("No notes in this chat!") elif len(msg) != 0: update.effective_message.reply_text(msg, parse_mode=ParseMode.MARKDOWN)
Example #8
Source File: welcome.py From EmiliaHikari with GNU General Public License v3.0 | 6 votes |
def security(update, context): args = context.args chat = update.effective_chat # type: Optional[Chat] getcur, extra_verify, cur_value, timeout, timeout_mode, cust_text = sql.welcome_security(chat.id) if len(args) >= 1: var = args[0].lower() if (var == "yes" or var == "ya" or var == "on"): check = context.bot.getChatMember(chat.id, context.bot.id) if check.status == 'member' or check['can_restrict_members'] == False: text = tl(update.effective_message, "Saya tidak bisa membatasi orang di sini! Pastikan saya admin agar bisa membisukan seseorang!") send_message(update.effective_message, text, parse_mode="markdown") return "" sql.set_welcome_security(chat.id, True, extra_verify, str(cur_value), str(timeout), int(timeout_mode), cust_text) send_message(update.effective_message, tl(update.effective_message, "Keamanan untuk member baru di aktifkan!")) elif (var == "no" or var == "ga" or var == "off"): sql.set_welcome_security(chat.id, False, extra_verify, str(cur_value), str(timeout), int(timeout_mode), cust_text) send_message(update.effective_message, tl(update.effective_message, "Di nonaktifkan, saya tidak akan membisukan member masuk lagi")) else: send_message(update.effective_message, tl(update.effective_message, "Silakan tulis `on`/`ya`/`off`/`ga`!"), parse_mode=ParseMode.MARKDOWN) else: getcur, extra_verify, cur_value, timeout, timeout_mode, cust_text = sql.welcome_security(chat.id) if cur_value[:1] == "0": cur_value = tl(update.effective_message, "Selamanya") text = tl(update.effective_message, "Pengaturan saat ini adalah:\nWelcome security: `{}`\nVerify security: `{}`\nMember akan di mute selama: `{}`\nWaktu verifikasi timeout: `{}` ({})\nTombol unmute custom: `{}`").format(getcur, extra_verify, cur_value, make_time(int(timeout)), "kick" if 1 else "banned", cust_text) send_message(update.effective_message, text, parse_mode="markdown")
Example #9
Source File: welcome.py From EmiliaHikari with GNU General Public License v3.0 | 6 votes |
def cleanservice(update, context): args = context.args chat = update.effective_chat # type: Optional[Chat] if chat.type != chat.PRIVATE: if len(args) >= 1: var = args[0].lower() if (var == "no" or var == "off" or var == "tidak"): sql.set_clean_service(chat.id, False) send_message(update.effective_message, tl(update.effective_message, "Saya meninggalkan pesan layanan")) elif(var == "yes" or var == "ya" or var == "on"): sql.set_clean_service(chat.id, True) send_message(update.effective_message, tl(update.effective_message, "Saya akan membersihkan pesan layanan")) else: send_message(update.effective_message, tl(update.effective_message, "Silakan masukkan yes/ya atau no/tidak!"), parse_mode=ParseMode.MARKDOWN) else: send_message(update.effective_message, tl(update.effective_message, "Silakan masukkan yes/ya atau no/tidak!"), parse_mode=ParseMode.MARKDOWN) else: curr = sql.clean_service(chat.id) if curr: send_message(update.effective_message, tl(update.effective_message, "Saat ini saya akan membersihkan `x joined the group` ketika ada member baru."), parse_mode=ParseMode.MARKDOWN) else: send_message(update.effective_message, tl(update.effective_message, "Saat ini saya tidak akan membersihkan `x joined the group` ketika ada member baru."), parse_mode=ParseMode.MARKDOWN)
Example #10
Source File: cust_filters.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def list_handlers(bot: Bot, update: Update): chat = update.effective_chat # type: Optional[Chat] all_handlers = sql.get_chat_triggers(chat.id) if not all_handlers: update.effective_message.reply_text("No filters are active here!") return filter_list = BASIC_FILTER_STRING for keyword in all_handlers: entry = " - {}\n".format(escape_markdown(keyword)) if len(entry) + len(filter_list) > telegram.MAX_MESSAGE_LENGTH: update.effective_message.reply_text(filter_list, parse_mode=telegram.ParseMode.MARKDOWN) filter_list = entry else: filter_list += entry if not filter_list == BASIC_FILTER_STRING: update.effective_message.reply_text(filter_list, parse_mode=telegram.ParseMode.MARKDOWN) # NOT ASYNC BECAUSE DISPATCHER HANDLER RAISED
Example #11
Source File: feds.py From EmiliaHikari with GNU General Public License v3.0 | 6 votes |
def get_frules(update, context): chat = update.effective_chat # type: Optional[Chat] args = context.args if chat.type == 'private': send_message(update.effective_message, tl(update.effective_message, "Perintah ini di khususkan untuk grup, bukan pada PM!")) return fed_id = sql.get_fed_id(chat.id) if not fed_id: send_message(update.effective_message, tl(update.effective_message, "Grup ini tidak dalam federasi apa pun!")) return rules = sql.get_frules(fed_id) text = tl(update.effective_message, "*Peraturan di fed ini:*\n") text += rules send_message(update.effective_message, text, parse_mode=ParseMode.MARKDOWN)
Example #12
Source File: disable.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def disable(bot: Bot, update: Update, args: List[str]): chat = update.effective_chat # type: Optional[Chat] if len(args) >= 1: disable_cmd = args[0] if disable_cmd.startswith(CMD_STARTERS): disable_cmd = disable_cmd[1:] if disable_cmd in set(DISABLE_CMDS + DISABLE_OTHER): sql.disable_command(chat.id, disable_cmd) update.effective_message.reply_text("Disabled the use of `{}`".format(disable_cmd), parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text("That command can't be disabled") else: update.effective_message.reply_text("What should I disable?")
Example #13
Source File: userinfo.py From EmiliaHikari with GNU General Public License v3.0 | 6 votes |
def about_me(update, context): message = update.effective_message # type: Optional[Message] args = context.args user_id = extract_user(message, args) if user_id and user_id != "error": user = bot.get_chat(user_id) else: user = message.from_user info = sql.get_user_me_info(user.id) if info: send_message(update.effective_message, "*{}*:\n{}".format(user.first_name, escape_markdown(info)), parse_mode=ParseMode.MARKDOWN) elif message.reply_to_message: username = message.reply_to_message.from_user.first_name send_message(update.effective_message, username + tl(update.effective_message, " belum mengatur pesan info tentang diri mereka!")) else: send_message(update.effective_message, tl(update.effective_message, "Anda belum mengatur pesan info tentang diri Anda!"))
Example #14
Source File: __main__.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def send_settings(chat_id, user_id, user=False): if user: if USER_SETTINGS: settings = "\n\n".join( "*{}*:\n{}".format(mod.__mod_name__, mod.__user_settings__(user_id)) for mod in USER_SETTINGS.values()) dispatcher.bot.send_message(user_id, "These are your current settings:" + "\n\n" + settings, parse_mode=ParseMode.MARKDOWN) else: dispatcher.bot.send_message(user_id, "Seems like there aren't any user specific settings available :'(", parse_mode=ParseMode.MARKDOWN) else: if CHAT_SETTINGS: chat_name = dispatcher.bot.getChat(chat_id).title dispatcher.bot.send_message(user_id, text="Which module would you like to check {}'s settings for?".format( chat_name), reply_markup=InlineKeyboardMarkup( paginate_modules(0, CHAT_SETTINGS, "stngs", chat=chat_id))) else: dispatcher.bot.send_message(user_id, "Seems like there aren't any chat settings available :'(\nSend this " "in a group chat you're admin in to find its current settings!", parse_mode=ParseMode.MARKDOWN)
Example #15
Source File: connection.py From EmiliaHikari with GNU General Public License v3.0 | 6 votes |
def allow_connections(update, context) -> str: chat = update.effective_chat # type: Optional[Chat] args = context.args if chat.type != chat.PRIVATE: if len(args) >= 1: var = args[0] if (var == "no" or var == "tidak"): sql.set_allow_connect_to_chat(chat.id, False) send_message(update.effective_message, languages.tl(update.effective_message, "Sambungan telah dinonaktifkan untuk obrolan ini")) elif(var == "yes" or var == "ya"): sql.set_allow_connect_to_chat(chat.id, True) send_message(update.effective_message, languages.tl(update.effective_message, "Koneksi di aktifkan untuk obrolan ini")) else: send_message(update.effective_message, languages.tl(update.effective_message, "Silakan masukkan `ya`/`yes` atau `tidak`/`no`!"), parse_mode=ParseMode.MARKDOWN) else: get_settings = sql.allow_connect_to_chat(chat.id) if get_settings: send_message(update.effective_message, languages.tl(update.effective_message, "Koneksi pada grup ini di *Di Izinkan* untuk member!"), parse_mode=ParseMode.MARKDOWN) else: send_message(update.effective_message, languages.tl(update.effective_message, "Koneksi pada grup ini di *Tidak Izinkan* untuk member!"), parse_mode=ParseMode.MARKDOWN) else: send_message(update.effective_message, languages.tl(update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM"))
Example #16
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 #17
Source File: welcome_timeout.py From EmiliaHikari with GNU General Public License v3.0 | 6 votes |
def set_verify_welcome(update, context): args = context.args chat = update.effective_chat # type: Optional[Chat] getcur, extra_verify, cur_value, timeout, timeout_mode, cust_text = sql.welcome_security(chat.id) if len(args) >= 1: var = args[0].lower() if (var == "yes" or var == "ya" or var == "on"): check = context.bot.getChatMember(chat.id, context.bot.id) if check.status == 'member' or check['can_restrict_members'] == False: text = tl(update.effective_message, "Saya tidak bisa membatasi orang di sini! Pastikan saya admin agar bisa membisukan seseorang!") send_message(update.effective_message, text, parse_mode="markdown") return "" sql.set_welcome_security(chat.id, getcur, True, str(cur_value), str(timeout), int(timeout_mode), cust_text) send_message(update.effective_message, tl(update.effective_message, "Keamanan untuk member baru di aktifkan! Pengguna baru di wajibkan harus menyelesaikan verifikasi untuk chat")) elif (var == "no" or var == "ga" or var == "off"): sql.set_welcome_security(chat.id, getcur, False, str(cur_value), str(timeout), int(timeout_mode), cust_text) send_message(update.effective_message, tl(update.effective_message, "Di nonaktifkan, pengguna dapat mengklik tombol untuk langsung chat")) else: send_message(update.effective_message, tl(update.effective_message, "Silakan tulis `on`/`ya`/`off`/`ga`!"), parse_mode=ParseMode.MARKDOWN) else: getcur, extra_verify, cur_value, timeout, timeout_mode, cust_text = sql.welcome_security(chat.id) if cur_value[:1] == "0": cur_value = tl(update.effective_message, "Selamanya") text = tl(update.effective_message, "Pengaturan saat ini adalah:\nWelcome security: `{}`\nVerify security: `{}`\nMember akan di mute selama: `{}`\nWaktu verifikasi timeout: `{}`\nTombol unmute custom: `{}`").format(getcur, extra_verify, cur_value, make_time(int(timeout)), cust_text) send_message(update.effective_message, text, parse_mode="markdown")
Example #18
Source File: devs.py From EmiliaHikari with GNU General Public License v3.0 | 5 votes |
def reboot(update, context): msg = update.effective_message chat_id = update.effective_chat.id send_message(update.effective_message, "Rebooting...", parse_mode=ParseMode.MARKDOWN) try: os.system("cd /home/ayra/emilia/ && python3.6 -m emilia &") os.system('kill %d' % os.getpid()) send_message(update.effective_message, "Reboot Berhasil!", parse_mode=ParseMode.MARKDOWN) except: send_message(update.effective_message, "Reboot Gagal!", parse_mode=ParseMode.MARKDOWN)
Example #19
Source File: __main__.py From EmiliaHikari with GNU General Public License v3.0 | 5 votes |
def send_help(chat_id, text, keyboard=None): if not keyboard: keyboard = InlineKeyboardMarkup(paginate_modules(0, HELPABLE, "help")) dispatcher.bot.send_message(chat_id=chat_id, text=text, parse_mode=ParseMode.MARKDOWN, reply_markup=keyboard)
Example #20
Source File: feds.py From EmiliaHikari with GNU General Public License v3.0 | 5 votes |
def new_fed(update, context): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message if chat.type != "private": send_message(update.effective_message, tl(update.effective_message, "Buat federasi Anda di PM saya, bukan dalam grup.")) return if len(message.text) == 1: send_message(update.effective_message, tl(update.effective_message, "Tolong tulis nama federasinya!")) return fednam = message.text.split(None, 1)[1] if not fednam == '': fed_id = str(uuid.uuid4()) fed_name = fednam LOGGER.info(fed_id) # Currently only for creator if fednam == "Team Nusantara Disciplinary Circle": fed_id = "TeamNusantaraDevs" elif fednam == "Emilia Official Support": fed_id = "EmiliaSupport" x = sql.new_fed(user.id, fed_name, fed_id) if not x: send_message(update.effective_message, tl(update.effective_message, "Tidak dapat membuat federasi! Tolong hubungi pembuat saya jika masalah masih berlanjut.")) return send_message(update.effective_message, tl(update.effective_message, "*Anda telah berhasil membuat federasi baru!*"\ "\nNama: `{}`"\ "\nID: `{}`" "\n\nGunakan perintah di bawah ini untuk bergabung dengan federasi:" "\n`/joinfed {}`").format(fed_name, fed_id, fed_id), parse_mode=ParseMode.MARKDOWN) try: context.bot.send_message(TEMPORARY_DATA, "Federasi <b>{}</b> telah di buat dengan ID: <pre>{}</pre>".format(fed_name, fed_id), parse_mode=ParseMode.HTML) except: LOGGER.warning("Cannot send a message to TEMPORARY_DATA") else: send_message(update.effective_message, tl(update.effective_message, "Tolong tulis nama federasinya!"))
Example #21
Source File: connection.py From EmiliaHikari with GNU General Public License v3.0 | 5 votes |
def connect_button(update, context) -> str: query = update.callback_query chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] connect_match = re.match(r"connect\((.+?)\)", query.data) disconnect_match = query.data == "connect_disconnect" clear_match = query.data == "connect_clear" connect_close = query.data == "connect_close" if connect_match: target_chat = connect_match.group(1) getstatusadmin = context.bot.get_chat_member(target_chat, query.from_user.id) isadmin = getstatusadmin.status in ('administrator', 'creator') ismember = getstatusadmin.status in ('member') isallow = sql.allow_connect_to_chat(target_chat) if (isadmin) or (isallow and ismember) or (user.id in SUDO_USERS): connection_status = sql.connect(query.from_user.id, target_chat) if connection_status: conn_chat = dispatcher.bot.getChat(connected(context.bot, update, chat, user.id, need_admin=False)) chat_name = conn_chat.title query.message.edit_text(languages.tl(update.effective_message, "Berhasil tersambung ke *{}*. Gunakan /connection untuk informasi perintah apa saja yang tersedia.").format(chat_name), parse_mode=ParseMode.MARKDOWN) sql.add_history_conn(user.id, str(conn_chat.id), chat_name) else: query.message.edit_text(languages.tl(update.effective_message, "Koneksi gagal!")) else: context.bot.answer_callback_query(query.id, languages.tl(update.effective_message, "Sambungan ke obrolan ini tidak diizinkan!"), show_alert=True) elif disconnect_match: disconnection_status = sql.disconnect(query.from_user.id) if disconnection_status: sql.disconnected_chat = query.message.edit_text(languages.tl(update.effective_message, "Terputus dari obrolan!")) else: context.bot.answer_callback_query(query.id, languages.tl(update.effective_message, "Anda tidak terkoneksi!"), show_alert=True) elif clear_match: sql.clear_history_conn(query.from_user.id) query.message.edit_text(languages.tl(update.effective_message, "Riwayat yang terhubung telah dihapus!")) elif connect_close: query.message.edit_text(languages.tl(update.effective_message, "Closed.\nTo open again, type /connect")) else: connect_chat(update, context)
Example #22
Source File: markdownformatter.py From BotListBot with MIT License | 5 votes |
def _set_defaults(kwargs): if 'disable_web_page_preview' not in kwargs: kwargs['disable_web_page_preview'] = True if 'parse_mode' not in kwargs: kwargs['parse_mode'] = ParseMode.MARKDOWN return kwargs
Example #23
Source File: tasks.py From OmNomNom with GNU Affero General Public License v3.0 | 5 votes |
def send_message_to_admin(message): bot.send_message(chat_id=ADMIN, text=message, parse_mode=ParseMode.MARKDOWN) logger.info('Send to Admin: %s' % message)
Example #24
Source File: frontend.py From OmNomNom with GNU Affero General Public License v3.0 | 5 votes |
def help_message(_, update): """Send a help message with usage instructions.""" message_logger.info('Send <help> message') update.message.reply_text(text=help_text, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True)
Example #25
Source File: frontend.py From OmNomNom with GNU Affero General Public License v3.0 | 5 votes |
def about(_, update): """Send the 'About' text about the bot.""" message_logger.info('Out: Sending <about> message') update.message.reply_text(text=about_text, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True)
Example #26
Source File: inlinequeries.py From BotListBot with MIT License | 5 votes |
def all_bot_results_article(lst, too_many_results): txt = messages.PROMOTION_MESSAGE + '\n\n' txt += "{} one of these {} bots:\n\n".format(messages.rand_call_to_action(), len(lst)) txt += '\n'.join([str(b) for b in lst]) return InlineQueryResultArticle( id=uuid4(), title='{} {} ʙᴏᴛ ʀᴇsᴜʟᴛs'.format( mdformat.smallcaps("Send"), len(lst)), input_message_content=InputTextMessageContent(message_text=txt[:4096], parse_mode=ParseMode.MARKDOWN) # description=b.description if b.description else b.name if b.name else None, # thumb_url='http://www.colorcombos.com/images/colors/FF0000.png' )
Example #27
Source File: inlinequeries.py From BotListBot with MIT License | 5 votes |
def category_article(cat): cat_bots = Bot.of_category_without_new(cat) txt = messages.PROMOTION_MESSAGE + '\n\n' txt += "There are *{}* bots in the category *{}*:\n\n".format(len(cat_bots), str(cat)) txt += '\n'.join([str(b) for b in cat_bots]) return InlineQueryResultArticle( id=uuid4(), title=emoji.emojize(cat.emojis, use_aliases=True) + cat.name, input_message_content=InputTextMessageContent(message_text=txt, parse_mode=ParseMode.MARKDOWN), description=cat.extra, # thumb_url='https://pichoster.net/images/2017/03/13/cfa5e29e29e772373242bc177a9e5479.jpg' )
Example #28
Source File: help.py From BotListBot with MIT License | 5 votes |
def available_commands(bot, update): update.message.reply_text('*Available commands:*\n' + helpers.get_commands(), parse_mode=ParseMode.MARKDOWN)
Example #29
Source File: misc.py From BotListBot with MIT License | 5 votes |
def t3chnostats(bot, update): days = 30 txt = 'Bots approved by other people *in the last {} days*:\n\n'.format(days) bots = Bot.select().where( (Bot.approved_by != User.get(User.chat_id == 918962)) & (Bot.date_added.between( datetime.date.today() - datetime.timedelta(days=days), datetime.date.today() )) ) txt += '\n'.join(['{} by @{}'.format(str(b), b.approved_by.username) for b in bots]) update.message.reply_text(txt, parse_mode=ParseMode.MARKDOWN)
Example #30
Source File: taghints.py From rules-bot with GNU Affero General Public License v3.0 | 5 votes |
def hint_handler(update: Update, context: CallbackContext): reply_to = update.message.reply_to_message hint = get_hints(update.message.text).popitem()[1] if hint is not None: update.effective_message.reply_text(hint.msg, reply_markup=hint.reply_markup, reply_to_message_id=reply_to.message_id if reply_to else None, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True) try: update.effective_message.delete() except BadRequest: pass