Ejemplo n.º 1
0
async def save_note(_, message):
    if not DB_AVAILABLE:
        await message.edit("Your database is not avaiable!")
        return
    note_name, text, data_type, content = get_note_type(message)

    if not note_name:
        await message.edit(
            "```"
            + message.text +
            "```\n\nError: You must give a name for this note!"
        )
        return

    if data_type == Types.TEXT:
        teks, _ = parse_button(text)
        if not teks:
            await message.edit(
                "```"
                + message.text
                + "```\n\nError: There is no text in here!"
            )
            return

    db.save_selfnote(message.from_user.id, note_name, text, data_type, content)
    await message.edit(f"Saved note `{note_name}`!")
Ejemplo n.º 2
0
async def save_note(client, message):
    if not DB_AVAIABLE:
        await message.edit("Your database is not avaiable!")
        return
    note_name, text, data_type, content, file_ref = get_note_type(message)

    if not note_name:
        await message.edit("```" + message.text +
                           '```\n\nError: You must give a name for this note!')
        return

    if data_type == Types.TEXT:
        file_id = None
        teks, button = parse_button(text)
        if not teks:
            await message.edit("```" + message.text +
                               '```\n\nError: There is no text in here!')
            return
    else:
        file_id = await client.forward_messages(
            Owner,
            message.chat.id,
            message.reply_to_message.message_id,
            as_copy=True)

    db.save_selfnote(message.from_user.id, note_name, text, data_type, content,
                     file_ref, file_id.message_id if file_id else None)
    await message.edit('Saved note `{}`!'.format(note_name))
Ejemplo n.º 3
0
async def save_note(client, message):
	note_name, text, data_type, content = get_note_type(message)

	if not note_name:
		await message.edit("```" + message.text + '```\n\nError: You must give a name for this note!')
		return

	if data_type == Types.TEXT:
		teks, button = parse_button(text)
		if not teks:
			await message.edit("```" + message.text + '```\n\nError: There is no text in here!')
			return

	db.save_selfnote(message.from_user.id, note_name, text, data_type, content)
	await message.edit('Saved note `{}`!'.format(note_name))
Ejemplo n.º 4
0
async def get_note(client, message):
    if not DB_AVAIABLE:
        await message.edit("Your database is not avaiable!")
        return
    is_hash = False
    if len(message.text.split()) >= 2:
        note = message.text.split()[1]
    else:
        await message.edit("Give me a note tag!")

    getnotes = db.get_selfnote(message.from_user.id, note)
    if not getnotes:
        await message.edit("This note does not exist!")
        return

    replyid = None  # message.message_id
    if message.reply_to_message:
        replyid = message.reply_to_message.message_id

    if getnotes['type'] == Types.TEXT:
        teks, button = parse_button(getnotes.get('value'))
        button = build_keyboard(button)
        if button:
            button = InlineKeyboardMarkup(button)
        else:
            button = None
        if button:
            await message.edit(
                "Inline button not supported in this userbot version :(\nSee @AyraSupport for more information"
            )
            return
        else:
            await message.edit(teks)
    elif getnotes['type'] in (Types.STICKER, Types.VOICE, Types.VIDEO_NOTE,
                              Types.CONTACT, Types.ANIMATED_STICKER):
        await message.delete()
        try:
            if replyid:
                await GET_FORMAT[getnotes['type']
                                 ](message.chat.id,
                                   getnotes['file'],
                                   file_ref=getnotes['file_ref'],
                                   reply_to_message_id=replyid)
            else:
                await GET_FORMAT[getnotes['type']
                                 ](message.chat.id,
                                   getnotes['file'],
                                   file_ref=getnotes['file_ref'])
        except errors.exceptions.bad_request_400.BadRequest:
            msg = await client.get_messages(Owner, getnotes['message_id'])
            note_name, text, data_type, content, file_ref = fetch_note_type(
                msg)
            db.save_selfnote(Owner, note, "", getnotes['type'], content,
                             file_ref, getnotes['message_id'])
            if replyid:
                await GET_FORMAT[getnotes['type']](message.chat.id,
                                                   content,
                                                   file_ref=file_ref,
                                                   reply_to_message_id=replyid)
            else:
                await GET_FORMAT[getnotes['type']](message.chat.id,
                                                   content,
                                                   file_ref=file_ref)
    else:
        await message.delete()
        if getnotes.get('value'):
            teks, button = parse_button(getnotes.get('value'))
            button = build_keyboard(button)
            if button:
                button = InlineKeyboardMarkup(button)
            else:
                button = None
        else:
            teks = None
            button = None
        if button:
            await message.edit(
                "Inline button not supported in this userbot version :(\nSee @AyraSupport for more information"
            )
            return
        else:
            try:
                if replyid:
                    await GET_FORMAT[getnotes['type']
                                     ](message.chat.id,
                                       getnotes['file'],
                                       file_ref=getnotes['file_ref'],
                                       caption=teks,
                                       reply_to_message_id=replyid)
                else:
                    await GET_FORMAT[getnotes['type']
                                     ](message.chat.id,
                                       getnotes['file'],
                                       file_ref=getnotes['file_ref'],
                                       caption=teks)
            except errors.exceptions.bad_request_400.BadRequest:
                msg = await client.get_messages(Owner, getnotes['message_id'])
                note_name, text, data_type, content, file_ref = fetch_note_type(
                    msg)
                db.save_selfnote(Owner, note, teks, getnotes['type'], content,
                                 file_ref, getnotes['message_id'])
                if replyid:
                    await GET_FORMAT[getnotes['type']
                                     ](message.chat.id,
                                       getnotes['file'],
                                       file_ref=getnotes['file_ref'],
                                       caption=teks,
                                       reply_to_message_id=replyid)
                else:
                    await GET_FORMAT[getnotes['type']
                                     ](message.chat.id,
                                       getnotes['file'],
                                       file_ref=getnotes['file_ref'],
                                       caption=teks)