def tagall(update, context): chat = update.effective_chat user = update.effective_user message = update.effective_message args = context.args query = " ".join(args) if not query: message.reply_text("Please give a reason why are you want to tag all!") return chat_id = str(chat.id)[1:] tagall = list(REDIS.sunion(f"tagall2_{chat_id}")) tagall.sort() tagall = ", ".join(tagall) if tagall: tagall_reason = query if message.reply_to_message: message.reply_to_message.reply_text( "{}" "\n\n<b>• Tagged Reason : </b>" "\n{}".format(tagall, tagall_reason), parse_mode=ParseMode.HTML, ) else: message.reply_text( "{}" "\n\n<b>• Tagged Reason : </b>" "\n{}".format(tagall, tagall_reason), parse_mode=ParseMode.HTML, ) else: message.reply_text("Tagall list is empty!")
def untagall(update, context): chat = update.effective_chat user = update.effective_user message = update.effective_message chat_id = str(chat.id)[1:] tagall_list = list(REDIS.sunion(f"tagall2_{chat_id}")) for tag_user in tagall_list: REDIS.srem(f"tagall2_{chat_id}", tag_user) message.reply_text( "Successully removed all users from {}'s tag list.".format(chat.title))
def tagme(update, context): chat = update.effective_chat user = update.effective_user message = update.effective_message chat_id = str(chat.id)[1:] tagall_list = list(REDIS.sunion(f"tagall2_{chat_id}")) match_user = mention_html(user.id, user.first_name) if match_user in tagall_list: message.reply_text("You're Already Exist In {}'s Tag List!".format( chat.title)) return REDIS.sadd(f"tagall2_{chat_id}", mention_html(user.id, user.first_name)) message.reply_text( "{} has been successfully added in {}'s tag list.".format( mention_html(user.id, user.first_name), chat.title), parse_mode=ParseMode.HTML, )
def untagme(update, context): chat = update.effective_chat user = update.effective_user message = update.effective_message chat_id = str(chat.id)[1:] tagall_list = list(REDIS.sunion(f"tagall2_{chat_id}")) match_user = mention_html(user.id, user.first_name) if match_user not in tagall_list: message.reply_text( "You're already doesn't exist in {}'s tag list!".format( chat.title)) return REDIS.srem(f"tagall2_{chat_id}", mention_html(user.id, user.first_name)) message.reply_text( "{} has been removed from {}'s tag list.".format( mention_html(user.id, user.first_name), chat.title), parse_mode=ParseMode.HTML, )
def addtag(update, context): chat = update.effective_chat user = update.effective_user message = update.effective_message args = context.args user_id, reason = extract_user_and_text(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return try: member = chat.get_member(user_id) except BadRequest as excp: if excp.message == "User not found": message.reply_text("I can't seem to find this user") return raise if user_id == context.bot.id: message.reply_text("how I supposed to tag myself") return chat_id = str(chat.id)[1:] tagall_list = list(REDIS.sunion(f"tagall2_{chat_id}")) match_user = mention_html(member.user.id, member.user.first_name) if match_user in tagall_list: message.reply_text( "{} is already exist in {}'s tag list.".format( mention_html(member.user.id, member.user.first_name), chat.title), parse_mode=ParseMode.HTML, ) return message.reply_text( "{} accept this, if you want to add yourself into {}'s tag list! or just simply decline this." .format(mention_html(member.user.id, member.user.first_name), chat.title), reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(text="Accept", callback_data=f"tagall_accept={user_id}"), InlineKeyboardButton(text="Decline", callback_data=f"tagall_dicline={user_id}"), ]]), parse_mode=ParseMode.HTML, )
def removetag(update, context): chat = update.effective_chat user = update.effective_user message = update.effective_message args = context.args user_id, reason = extract_user_and_text(message, args) if not user_id: message.reply_text("You don't seem to be referring to a user.") return try: member = chat.get_member(user_id) except BadRequest as excp: if excp.message == "User not found": message.reply_text("I can't seem to find this user") return raise if user_id == context.bot.id: message.reply_text("how I supposed to tag or untag myself") return chat_id = str(chat.id)[1:] tagall_list = list(REDIS.sunion(f"tagall2_{chat_id}")) match_user = mention_html(member.user.id, member.user.first_name) if match_user not in tagall_list: message.reply_text( "{} is doesn't exist in {}'s list!".format( mention_html(member.user.id, member.user.first_name), chat.title), parse_mode=ParseMode.HTML, ) return member = chat.get_member(int(user_id)) chat_id = str(chat.id)[1:] REDIS.srem(f"tagall2_{chat_id}", mention_html(member.user.id, member.user.first_name)) message.reply_text( "{} is successfully removed from {}'s list.".format( mention_html(member.user.id, member.user.first_name), chat.title), parse_mode=ParseMode.HTML, )