Exemplo n.º 1
0
def unapproveall(update, context):
    chat = update.effective_chat
    user = update.effective_user
    message = update.effective_message
    chat_id = str(chat.id)[1:]
    approve_list = list(REDIS.sunion(f'approve_list_{chat_id}'))
    for target_user in approve_list:
        REDIS.srem(f'approve_list_{chat_id}', target_user)
    message.reply_text("Successully unapproved all users from {}.".format(
        chat.title))
Exemplo n.º 2
0
def removemangalist(update, context):
    user = update.effective_user 
    message = update.effective_message 
    removewlist = message.text.split(' ', 1) 
    args = context.args
    query = " ".join(args)
    if not query:
        message.reply_text("Please enter a manga name to remove from your manga list.")
        return
    fvrt_char = list(REDIS.sunion(f'anime_mangaread{user.id}'))
    removewlist = removewlist[1]
    
    if removewlist not in fvrt_char:
        message.reply_text(
            f"<code>{removewlist}</code> doesn't exist in your manga list.",
            parse_mode=ParseMode.HTML
        )
    else:
        message.reply_text(
            f"<code>{removewlist}</code> has been removed from your favorite characters list.",
            parse_mode=ParseMode.HTML
        )
        REDIS.srem(f'anime_mangaread{user.id}', removewlist)
Exemplo n.º 3
0
def removewatchlist(update, context):
    user = update.effective_user 
    message = update.effective_message 
    removewlist = message.text.split(' ', 1) 
    args = context.args
    query = " ".join(args)
    if not query:
        message.reply_text("Please enter a anime name to remove from your watchlist.")
        return
    watchlist = list(REDIS.sunion(f'anime_watch_list{user.id}'))
    removewlist = removewlist[1]
    
    if removewlist not in watchlist:
        message.reply_text(
            f"<code>{removewlist}</code> doesn't exist in your watch list.",
            parse_mode=ParseMode.HTML
        )
    else:
        message.reply_text(
            f"<code>{removewlist}</code> has been removed from your watch list.",
            parse_mode=ParseMode.HTML
        )
        REDIS.srem(f'anime_watch_list{user.id}', removewlist)
Exemplo n.º 4
0
def unapprove(update: Update, context: CallbackContext) -> str:
    bot = context.bot
    args = context.args

    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 approve or unapprove myself")
        return
    chat_id = str(chat.id)[1:]
    approve_list = list(REDIS.sunion(f'approve_list_{chat_id}'))
    target_user = mention_html(member.user.id, member.user.first_name)
    if target_user not in approve_list:
        message.reply_text("{} isn't approved yet.".format(
            mention_html(member.user.id, member.user.first_name)),
                           parse_mode=ParseMode.HTML)
        return
    member = chat.get_member(int(user_id))
    chat_id = str(chat.id)[1:]
    REDIS.srem(f'approve_list_{chat_id}',
               mention_html(member.user.id, member.user.first_name))
    message.reply_text("{} is no longer approved in {}.".format(
        mention_html(member.user.id, member.user.first_name), chat.title),
                       parse_mode=ParseMode.HTML)