예제 #1
0
파일: tagger.py 프로젝트: WeebTime/Ash
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)
예제 #2
0
def unapprove(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
        else:
            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)
예제 #3
0
파일: tagger.py 프로젝트: WeebTime/Ash
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))
예제 #4
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))
예제 #5
0
파일: tagger.py 프로젝트: WeebTime/Ash
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)
예제 #6
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)
예제 #7
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)