Beispiel #1
0
    async def pt_delete(self, ctx, trigger_id: int):
        if self.data.get_price_trigger_author(trigger_id) != author_mention(ctx) and \
                not (ctx.message.author.id in DISCORD_ADMINS):
            await ctx.send(
                _('{mention} price trigger (ID:{trigger_id}) is not yours.').
                format(mention=author_mention(ctx), trigger_id=trigger_id))
            return

        self.data.delete_price_trigger(trigger_id)
        await ctx.send(
            _('{mention} price trigger {trigger_id} was deleted.').format(
                mention=author_mention(ctx), trigger_id=trigger_id))
Beispiel #2
0
 async def pt_list(self, ctx, *args):
     if args:
         await self.pt_list_other(ctx, args[0])
         return
     triggers = self.data.price_triggers(author_mention(ctx))
     triggers = '\n'.join(triggers)
     if triggers:
         await ctx.send(
             _('{mention} Your triggers are:\n{triggers}').format(
                 mention=author_mention(ctx), triggers=triggers))
     else:
         await ctx.send(
             _('{mention} You don\'t have any triggers.').format(
                 mention=author_mention(ctx)))
Beispiel #3
0
 async def pt_list_other(self, ctx, user_id):
     if ctx.message.author.id not in DISCORD_ADMINS:
         raise Exception(
             _('You don\'t have admin rights to use it for others.'))
     else:
         user_mention = "<@{user_id}>".format(user_id=user_id)
     user = self.data.get_user(user_mention)
     if not user:
         raise Exception(
             _('User_id({user_id}) was not found in DB.').format(
                 user_id=user_id))
     triggers = self.data.price_triggers(user_mention)
     triggers = '\n'.join(triggers)
     if triggers:
         await ctx.send(
             _('{mention} Triggers for user_id({user_id}) are:\n{triggers}'
               ).format(mention=author_mention(ctx),
                        user_id=user_id,
                        triggers=triggers))
     else:
         await ctx.send(
             _('{mention} User_id({user_id}) don\'t have any triggers.').
             format(mention=author_mention(ctx), user_id=user_id))
Beispiel #4
0
 async def pt_add(self, ctx, item_name: str, trigger_type: str, value: int):
     resolved_item_name = self.resolve_item_name(item_name)
     price_trigger = PriceTrigger(user_mention=author_mention(ctx),
                                  item_name=resolved_item_name,
                                  trigger_type=trigger_type,
                                  value=value,
                                  notified_datetime=now())
     self.data.add_price_trigger(price_trigger)
     price_point = self.data.get_item_last_price_point(resolved_item_name)
     await ctx.send(
         _('{mention} You will be notified when {trigger_description} {value:,} for {item_name}. '
           'Current price: {price:,}, volume: {volume:,}.').format(
               mention=author_mention(ctx),
               trigger_description=self.data.
               price_trigger_types[trigger_type].description,
               value=value,
               item_name=resolved_item_name,
               price=price_point.price,
               volume=price_point.volume))
     logging.info(
         'discord_server.Prices.price_trigger_add Price trigger {item_name} '
         'was added for {mention}.'.format(item_name=resolved_item_name,
                                           mention=author_mention(ctx)))
Beispiel #5
0
 async def price(self, ctx, *args):
     item_name = ' '.join(args)
     item_name = self.data.get_item_name(item_name)
     if item_name is not None:
         price_point = self.data.get_item_last_price_point(item_name)
         if price_point:
             await ctx.send(
                 _('{mention} Price: {price:,}, volume: {volume:,}, '
                   'date: {relevance:%d %b %Y %H:%M}').format(
                       mention=author_mention(ctx),
                       price=price_point.price,
                       volume=price_point.volume,
                       relevance=price_point.relevance))
         else:
             await ctx.send(
                 _('{mention} Price point for {item_name} was not found in DB'
                   ).format(item_name=item_name))
     else:
         await ctx.send(
             _('{mention} Item {item_name} was not found in DB').format(
                 item_name=item_name))
 async def att_set_error(self, ctx, error):
     await ctx.send('{mention} {error}'.format(mention=author_mention(ctx),
                                               error=error))
Beispiel #7
0
 async def pt_last_update(self, ctx):
     update_datetime = self.data.get_last_update_datetime()
     await ctx.send(
         _('{mention} Last update was at {update_datetime}.').format(
             mention=author_mention(ctx), update_datetime=update_datetime))
Beispiel #8
0
 async def pt_here(self, ctx):
     self.data.set_chat_id(author_mention(ctx), ctx.message.channel.id)
Beispiel #9
0
 async def pt_types(self, ctx):
     await ctx.send('{mention} {description}'.format(
         mention=author_mention(ctx),
         description=self.price_trigger_description()))
Beispiel #10
0
 async def price_trigger_add_error(self, ctx, error):
     await ctx.send('{mention} {error}'.format(mention=author_mention(ctx),
                                               error=error))