Пример #1
0
 async def refresh(self, sortie):
     em = EmbedTemplate(title="Sorties", timestamp=datetime.utcnow())
     count = 1
     for i in sortie.missions:
         em.add_field(name=f"Mission {count}", value=str(i))
         count += 1
     await self.message.edit(embed=em)
Пример #2
0
    async def refresh(self, nightwave_data):
        em = EmbedTemplate(title="Nightwave", timestamp=datetime.utcnow())
        for i in nightwave_data:
            em.add_field(name=i.name,
                         value=(Utilities.ts2string(i.start_time +
                                                    (60 * 120)) + "\n\n"))

        await self.message.edit(embed=em)
Пример #3
0
 def getEmbed(self, ) -> discord.Embed:
     em = EmbedTemplate(
         title="Crisscross",
         description=
         f"{self.player1[0].mention} :x: vs {self.player2[0].mention} :o:")
     em.add_field(name="Game",
                  value=str(self.map).replace("x", ":x:").replace(
                      "0", ":o:").replace("-", ":large_blue_diamond:"))
     return em
Пример #4
0
 async def refresh(self, newswire_data: list[NewswireItem]) -> None:
     em = EmbedTemplate(title="GTA V Newswire",
                        timestamp=datetime.utcnow(),
                        inline=False)
     x = 1
     for i in newswire_data:
         em.add_field(name=f"**{x}**. {i.title[:15]}...",
                      value=f"[Link]({i.url})\n\n[Image]({i.image})\n")
         x += 1
     await self.message.edit(embed=em)
Пример #5
0
 def relicSearch(self, searched_value):
     vals = self.searchKey("relicRewards", searched_value)
     if len(vals) == 1:
         em = EmbedTemplate(title=self.data["relicRewards"]["title"],
                            description=vals[0])
         for i, j in self.data["relicRewards"]["data"][vals[0]].items():
             em.add_field(name=i, value="\n".join(j))
         return em
     else:
         return EmbedTemplate(title=self.data["relicRewards"]["title"],
                              description="\n".join(vals))
Пример #6
0
 def get_embed(self, ) -> discord.Embed:
     em = EmbedTemplate(title=self.name.title(),
                        description=f"{self.description}\n\n{self.usage}")
     if self.stage_drop_list:
         sanity_costs = self.sanity_cost_per_stage()
         if sanity_costs:
             tmp = ""
             for i in sanity_costs:
                 stage, sanity_per_item, drop_rate = i
                 tmp += f"{stage.code} {sanity_per_item:.2f} Sanity/Item {drop_rate*100:.2f}%\n"
             em.add_field(name="Drop Rates", value=tmp)
     return em
Пример #7
0
 async def refresh(self, cetus):
     em = EmbedTemplate(title="Plains of Eidolon",
                        timestamp=datetime.utcnow())
     em.add_field(name="Status", value=str(cetus))
     em.add_field(
         name="Time until new rotation",
         value=f"{cetus.minutes_left() if cetus else 0.00:.0f} min")
     await self.message.edit(embed=em)
     if not self.lock:
         if cetus.isNight() and self.mention:
             self.lock = True
             self.notify_message = await self.message.channel.send(
                 f"{self.mention.name} - {self.mention.role.mention}")
             self.client.loop.call_later(cetus.seconds_left() + 60,
                                         self.callback)
Пример #8
0
 async def run(self, message: discord.Message, server: Server):
     parsed = self.args.parse(message.content)
     if parsed:
         tmp = list(self.database.runtime["gfl"]["dolls"]["names"].values())
         tmp = [x for x in tmp if x.production_timer]
         tmp_str = []
         for doll in sorted(tmp, key=lambda x: x.production_timer):
             tmp_str.append(
                 f"{datetime.timedelta(seconds=doll.production_timer)} {doll.name} {doll.doll_type}"
             )
         lists = [tmp_str[i:i + 30] for i in range(0, len(tmp_str), 30)]
         em = EmbedTemplate(title="Production Dolls")
         for i in lists:
             em.add_field(name="PRODUCTION",
                          value="\n".join(i),
                          inline=True)
         await message.channel.send(embed=em)
Пример #9
0
    async def refresh(self, invasions):
        em = EmbedTemplate(title="Invasions", timestamp=datetime.utcnow())
        for i in invasions:
            vals = []
            if type(i.node) == str:
                vals.append(f"{i.node.title()}, {i.node.title()}")
            else:
                vals.append(
                    f"{i.node.planet.name.title()}, {i.node.name.title()}")
            vals.append(i.start_time)
            vals.append(f"{i.defender.faction} vs {i.attacker.faction}"),
            vals.append(i.status)

            em.add_field(
                name=f"{i.defender.rewards} vs {i.attacker.rewards}",
                value=f"{vals[0]}\n{vals[1]}\n{vals[2]}\n{vals[3]}\n\u200b")
        await self.message.edit(embed=em)
Пример #10
0
    async def run(self, message: discord.Message, server: Server) -> None:
        def check_author(m: discord.Message):
            if message.author == m.author:
                return True
            return False

        parse = self.args.parse(message.content)
        if parse:
            table_name = parse['table_name']
            i = 1
            columns = []
            while True:
                em = EmbedTemplate(
                    title=f"Column {i}",
                    description=
                    f"syntax: \*column name\*:\*column type\*:\*extra detail\*\nExtra detail is for example, PRIMARY, not null etc.\nType 'END;' to stop"
                )
                em.add_field(
                    name="Data types",
                    value="https://www.postgresql.org/docs/9.5/datatype.html")
                await message.channel.send(embed=em)
                msg = await self.client.wait_for('message',
                                                 timeout=120.0,
                                                 check=check_author)
                if msg:
                    content = msg.content
                    if content == 'END;':
                        break
                    splitted = content.split(":")
                    merged = f"{' '.join(splitted)}"
                    columns.append(merged)
                    i += 1
                else:
                    break
            if columns:
                nl = ',\n'
                query = f"CREATE TABLE {table_name} IF NOT EXISTS (\n{f'{nl}'.join(columns)}\n);"
                sql = f"```sql\n{query}\n```"
                await message.channel.send(sql)
                await message.channel.send(
                    "Is this ok ? Y for Yes, anything for No")
                msg = await self.client.wait_for('message', timeout=60.0)
                if msg:
                    if "y" in msg.content.lower():
                        await self.database.query(query)
Пример #11
0
    async def run(self, message: discord.Message, server: Server) -> None:
        parse = self.args.parse(message.content)
        if parse:
            amount = int(parse['amount']) if parse['amount'] else 1
            banner = parse['banner']
            items = None
            if banner == "hunter":
                items = Banners.hunter()
            if amount > 500:
                amount = 500
            if items:
                sim = ProtocolAssimilationBanner(
                    ProtocolAssimilationBanner.MONTHLY_SVAROGS)
                sim.set_names(items)
                sim.set_prioritize([
                    "Manticore", "Nemeum",
                    ProtocolAssimilationBanner.PRIORITIZE_WEIGHT
                ])
                total_pulls = 0
                total_results = []
                for i in range(amount):
                    pulls, results = sim.run()
                    total_pulls += pulls
                    total_results.append(results)
                    sim.reset()
                combined_results, used_svarogs = self.combine_results(
                    total_results)
                total_svarogs = sim.svarog_tickets * amount

                em = EmbedTemplate(
                    title="Sim",
                    description=
                    f"Across {amount} banners, you got:\nTotal pulls: {total_pulls}\nTotal SVAROG tickets used: {used_svarogs}/{total_svarogs}"
                )
                for banner_item_name, banner_item_data in combined_results.items(
                ):
                    em.add_field(name=banner_item_name,
                                 value=f"""
                    {f"Svarogs: {banner_item_data['svarogs']}" if 'svarogs' in banner_item_data else ""}
                    {f"Failures: {banner_item_data['failures']}" if banner_item_data['failures'] > 0 else ""}
                    Successes: {banner_item_data['successes']}
                    Total: {banner_item_data['total']}
                    Got {banner_item_data['successes']}/{banner_item_data['item']._original_amount*amount}
                    """)
                await message.channel.send(embed=em)
Пример #12
0
 async def on_message(self, message):
     try:
         server = self.database.runtime.get("servers").get(message.guild.id)
         for key, module in self.commands.items():
             if message.content.startswith(module.command_key):
                 await module.parse(message, server)
                 break
         if server:
             if server.voice:
                 for i, f in server.voice.sounds.items():
                     if message.content == i:
                         await server.voice.playFile(f)
                         break
         if message.content.startswith(self.command_key+"help"):
             em = EmbedTemplate(title="Help", timestamp=datetime.utcnow())
             for name, commandset in self.commands.items():
                 em.add_field(name=f"{name.title()}", value=commandset.command_key+" help")
             await message.channel.send(embed=em)
     except Exception as e:
         log([f"[COMMANDS][{datetime.now().strftime('%Y-%m-%d, %H:%I:%S.%f')}] {e}", traceback.format_exc()+"\r\n"])
Пример #13
0
    async def run(self, message, server):
        def is_number(s):
            try:
                float(s.content)
                return True
            except ValueError:
                return False

        try:
            parse = self.parser.parse(message.content)
            if parse:
                await message.channel.send(embed=EmbedTemplate(
                    title="Probability", description="Amount of trials"))
                trials = await self.client.wait_for('message',
                                                    timeout=30.0,
                                                    check=is_number)
                await message.channel.send(embed=EmbedTemplate(
                    title="Probability", description="Chance (in %)"))
                chance = await self.client.wait_for('message',
                                                    timeout=30.0,
                                                    check=is_number)
                await message.channel.send(embed=EmbedTemplate(
                    title="Probability",
                    description="Wanted amount of successes"))
                successes = await self.client.wait_for('message',
                                                       timeout=30.0,
                                                       check=is_number)
                if trials and chance and successes:
                    successes = int(successes.content)
                    trials = int(trials.content)
                    chance = float(chance.content) / 100
                    em = EmbedTemplate(title='Probability',
                                       description="Calculated probability")
                    em.add_field(name="Trials", value=f"{trials}")
                    em.add_field(name="Successes", value=f"{successes}")
                    em.add_field(name="Chance", value=f"{chance}")
                    em.add_field(
                        name="Probability",
                        value=
                        f"{Math.exact_probability(trials, successes, chance)}")
                    await message.channel.send(embed=em)
        except asyncio.TimeoutError:
            await message.channel.send(embed=EmbedTemplate(
                title="Probability", description="Timed out"))
Пример #14
0
    def get_embed(self, ) -> discord.Embed:
        em = EmbedTemplate(title=self.name)
        if self.production_timer:
            em.add_field(
                name="Production Time",
                value=f"{datetime.timedelta(seconds=self.production_timer)}",
                inline=False)
        if self.stats:
            em.add_field(name="Stats", value="\n".join(self.stats))
        em.add_field(name="Skill", value=self.skill if self.skill else "N/A")

        return em
Пример #15
0
    def get_embed(self, ) -> discord.Embed:
        em = EmbedTemplate(title=self.name)
        if self.production_timer:
            em.add_field(
                name="Production Time",
                value=f"{datetime.timedelta(seconds=self.production_timer)}",
                inline=False)

        em.add_field(name="Skill", value=self.skill if self.skill else "N/A")
        if self.formation_bonus and self.formation_tiles:
            formation_tiles = self.formation_tiles.replace("0", "⬛").replace(
                "1", "⬜").replace("2", "🟦").replace("\\r\\n", "\r\n")
            formation_bonus = self.formation_bonus.replace("\\r\\n", "\r\n")
            em.add_field(name="Formation",
                         value=f"{formation_tiles}\n\n{formation_bonus}",
                         inline=False)
        return em
Пример #16
0
 async def refresh(self, fissures):
     em = EmbedTemplate(title="Fissures", timestamp=datetime.utcnow())
     for i in fissures:
         em.add_field(name=f"{i.era} {i.mission_type}", value=str(i))
     await self.message.edit(embed=em)