当前位置: 首页>>代码示例>>Python>>正文


Python Filters.user方法代码示例

本文整理汇总了Python中telegram.ext.Filters.user方法的典型用法代码示例。如果您正苦于以下问题:Python Filters.user方法的具体用法?Python Filters.user怎么用?Python Filters.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在telegram.ext.Filters的用法示例。


在下文中一共展示了Filters.user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fed_chat

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def fed_chat(update, context):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	fed_id = sql.get_fed_id(chat.id)

	user_id = update.effective_message.from_user.id
	if not is_user_admin(update.effective_chat, user_id):
		send_message(update.effective_message, tl(update.effective_message, "Anda harus menjadi admin untuk menjalankan perintah ini"))
		return

	if not fed_id:
		send_message(update.effective_message, tl(update.effective_message, "Grup ini tidak dalam federasi apa pun!"))
		return

	user = update.effective_user  # type: Optional[Chat]
	chat = update.effective_chat  # type: Optional[Chat]
	info = sql.get_fed_info(fed_id)

	text = tl(update.effective_message, "Obrolan ini adalah bagian dari federasi berikut:")
	text += "\n{} (ID: <code>{}</code>)".format(info['fname'], fed_id)

	send_message(update.effective_message, text, parse_mode=ParseMode.HTML) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:24,代码来源:feds.py

示例2: leave_fed

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def leave_fed(update, context):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	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)
	fed_info = sql.get_fed_info(fed_id)

	# administrators = chat.get_administrators().status
	getuser = context.bot.get_chat_member(chat.id, user.id).status
	if getuser in 'creator' or user.id in SUDO_USERS:
		if sql.chat_leave_fed(chat.id) == True:
			get_fedlog = sql.get_fed_log(fed_id)
			if get_fedlog:
				if eval(get_fedlog):
					context.bot.send_message(get_fedlog, tl(update.effective_message, "Obrolan *{}* telah keluar ke federasi *{}*").format(chat.title, fed_info['fname']), parse_mode="markdown")
			send_message(update.effective_message, tl(update.effective_message, "Obrolan ini telah keluar dari federasi {}!").format(fed_info['fname']))
		else:
			send_message(update.effective_message, tl(update.effective_message, "Mengapa Anda meninggalkan federasi ketika Anda belum bergabung?!"))
	else:
		send_message(update.effective_message, tl(update.effective_message, "Hanya pembuat grup yang dapat melakukannya!")) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:27,代码来源:feds.py

示例3: fed_notif

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def fed_notif(update, context):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	msg = update.effective_message  # type: Optional[Message]
	args = context.args
	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

	if args:
		if args[0] in ("yes", "on", "ya"):
			sql.set_feds_setting(user.id, True)
			send_message(update.effective_message, tl(update.effective_message, "Pelaporan federasi hidup! Setiap ada pengguna yang di fban/unfban anda akan di beritahu via PM."))
		elif args[0] in ("no", "off", "ga"):
			sql.set_feds_setting(user.id, False)
			send_message(update.effective_message, tl(update.effective_message, "Pelaporan federasi mati! Setiap ada pengguna yang di fban/unfban anda tidak akan di beritahu via PM."))
		else:
			send_message(update.effective_message, tl(update.effective_message, "Tolong masukan `ya`/`on`/`ga`/`off`"), parse_mode="markdown")
	else:
		getreport = sql.user_feds_report(user.id)
		send_message(update.effective_message, tl(update.effective_message, "Preferensi laporan federasi anda saat ini: `{}`").format(getreport), parse_mode="markdown") 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:25,代码来源:feds.py

示例4: set_fed_log

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def set_fed_log(update, context):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	msg = update.effective_message  # type: Optional[Message]
	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

	if args:
		fedinfo = sql.get_fed_info(args[0])
		if not fedinfo:
			send_message(update.effective_message, tl(update.effective_message, "Federasi ini tidak ada!"))
			return
		isowner = is_user_fed_owner(args[0], user.id)
		if not isowner:
			send_message(update.effective_message, tl(update.effective_message, "Hanya pencipta federasi yang bisa menetapkan log federasi."))
			return
		setlog = sql.set_fed_log(args[0], chat.id)
		if setlog:
			send_message(update.effective_message, tl(update.effective_message, "Log federasi `{}` telah di setel pada {}").format(fedinfo['fname'], chat.title), parse_mode="markdown")
	else:
		send_message(update.effective_message, tl(update.effective_message, "Anda belum memberikan ID federasinya!")) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:26,代码来源:feds.py

示例5: unset_fed_log

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def unset_fed_log(update, context):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	msg = update.effective_message  # type: Optional[Message]
	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

	if args:
		fedinfo = sql.get_fed_info(args[0])
		if not fedinfo:
			send_message(update.effective_message, tl(update.effective_message, "Federasi ini tidak ada!"))
			return
		isowner = is_user_fed_owner(args[0], user.id)
		if not isowner:
			send_message(update.effective_message, tl(update.effective_message, "Hanya pencipta federasi yang bisa menetapkan log federasi."))
			return
		setlog = sql.set_fed_log(args[0], None)
		if setlog:
			send_message(update.effective_message, tl(update.effective_message, "Log federasi `{}` telah di cabut pada {}").format(fedinfo['fname'], chat.title), parse_mode="markdown")
	else:
		send_message(update.effective_message, tl(update.effective_message, "Anda belum memberikan ID federasinya!")) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:26,代码来源:feds.py

示例6: getsticker

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def getsticker(update, context):
	msg = update.effective_message
	chat_id = update.effective_chat.id
	if msg.reply_to_message and msg.reply_to_message.sticker:
		send_message(update.effective_message, "Hai " + "[{}](tg://user?id={})".format(msg.from_user.first_name,
											msg.from_user.id) + ", Silahkan cek file yang anda minta dibawah ini."
											"\nTolong gunakan fitur ini dengan bijak!",
											parse_mode=ParseMode.MARKDOWN)
		context.bot.sendChatAction(chat_id, "upload_document")
		file_id = msg.reply_to_message.sticker.file_id
		newFile = context.bot.get_file(file_id)
		newFile.download('sticker.png')
		context.bot.sendDocument(chat_id, document=open('sticker.png', 'rb'))
		context.bot.sendChatAction(chat_id, "upload_photo")
		context.bot.send_photo(chat_id, photo=open('sticker.png', 'rb'))
		
	else:
		send_message(update.effective_message, "Hai " + "[{}](tg://user?id={})".format(msg.from_user.first_name,
											msg.from_user.id) + ", Tolong balas pesan stiker untuk mendapatkan gambar stiker",
											parse_mode=ParseMode.MARKDOWN) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:22,代码来源:special.py

示例7: permanent_pin

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def permanent_pin(update, context):
	user = update.effective_user  # type: Optional[User]
	chat = update.effective_chat  # type: Optional[Chat]
	message = update.effective_message
	args = context.args

	get_permapin = sql.get_permapin(chat.id)
	if get_permapin and not user.id == context.bot.id:
		try:
			to_del = context.bot.pinChatMessage(chat.id, get_permapin, disable_notification=True)
		except BadRequest:
			sql.set_permapin(chat.id, 0)
			if chat.username:
				old_pin = "https://t.me/{}/{}".format(chat.username, get_permapin)
			else:
				old_pin = "https://t.me/c/{}/{}".format(str(chat.id)[4:], get_permapin)
			send_message(update.effective_message, tl(update.effective_message, "*Permanen pin error:*\nSaya tidak bisa menyematkan pesan di sini!\nPastikan saya admin dan dapat pin pesan.\n\nPermanen pin di nonaktifkan, [pesan permanen pin lama ada disini]({})").format(old_pin), parse_mode="markdown")
			return

		if to_del:
			try:
				context.bot.deleteMessage(chat.id, message.message_id+1)
			except BadRequest:
				print("Permanent pin error: cannot delete pin msg") 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:26,代码来源:admin.py

示例8: get_user_id

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def get_user_id(username):
    # ensure valid userid
    if len(username) <= 5:
        return None

    if username.startswith('@'):
        username = username[1:]

    users = sql.get_userid_by_name(username)

    if not users:
        return None

    elif len(users) == 1:
        return users[0].user_id

    else:
        for user_obj in users:
            try:
                userdat = dispatcher.bot.get_chat(user_obj.user_id)
                if userdat.username == username:
                    return userdat.id

            except BadRequest as excp:
                if excp.message == 'Chat not found':
                    pass
                else:
                    LOGGER.exception("Error extracting user ID")

    return None 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:32,代码来源:users.py

示例9: slap

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def slap(bot: Bot, update: Update, args: List[str]):
    msg = update.effective_message  # type: Optional[Message]

    # reply to correct message
    reply_text = msg.reply_to_message.reply_text if msg.reply_to_message else msg.reply_text

    # get user who sent message
    if msg.from_user.username:
        curr_user = "@" + escape_markdown(msg.from_user.username)
    else:
        curr_user = "[{}](tg://user?id={})".format(msg.from_user.first_name, msg.from_user.id)

    user_id = extract_user(update.effective_message, args)
    if user_id:
        slapped_user = bot.get_chat(user_id)
        user1 = curr_user
        if slapped_user.username:
            user2 = "@" + escape_markdown(slapped_user.username)
        else:
            user2 = "[{}](tg://user?id={})".format(slapped_user.first_name,
                                                   slapped_user.id)

    # if no target found, bot targets the sender
    else:
        user1 = "[{}](tg://user?id={})".format(bot.first_name, bot.id)
        user2 = curr_user

    temp = random.choice(SLAP_TEMPLATES)
    item = random.choice(ITEMS)
    hit = random.choice(HIT)
    throw = random.choice(THROW)

    repl = temp.format(user1=user1, user2=user2, item=item, hits=hit, throws=throw)

    reply_text(repl, parse_mode=ParseMode.MARKDOWN) 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:37,代码来源:misc.py

示例10: get_id

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
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) 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:28,代码来源:misc.py

示例11: slist

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def slist(bot: Bot, update: Update):
    message = update.effective_message
    text1 = "My sudo users are:"
    text2 = "My support users are:"
    for user_id in SUDO_USERS:
        try:
            user = bot.get_chat(user_id)
            name = "[{}](tg://user?id={})".format(user.first_name + (user.last_name or ""), user.id)
            if user.username:
                name = escape_markdown("@" + user.username)
            text1 += "\n - {}".format(name)
        except BadRequest as excp:
            if excp.message == 'Chat not found':
                text1 += "\n - ({}) - not found".format(user_id)
    for user_id in SUPPORT_USERS:
        try:
            user = bot.get_chat(user_id)
            name = "[{}](tg://user?id={})".format(user.first_name + (user.last_name or ""), user.id)
            if user.username:
                name = escape_markdown("@" + user.username)
            text2 += "\n - {}".format(name)
        except BadRequest as excp:
            if excp.message == 'Chat not found':
                text2 += "\n - ({}) - not found".format(user_id)
    message.reply_text(text1 + "\n", parse_mode=ParseMode.MARKDOWN)
    message.reply_text(text2 + "\n", parse_mode=ParseMode.MARKDOWN) 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:28,代码来源:special.py

示例12: log_user

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def log_user(update, context):
    chat = update.effective_chat  # type: Optional[Chat]
    msg = update.effective_message  # type: Optional[Message]
    """text = msg.text if msg.text else ""
                uid = msg.from_user.id
                uname = msg.from_user.name
                print("{} | {} | {} | {}".format(text, uname, uid, chat.title))"""
    fed_id = fedsql.get_fed_id(chat.id)
    if fed_id:
        user = update.effective_user
        if user:
            fban, fbanreason, fbantime = fedsql.get_fban_user(fed_id, user.id)
            if fban:
                send_message(update.effective_message, languages.tl(update.effective_message, "Pengguna ini dilarang di federasi saat ini!\nAlasan: `{}`").format(fbanreason), parse_mode="markdown")
                try:
                    context.bot.kick_chat_member(chat.id, user.id)
                except:
                	print("Fban: cannot banned this user")

    sql.update_user(msg.from_user.id,
                    msg.from_user.username,
                    chat.id,
                    chat.title)

    if msg.reply_to_message:
        sql.update_user(msg.reply_to_message.from_user.id,
                        msg.reply_to_message.from_user.username,
                        chat.id,
                        chat.title)

    if msg.forward_from:
        sql.update_user(msg.forward_from.id,
                        msg.forward_from.username) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:35,代码来源:users.py

示例13: new_fed

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
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!")) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:41,代码来源:feds.py

示例14: del_fed

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def del_fed(update, context):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	args = context.args
	if chat.type != "private":
		send_message(update.effective_message, tl(update.effective_message, "Hapus federasi Anda di PM saya, bukan dalam grup."))
		return
	if args:
		is_fed_id = args[0]
		getinfo = sql.get_fed_info(is_fed_id)
		if getinfo == False:
			send_message(update.effective_message, tl(update.effective_message, "Federasi ini tidak di temukan!"))
			return
		if int(getinfo['owner']) == int(user.id) or int(user.id) == OWNER_ID:
			fed_id = is_fed_id
		else:
			send_message(update.effective_message, tl(update.effective_message, "Hanya pemilik federasi yang dapat melakukan ini!"))
			return
	else:
		send_message(update.effective_message, tl(update.effective_message, "Apa yang harus saya hapus?"))
		return

	if is_user_fed_owner(fed_id, user.id) == False:
		send_message(update.effective_message, tl(update.effective_message, "Hanya pemilik federasi yang dapat melakukan ini!"))
		return

	send_message(update.effective_message, tl(update.effective_message, "Anda yakin ingin menghapus federasi Anda? Tindakan ini tidak bisa dibatalkan, Anda akan kehilangan seluruh daftar larangan Anda, dan '{}' akan hilang secara permanen.").format(getinfo['fname']),
			reply_markup=InlineKeyboardMarkup(
						[[InlineKeyboardButton(text=tl(update.effective_message, "⚠️ Hapus Federasi ⚠️"), callback_data="rmfed_{}".format(fed_id))],
						[InlineKeyboardButton(text=tl(update.effective_message, "Batalkan"), callback_data="rmfed_cancel")]])) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:32,代码来源:feds.py

示例15: fed_info

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import user [as 别名]
def fed_info(update, context):
	chat = update.effective_chat  # type: Optional[Chat]
	user = update.effective_user  # type: Optional[User]
	args = context.args
	if args:
		fed_id = args[0]
		info = sql.get_fed_info(fed_id)
	else:
		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
		info = sql.get_fed_info(fed_id)

	owner = context.bot.get_chat(info['owner'])
	try:
		owner_name = owner.first_name + " " + owner.last_name
	except:
		owner_name = owner.first_name
	FEDADMIN = sql.all_fed_users(fed_id)
	FEDADMIN.append(int(owner.id))
	TotalAdminFed = len(FEDADMIN)

	user = update.effective_user  # type: Optional[Chat]
	chat = update.effective_chat  # type: Optional[Chat]
	info = sql.get_fed_info(fed_id)

	text = tl(update.effective_message, "<b>ℹ️ Info federasi:</b>")
	text += "\nFedID: <code>{}</code>".format(fed_id)
	text += tl(update.effective_message, "\nNama: {}").format(info['fname'])
	text += tl(update.effective_message, "\nPembuat: {}").format(mention_html(owner.id, owner_name))
	text += tl(update.effective_message, "\nSeluruh admin: <code>{}</code>").format(TotalAdminFed)
	getfban = sql.get_all_fban_users(fed_id)
	text += tl(update.effective_message, "\nTotal yang di banned: <code>{}</code>").format(len(getfban))
	getfchat = sql.all_fed_chats(fed_id)
	text += tl(update.effective_message, "\nTotal grup yang terkoneksi: <code>{}</code>").format(len(getfchat))

	send_message(update.effective_message, text, parse_mode=ParseMode.HTML) 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:40,代码来源:feds.py


注:本文中的telegram.ext.Filters.user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。