예제 #1
0
    for msg_id in event.deleted_ids:
        revived: CachedMessage = await utils.get_message(msg_id, event.chat_id)
        if revived:
            try:
                text = escape(revived.text) if revived.text else None
                file_id = revived.file_id
                mention = f'<a href="tg://user?id={revived.user_id}">{revived.user_name}</a>'

                text = f'{mention} at {revived.chat_name}\n{text}'

                if file_id:
                    await bot.send_document(chat_id=config.commandos_id,
                                            document=file_id,
                                            caption=text,
                                            parse_mode=ParseMode.HTML,
                                            disable_notification=True)

                else:
                    await bot.send_message(chat_id=config.commandos_id,
                                           text=text,
                                           parse_mode=ParseMode.HTML,
                                           disable_notification=True)
            except Exception as ex:
                log.exception('error during reviving %s', revived)

            finally:
                await utils.delete_message(revived.id)


handlers.extend((cache_message, revive_message))
예제 #2
0
import logging

from telethon.events import NewMessage, register

from core.misc import controller, handlers
from modules.nailerine.spoiling import utils_async

log = logging.getLogger(__name__)

flood = controller.anti_flood


@register(NewMessage(outgoing=True, pattern=r'(?i)spoil member_ids'))
async def spoil_member_ids(event: NewMessage.Event):
    await utils_async.do_spoil(event)


@register(NewMessage(incoming=True, pattern=r'(?i)spoil member_ids'))
@flood
async def spoil_member_ids_public(event: NewMessage.Event):
    log.warning('%s requested members spoiler in %s', event.sender_id,
                event.chat)
    await utils_async.do_spoil(event)


handlers.extend((spoil_member_ids, spoil_member_ids_public))
예제 #3
0
파일: base.py 프로젝트: nailerNAS/nailerine
    messages = await client.get_messages(await event.get_input_chat(),
                                         limit=0,
                                         offset_date=offset)

    text = f'OMW is {"enabled" if event.chat_id in chats else "disabled"} in this chat\n'
    text += f'There are {messages.total} old messages (48 hours offset)'

    await event.edit(text)


@register(NewMessage(outgoing=True, pattern=r'omw now$'))
async def omw_now(event: NewMessage.Event):
    result = await omw(event)
    await event.edit(f'{result} messages were removed by OMW')


@register(NewMessage(outgoing=True, pattern=r'omw auto$'))
async def omw_auto(event: NewMessage.Event):
    if event.chat_id in chats:
        await chats.pop(event.chat_id).close()
        await event.edit(f'Nailerine has disabled OMW for this chat')

    else:
        chats[event.chat_id] = await create_scheduler()
        await chats[event.chat_id].spawn(periodic_omw(event, chats))
        await event.edit('Nailerine has enabled OMW for this that')


handlers.extend((omw_status, omw_now, omw_auto))
예제 #4
0
            file.seek(0)

            await gather(event.delete(),
                         event.respond(file=file))
    else:
        await event.edit(output, parse_mode='html')


@register(NewMessage(outgoing=True, pattern=r'(\.bash\s).+'))
async def run_bash(event: hints.EventLike):
    code = event.raw_text.replace(event.pattern_match.group(1), '')
    output = await bash(code)
    output = format_run(code, output, 'Bash')

    if len(output) > 4096:
        with io.BytesIO() as file:
            file.name = 'bash.htm'
            file.write(output)
            file.seek(0)
            await event.reply(file=file)
    else:
        await event.edit(output, parse_mode='html')


handlers.extend(
    (
        run_exec,
        run_bash,
    )
)
예제 #5
0
파일: base.py 프로젝트: nailerNAS/nailerine
    await sleep(15)
    await report.delete()


@register(NewMessage(outgoing=True, pattern=r'WAM$'))
async def wipe_all_messages(event: NewMessage.Event):
    client: TelegramClient = event.client
    entity = await event.get_input_chat()

    messages = []
    count = 0

    async for message in client.iter_messages(entity, reverse=True):
        messages.append(message)
        if len(messages) >= 100:
            await client.delete_messages(entity, messages)
            count += len(messages)
            messages = []
            await sleep(randint(1, 5))

    if messages:
        await client.delete_messages(entity, messages)
        count += len(messages)

    report = await event.respond(f'Nailerine has sent {count} deletion requests')
    await sleep(15)
    await report.delete()


handlers.extend((wipe_own_messages, wipe_all_messages))