本文整理汇总了Python中telegram.ParseMode.MARKDOWN属性的典型用法代码示例。如果您正苦于以下问题:Python ParseMode.MARKDOWN属性的具体用法?Python ParseMode.MARKDOWN怎么用?Python ParseMode.MARKDOWN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类telegram.ParseMode
的用法示例。
在下文中一共展示了ParseMode.MARKDOWN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_settings
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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)
示例2: disable
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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?")
示例3: list_handlers
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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
示例4: about_me
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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!")
示例5: about_bio
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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!")
示例6: safe_mode
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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)
示例7: gps
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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
示例8: list_notes
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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)
示例9: commands
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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)
示例10: security
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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")
示例11: cleanservice
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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)
示例12: get_frules
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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)
示例13: about_me
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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!"))
示例14: allow_connections
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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"))
示例15: set_verify_welcome
# 需要导入模块: from telegram import ParseMode [as 别名]
# 或者: from telegram.ParseMode import MARKDOWN [as 别名]
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")