survey.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:tmerc-cogs 作者: tmercswims 项目源码 文件源码
def _save_answer(self, server_id: str, survey_id: str, user: discord.User,
                     answer: str, change: bool) -> bool:
        answers = self.surveys[server_id][survey_id]["answers"]
        asked = self.surveys[server_id][survey_id]["asked"]
        options = self.surveys[server_id][survey_id]["options"]

        if change:
            for a in answers.values():
                if user.id in a:
                    a.remove(user.id)

        if options != "any":
            limit = options[answer]["limit"]

        if answer not in answers:
            answers[answer] = []

        if answer in options and limit and len(answers[answer]) >= int(limit):
            return False

        answers[answer].append(user.id)
        if user.id in asked:
            asked.remove(user.id)
        dataIO.save_json(self.surveys_path, self.surveys)
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号