コード例 #1
0
async def leave(context):
    """ It leaves you from the group. """
    if context.is_group:
        await context.edit(lang('leave_bye'))
        try:
            await bot(DeleteChatUserRequest(chat_id=context.chat_id,
                                            user_id=context.sender_id
                                            ))
        except ChatIdInvalidError:
            await bot(LeaveChannelRequest(context.chat_id))
    else:
        await context.edit(lang('leave_not_group'))
コード例 #2
0
ファイル: message.py プロジェクト: yxkumad/PagerMaid-Modify
async def leave(context):
    """ It leaves you from the group. """
    if context.is_group:
        await context.edit("贵群真是浪费我的时间,再见。")
        try:
            await bot(DeleteChatUserRequest(chat_id=context.chat_id,
                                            user_id=context.sender_id
                                            ))
        except ChatIdInvalidError:
            await bot(LeaveChannelRequest(context.chat_id))
    else:
        await context.edit("出错了呜呜呜 ~ 当前聊天似乎不是群聊。")
コード例 #3
0
async def _(e):
    type_of_group = e.pattern_match.group(1)
    group_name = e.pattern_match.group(2)
    username = None
    if " ; " in group_name:
        group_ = group_name.split(" ; ", maxsplit=1)
        group_name = group_[0]
        username = group_[1]
    xx = await eor(e, get_string("com_1"))
    if type_of_group == "b":
        try:
            r = await e.client(
                CreateChatRequest(
                    users=["@missrose_bot"],
                    title=group_name,
                ), )
            created_chat_id = r.chats[0].id
            await e.client(
                DeleteChatUserRequest(
                    chat_id=created_chat_id,
                    user_id="@missrose_bot",
                ), )
            result = await e.client(
                ExportChatInviteRequest(peer=created_chat_id, ), )
            await xx.edit(
                get_string("chats_4").format(group_name, result.link),
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
    elif type_of_group in ["g", "c"]:
        try:
            r = await e.client(
                CreateChannelRequest(
                    title=group_name,
                    about=get_string("chats_5"),
                    megagroup=type_of_group != "c",
                ))

            created_chat_id = r.chats[0].id
            if username:
                await e.client(UpdateUsernameRequest(created_chat_id,
                                                     username))
                result = "https://t.me/" + username
            else:
                result = (await e.client(
                    ExportChatInviteRequest(peer=created_chat_id, ), )).link
            await xx.edit(
                get_string("chats_6").format(f"[{group_name}]({result})"),
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
コード例 #4
0
async def leave(context):
    """ It leaves you from the group. """
    if context.is_group:
        await context.edit("Wasted my time, bye.")
        try:
            await bot(
                DeleteChatUserRequest(chat_id=context.chat_id,
                                      user_id=context.sender_id))
        except ChatIdInvalidError:
            await bot(LeaveChannelRequest(chatid))
    else:
        await context.edit("Current chat is not a group chat.")
コード例 #5
0
async def _(e):
    if BOT_MODE:
        return await eor(e, "You Cant use this Command in BOT_MODE")
    type_of_group = e.pattern_match.group(1)
    group_name = e.pattern_match.group(2)
    xx = await eor(e, "`Processing...`")
    if type_of_group == "b":
        try:
            r = await e.client(
                CreateChatRequest(
                    users=["@missrose_bot"],
                    title=group_name,
                ),
            )
            created_chat_id = r.chats[0].id
            await e.client(
                DeleteChatUserRequest(
                    chat_id=created_chat_id,
                    user_id="@missrose_bot",
                ),
            )
            result = await e.client(
                ExportChatInviteRequest(
                    peer=created_chat_id,
                ),
            )
            await xx.edit(
                f"Your [{group_name}]({result.link}) Group Made Boss!",
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
    elif type_of_group == "g" or type_of_group == "c":
        try:
            r = await e.client(
                CreateChannelRequest(
                    title=group_name,
                    about="CREATED BY INFINATO",
                    megagroup=False if type_of_group == "c" else True,
                ),
            )
            created_chat_id = r.chats[0].id
            result = await e.client(
                ExportChatInviteRequest(
                    peer=created_chat_id,
                ),
            )
            await xx.edit(
                f"Your [{group_name}]({result.link}) Group/Channel Has been made Boss!",
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
コード例 #6
0
async def _(event):
    if BOT_MODE:
        return await eor(event, "`Anda tidak bisa menggunakan perintah ini di BOT_MODE.`")
    tipe = event.pattern_match.group(1)
    nama = event.pattern_match.group(2)
    xx = await eor(event, "`Memprossess...`")
    if tipe == "g":
        try:
            r = await event.client(
                CreateChatRequest(
                    users=["@missrose_bot"],
                    title=nama,
                ),
            )
            cht_id = r.chats[0].id
            await event.client(
                DeleteChatUserRequest(
                    chat_id=cht_id,
                    user_id="@missrose_bot"
                )
            )
            res = await event.client(
                ExportChatInviteRequest(
                    peer=cht_id
                )
            )
            await xx.edit(
                f"[{nama}]({res.link}) Berhasil dibuat!",
                link_preview=False
            )
        except Exception as EXcep:
            await xx.edit(str(EXcep))
    elif tipe == "c":
        try:
            r = await event.client(
                CreateChannelRequest(
                    title=nama,
                    about="Join @KingUserbotSupport",
                    megagroup=False
                )
            )
            cht_id = r.chats[0].id
            res = await event.client(
                ExportChatInviteRequest(
                    peer=cht_id
                )
            )
            await xx.edit(
                f"[{nama}]({res.link}) Berhasil dibuat!",
                link_preview=False
            )
        except Exception as EXcep:
            await xx.edit(str(EXcep))
コード例 #7
0
ファイル: chats.py プロジェクト: theshashankk/Ultroid
async def _(e):
    type_of_group = e.pattern_match.group(1)
    group_name = e.pattern_match.group(2)
    username = None
    if " ; " in group_name:
        group_ = group_name.split(" ; ", maxsplit=1)
        group_name = group_[0]
        username = group_[1]
    xx = await eor(e, "`Processing...`")
    if type_of_group == "b":
        try:
            r = await e.client(
                CreateChatRequest(
                    users=["@missrose_bot"],
                    title=group_name,
                ), )
            created_chat_id = r.chats[0].id
            await e.client(
                DeleteChatUserRequest(
                    chat_id=created_chat_id,
                    user_id="@missrose_bot",
                ), )
            result = await e.client(
                ExportChatInviteRequest(peer=created_chat_id, ), )
            await xx.edit(
                f"Your [{group_name}]({result.link}) Group Made Boss!",
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
    elif type_of_group in ["g", "c"]:
        try:
            r = await e.client(
                CreateChannelRequest(
                    title=group_name,
                    about="Join @TeamUltroid",
                    megagroup=type_of_group != "c",
                ))

            created_chat_id = r.chats[0].id
            if username:
                await e.client(UpdateUsernameRequest(created_chat_id,
                                                     username))
                result = "https://t.me/" + username
            else:
                result = (await e.client(
                    ExportChatInviteRequest(peer=created_chat_id, ), )).link
            await xx.edit(
                f"Your [{group_name}]({result}) Group/Channel Has been made Boss!",
                link_preview=False,
            )
        except Exception as ex:
            await xx.edit(str(ex))
コード例 #8
0
async def leave(context):
    """ It leaves you from the group. """
    if not context.text[0].isalpha() and context.text[0] not in ("/", "#", "@",
                                                                 "!"):
        await context.edit("Wasted my time, bye.")
        try:
            await bot(
                DeleteChatUserRequest(chat_id=context.chat_id,
                                      user_id=context.sender_id))
        except ChatIdInvalidError:
            await bot(LeaveChannelRequest(chatid))
        except PeerIdInvalidError:
            await context.edit("You are not in a group.")
コード例 #9
0
def create_birthday_chat(client, config, birthday_guy, responsible_guy,
                         employees):

    congratulators_usernames = []
    for employee in employees:
        if employee.username != birthday_guy.username:
            congratulators_usernames.append(employee.username)

    updates = client(
        CreateChatRequest(users=congratulators_usernames,
                          title=config["TITLE_TEMPLATE"].format(
                              name=birthday_guy.name,
                              day=birthday_guy.birthday.day,
                              month=birthday_guy.birthday.month,
                              year=birthday_guy.birthday.year)))

    birthday_chat = updates.chats[0]

    # Setting responsible_guy as admin
    client(ToggleChatAdminsRequest(chat_id=birthday_chat.id, enabled=True))
    client(
        EditChatAdminRequest(chat_id=birthday_chat.id,
                             user_id=responsible_guy.username,
                             is_admin=1))

    # Sending greeting message
    client.send_message(
        birthday_chat, config["GREETING_MESSAGE"].format(
            name=birthday_guy.name,
            responsible_guy_name=responsible_guy.name,
            responsible_guy_username=responsible_guy.username))

    # Deleting myself in case its my birthday
    if birthday_guy.username == config["MyUsername"]:
        client(
            DeleteChatUserRequest(chat_id=birthday_chat.id,
                                  user_id=config["MyUsername"]))

    return 0