コード例 #1
0
ファイル: feds.py プロジェクト: Hopsins/DIABLO
def join_fed(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    message = update.effective_message
    administrators = chat.get_administrators()
    fed_id = sql.get_fed_id(chat.id)

    if user.id in SUDO_USERS:
        pass
    else:
        for admin in administrators:
            status = admin.status
            if status == "creator":
                print(admin)
                if str(admin.user.id) == str(user.id):
                    pass
                else:
                    update.effective_message.reply_text(
                        tld(chat.id, "Only group creator can do it!"))
                    return
    if fed_id:
        message.reply_text(
            tld(chat.id,
                "Uh, Are you gonna join two federations at one chat?"))
        return

    if len(args) >= 1:
        fedd = args[0]
        print(fedd)
        if sql.search_fed_by_id(fedd) == False:
            message.reply_text(
                tld(chat.id, "Please enter valid federation id."))
            return

        x = sql.chat_join_fed(fedd, chat.id)
        if not x:
            message.reply_text(
                tld(
                    chat.id,
                    "Failed to join to federation! Due to some errors that basically I have no idea, try reporting it in support group!"
                ))
            return

        message.reply_text(tld(chat.id, "Chat joined to federation!"))
コード例 #2
0
ファイル: feds.py プロジェクト: ZyCromerZ/HarukaAya
def join_fed(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat
    user = update.effective_user
    message = update.effective_message
    administrators = chat.get_administrators()
    fed_id = sql.get_fed_id(chat.id)

    if user.id in SUDO_USERS:
        pass
    else:
        for admin in administrators:
            status = admin.status
            if status == "creator":
                print(admin)
                if str(admin.user.id) == str(user.id):
                    pass
                else:
                    update.effective_message.reply_text(
                        tld(chat.id, "common_group_creator_only"))
                    return
    if fed_id:
        message.reply_text(tld(chat.id, "feds_group_joined_fed"))
        return

    if len(args) >= 1:
        fedd = args[0]
        print(fedd)
        if sql.search_fed_by_id(fedd) == False:
            message.reply_text(tld(chat.id, "feds_fedid_invalid"))
            return

        x = sql.chat_join_fed(fedd, chat.id)
        if not x:
            message.reply_text(tld(chat.id, "feds_join_unknown_err"))
            return

        message.reply_text(tld(chat.id, "feds_join_success"))