示例#1
0
    async def get_history(self, ctx: commands.Command, *argv):
        historyJp = KujiUtil.getHistoryJp(ctx.author.id)
        historyCn = KujiUtil.getHistoryCn(ctx.author.id)
        historyLs = KujiUtil.getHistoryLs(ctx.author.id)
        if (-1, None) == historyJp and (-1, None) == historyLs and (
                -1, -1, None) == historyCn:
            await ctx.reply("親愛的員工, 你還沒抽過籤呢! 先試著抽一個看看?.")
        if not (-1, None) == historyLs:
            ls = LUNGSHAN[historyLs[0]]
            status = ls["status"]
            img = File(KujiUtil.getImageUrlLs(status),
                       filename=KujiUtil.getImageNameLs(status))
            await ctx.reply(file=img,
                            embed=KujiEmbed.createEmbededLs(
                                ls, datetime.now(),
                                f"{self.bot.user.name} - 抽籤遊戲"))

        if not (-1, None) == historyJp:
            kuji = OMIKUJI[historyJp[0]]
            imagePath = KujiUtil.generageImageForJp(KujiObj(kuji))
            img = File(imagePath, filename=KujiUtil.getKujiImageName())
            await ctx.reply(file=img,
                            embed=KujiEmbed.createEmbededJp(
                                kuji, historyJp[1],
                                f"{self.bot.user.name} - 抽籤遊戲"))

        if not (-1, -1, None) == historyCn:
            yi = KujiUtil.getTargetedYi(historyCn[0], historyCn[1])
            await ctx.reply(embed=KujiEmbed.createEmbededCn(
                yi, historyCn[2], f"{self.bot.user.name} - 抽籤遊戲"))
示例#2
0
 async def draw_jp(self, ctx: commands.Command, *argv):
     if not KujiUtil.canDrawJp(ctx.author.id):
         await ctx.reply("親愛的員工, 你今天已經抽過清水寺籤了哦! 每人一天只限一次.")
         return
     if not await self.checkToken(ctx):
         return
     random.seed(random.random())
     index = random.randint(0, 98)
     kuji = OMIKUJI[index]
     imagePath = KujiUtil.generageImageForJp(KujiObj(kuji))
     img = File(imagePath, filename=KujiUtil.getKujiImageName())
     await ctx.reply(file=img,
                     embed=KujiEmbed.createEmbededJp(
                         kuji, datetime.now(),
                         f"{self.bot.user.name} - 抽籤遊戲"))
     KujiUtil.updateMemberJp(ctx.author.id, index)
示例#3
0
 def createEmbededJp(kuji, timestamp, author: str):
     status = kuji["status"]
     title = KujiEmbed.getTitle(timestamp)
     imageUri = 'attachment://{}'.format(KujiUtil.getKujiImageName())
     title += "\n東京淺草觀音寺御神籤· {}籤 · {}".format(kuji["title"], status)
     description = "{}\n".format(kuji["poem_line1"])
     description += "`{}`\n".format(kuji["poem_line1_explain"])
     description += "{}\n".format(kuji["poem_line2"])
     description += "`{}`\n".format(kuji["poem_line2_explain"])
     description += "{}\n".format(kuji["poem_line3"])
     description += "`{}`\n".format(kuji["poem_line3_explain"])
     description += "{}\n".format(kuji["poem_line4"])
     description += "`{}`\n".format(kuji["poem_line4_explain"])
     embedMsg = Embed(title=title,
                      description=description,
                      color=KujiUtil.getColor(status))
     embedMsg.set_author(name=author)
     embedMsg.set_image(url=imageUri)
     payload = kuji["payload"]
     for key in payload:
         embedMsg.add_field(name=key, value=payload[key], inline=True)
     return embedMsg