Ejemplo n.º 1
0
def mypacks(update, context):
    msg = update.effective_message
    user = update.effective_user
    packs = sql.list_packs(user.id)
    defpack = sql.get_default_pack(user.id)
    packlist = f"{user.first_name}'s steal pack list :\n"
    if checkpacks(context.bot, packs):
        packs = sql.list_packs(user.id)
    blank = packlist
    count = 0
    for pack in packs:
        count += 1
        if pack == defpack[0]:
            packlist += f"\n*{count}.* [{pack[3]}](t.me/addstickers/{pack[0]}) ✓"
        else:
            packlist += f"\n*{count}.* [{pack[3]}](t.me/addstickers/{pack[0]})"
    if packlist == blank:
        replymsg = msg.reply_text(s.NO_STOLEN_PACKS)
    else:
        replymsg = msg.reply_markdown(packlist)
    reply(msg, None, replymsg)
Ejemplo n.º 2
0
def switch(update, context):
    user = update.effective_user
    msg = update.effective_message
    if not context.args:
        reply(msg, s.SWITCH_INVALID_INPUT)
        return
    packs = sql.list_packs(user.id)
    if not packs:
        reply(msg, s.NO_STOLEN_PACKS)
        return
    if checkpacks(context.bot, packs):
        packs = sql.list_packs(user.id)
    if context.args[-1].isdigit():
        try:
            newdefpack = packs[int(context.args[-1]) - 1]
            defpack = sql.get_default_pack(user.id)
        except:
            reply(msg, s.SWITCH_PACK_DOESNT_EXIST)
            return
        if defpack == newdefpack:
            reply(msg, s.SWITCH_ALREADY_DEFAULT.format(newdefpack[3]))
        else:
            try:
                sql.remove_default(user.id)
                sql.set_default_by_id(newdefpack[0])
                reply(msg, s.SWITCH_CHANGED_DEFAULT.format(newdefpack[3]))
            except:
                reply(msg, s.SWITCH_INDEX_ERROR)
    else:
        arg = ' '.join(context.args)
        if not sql.get_pack_by_name(arg.lower(), user.id):
            reply(msg, s.SWITCH_PACK_DOESNT_EXIST)
            return
        try:
            sql.remove_default(user.id)
            sql.set_default_by_name(arg.lower(), user.id)
            reply(msg, s.SWITCH_CHANGED_DEFAULT.format(arg))
        except:
            reply(msg, s.SWITCH_PACKNAME_ERROR)
Ejemplo n.º 3
0
def delsticker(update, context):
    msg = update.effective_message
    if not msg.reply_to_message.sticker:
        reply(msg, s.DELETE_NOT_REPLY)
        return
    if not msg.reply_to_message.sticker.set_name in str(
            sql.list_packs(update.effective_user.id)):
        reply(msg, s.NOT_YOUR_PACK)
        return
    try:
        context.bot.delete_sticker_from_set(
            msg.reply_to_message.sticker.file_id)
    except:
        replymsg = msg.reply_text(s.DELETE_ERROR)
    else:
        replymsg = msg.reply_text(s.DELETE_SUCESSFUL)
    reply(msg, None, replymsg)
Ejemplo n.º 4
0
def setposition(update, context):
    msg = update.effective_message
    if not msg.reply_to_message.sticker.set_name in str(
            sql.list_packs(update.effective_user.id)):
        reply(msg, s.NOT_YOUR_PACK)
        return
    try:
        position = int(context.args[-1])
    except:
        replymsg = msg.reply_markdown(s.SETPOSITION_INVALID_INPUT)
        return
    if not msg.reply_to_message:
        replymsg = msg.reply_text(s.STEAL_NOT_REPLY)
        return
    if msg.reply_to_message.sticker:
        try:
            context.bot.set_sticker_position_in_set(
                msg.reply_to_message.sticker.file_id, position)
            replymsg = msg.reply_text("Sticker position changed.")
        except:
            replymsg = msg.reply_markdown(s.SETPOSITION_ERROR)
    else:
        replymsg = msg.reply_text(s.REPLY_NOT_MY_STICKER)
    reply(msg, None, replymsg)