예제 #1
0
async def dcinfo(e):
    if e.pattern_match.group(1):
        clients = helper.give_client(helper.give_id(e.pattern_match.group(1)))
        if not clients:
            await e.reply(strings.follow_who.format(e.pattern_match.group(1)))
            return
    else:
        clients = [e.client]
    for client in clients:
        await e.reply('<code>' + (
            await client(functions.help.GetNearestDcRequest())).stringify() +
                      '</code>')
예제 #2
0
async def help_text(e):
    clients = e.pattern_match.group(1)
    if clients:
        clients = helper.give_client(helper.give_id(clients))
    else:
        clients = [e.client]
    for client in clients:
        text = helper.give_help(client)
        if config.help_as_file:
            await e.reply(file=helper.memory_file('help.txt', text))
        else:
            await e.reply(text, link_preview=False)
예제 #3
0
async def send(e):
    if e.pattern_match.group(1):
        clients = helper.give_client(helper.give_id(e.pattern_match.group(1)))
        if clients is None:
            await e.reply(strings.follow_who.format(e.pattern_match.group(1)))
            return
    else:
        clients = [e.client]
    chat = e.pattern_match.group(2)
    text = e.pattern_match.group(3)
    chat = helper.give_chat(chat, await e.get_chat())
    for client in clients:
        await client.send_message(chat, text)
예제 #4
0
async def read_messages(e):
    quick = e.pattern_match.group(1)
    chat = helper.give_chat(e.pattern_match.group(3), await e.get_chat())
    clients = e.pattern_match.group(2)
    if clients:
        clients = helper.give_client(helper.give_id(clients))
        if not clients:
            await e.reply(strings.follow_who.format(e.pattern_match.group(1)))
            return
    else:
        clients = [e.client]

    async def _read_messages(client, chat):
        await client.send_read_acknowledge(chat, clear_mentions=True)

    if quick:
        await asyncio.wait(
            [_read_messages(client, chat) for client in clients])
        await e.reply(strings.cmd_read_respond)
    else:
        for client in clients:
            await _read_messages(client, chat)
            await e.reply(strings.cmd_read_respond)
예제 #5
0
async def join(e):
    if e.pattern_match.group(1):
        clients = helper.give_client(helper.give_id(e.pattern_match.group(1)))
        if clients is None:
            await e.reply(strings.follow_who.format(e.pattern_match.group(1)))
            return
    else:
        clients = [e.client]
    chat = e.pattern_match.group(2)
    chat = helper.give_chat(chat, await e.get_chat())
    try:
        invite_info = utils.resolve_invite_link(chat)
    except Exception:
        invite_info = (None, None, None)
    for client in clients:
        if invite_info[0] is None:
            await client(functions.channels.JoinChannelRequest(chat))
        else:
            await client(functions.messages.ImportChatInviteRequest(chat))
        try:
            await e.reply(strings.cmd_join_respond)
        except Exception:
            pass