예제 #1
0
    async def handle_matrix_title(self, sender: 'u.User', title: str) -> None:
        if self.peer_type not in ("chat", "channel"):
            return

        if self.peer_type == "chat":
            response = await sender.client(EditChatTitleRequest(chat_id=self.tgid, title=title))
        else:
            channel = await self.get_input_entity(sender)
            response = await sender.client(EditTitleRequest(channel=channel, title=title))
        self.dedup.register_outgoing_actions(response)
        self.title = title
        self.save()
예제 #2
0
async def change_profile_name(e):
    title = e.pattern_match.group(1)
    chat = await e.get_chat()
    try:
        await client(EditChatTitleRequest(chat.id, title))
        await e.edit("`Succesfully changed channel/chat title`")

    except Exception as exc:
        if isinstance(exc, errors.ChatAdminRequiredError):
            await e.edit("`Chat admin privileges are required to do that`")

        if isinstance(exc, errors.ChatNotModifiedError):
            await e.edit("`The chat or channel wasn't modified`")
예제 #3
0
    async def handle_matrix_title(self, sender: 'u.User', title: str,
                                  event_id: EventID) -> None:
        if self.peer_type not in ("chat", "channel"):
            return

        if self.peer_type == "chat":
            response = await sender.client(
                EditChatTitleRequest(chat_id=self.tgid, title=title))
        else:
            channel = await self.get_input_entity(sender)
            response = await sender.client(
                EditTitleRequest(channel=channel, title=title))
        self.dedup.register_outgoing_actions(response)
        self.title = title
        await self.save()
        await self._send_delivery_receipt(event_id)
        await self.update_bridge_info()
예제 #4
0
async def change_profile_name(event):
    split_text = event.text.split(None, 1)

    if len(split_text) == 0:
        await client.update_message(event, CNAME_HELP)
        return

    title = split_text[1]
    chat = await event.get_chat()
    if not chat.admin_rights or not chat.creator:
        await client.update_message(
            event, "`Chat admin privileges are required to do that`")
        return
    try:
        await client(EditChatTitleRequest(chat.id, title))
        await client.update_message(
            event, "`Succesfully changed channel/chat title`")

    except Exception as exc:
        if isinstance(exc, errors.ChatNotModifiedError):
            await client.update_message(
                event, "`The chat or channel wasn't modified`")