Exemplo n.º 1
0
def save_note(bot: BOT, message: Message):
    cmd = message.command
    try:
        cmd[1]
    except IndexError:
        message.edit("I need a name to save to...")
        sleep(2)
        message.delete()
        return

    note = BOT.send_video_note(
        chat_id='me',
        video_note=message.reply_to_message.download('./note.mp4'))
    note.delete()
    os.remove('./note.mp4')
    db = sqlite3.connect(PYRO_DB)
    c = db.cursor()
    try:
        c.execute(SAVE_NOTE.format(cmd[1], note.video_note.file_id))
    except sqlite3.IntegrityError:
        message.edit(f'Videonote "`{cmd[1]}`" already saved.')
        return
    except AttributeError:
        message.edit(
            f"The video needs an aspect:ratio of 1:1, otherwise it can't be a videonote."
        )
        sleep(3)
        message.delete()
        return
    db.commit()
    db.close()
    message.edit(f'Videnote saved as `{cmd[1]}`.')
    sleep(2)
    message.delete()
Exemplo n.º 2
0
def send_note(bot: BOT, message: Message):
    cmd = message.command
    try:
        cmd[1]
    except IndexError:
        message.edit(f"I need a name to look for.")
        sleep(2)
        message.delete()
        return
    db = sqlite3.connect(PYRO_DB)
    c = db.cursor()
    c.execute(GET_NOTE.format(cmd[1]))
    result = c.fetchone()
    if result:
        BOT.send_video_note(chat_id=message.chat.id,
                            video_note=result[0],
                            reply_to_message_id=ReplyCheck(message))
    else:
        message.edit(f'Videonote `{cmd[1]}` not found.')
        sleep(2)
    message.delete()
    db.close()