async def pigeon_retrieve(self, ctx): """Retrieve and check on your pigeon.""" pigeon = ctx.pigeon if pigeon.status == Pigeon.Status.idle: raise SendableException(ctx.translate("pigeon_idle")) embed = self.get_base_embed(ctx.guild) activity = pigeon.current_activity if activity is None: raise SendableException(ctx.translate("nothing_to_retrieve")) if isinstance(activity, Exploration): if activity.end_date_passed: retrieval = ExplorationRetrieval(activity) embed = retrieval.embed retrieval.commit() return asyncio.gather(ctx.send(embed=embed)) else: embed.description = f"**{pigeon.name}** is still on {pigeon.gender.get_posessive_pronoun()} way to explore!" embed.set_footer( text="Check back at", icon_url= "https://www.animatedimages.org/data/media/678/animated-pigeon-image-0045.gif" ) embed.timestamp = activity.end_date return asyncio.gather(ctx.send(embed=embed)) elif isinstance(activity, Mail): if activity.end_date_passed: retrieval = MailRetrieval(activity) embed = retrieval.embed retrieval.commit() Reminder.create(user_id=activity.recipient.user_id, channel_id=None, dm=True, text=ctx.translate("pigeon_inbox_unread_mail"), due_date=datetime.datetime.utcnow()) return asyncio.gather(ctx.send(embed=embed)) else: embed.description = f"**{pigeon.name}** is still on {pigeon.gender.get_posessive_pronoun()} way to send a message!" embed.set_footer( text="Check back at", icon_url= "https://www.animatedimages.org/data/media/678/animated-pigeon-image-0045.gif" ) embed.timestamp = activity.end_date return asyncio.gather(ctx.send(embed=embed))
def reminder(): return Reminder.create( user_name="user_name", tweet_id=1, created_on=date(2020, 10, 16), remind_on=date(2021, 1, 16), stock_symbol="AMZN", stock_price=2954.91, )
def reminder(): return Reminder.create( user_name="user_name", tweet_id=1, created_on=date(2020, 10, 16), remind_on=datetime(2021, 1, 16, 12, 0), stock_symbol="AMZN", stock_price=2954.91, is_finished=False, )
async def pigeon_explore(self, ctx): """Have your pigeon exploring countries.""" pigeon = ctx.pigeon human = ctx.human residence = human.country or Country.random() destination = Country.random() exploration = Exploration(residence=residence, destination=destination, pigeon=pigeon) exploration.end_date = exploration.start_date + datetime.timedelta( minutes=exploration.calculate_duration()) pigeon.status = Pigeon.Status.exploring pigeon.save() exploration.save() remind_emoji = "❗" embed = self.get_base_embed(ctx.guild) embed.description = "Okay. Your pigeon is now off to explore a random location!" embed.set_footer( text= f"React with {remind_emoji} to get reminded when available.\n'{ctx.prefix}pigeon retrieve' to check on your pigeon" ) message = await ctx.send(embed=embed) waiter = ReactionWaiter(ctx, message, emojis=(remind_emoji, ), members=(ctx.author, )) await waiter.add_reactions() emoji = await waiter.wait(remove=True) await waiter.clear_reactions() if emoji is not None: Reminder.create(user_id=ctx.author.id, channel_id=ctx.channel.id, text=ctx.translate("pigeon_ready_to_be_retrieved"), due_date=exploration.end_date) asyncio.gather(ctx.success(ctx.translate("reminder_created")))
async def pigeon_mail(self, ctx, user: discord.User): """Sending someone a letter.""" if user.id == ctx.author.id: raise SendableException(ctx.translate("cannot_send_to_self")) sender = ctx.pigeon await ctx.send(ctx.translate("check_dms")) ctx.channel = ctx.author.dm_channel if ctx.channel is None: ctx.channel = await ctx.author.create_dm() recipient = ctx.get_human(user=user) human = ctx.get_human() mail = Mail(recipient=recipient, sender=sender, read=False) await mail.editor_for(ctx, "message") await mail.editor_for(ctx, "gold", min=0, max=human.gold, skippable=True) waiter = ItemWaiter(ctx, prompt=ctx.translate("mail_item_prompt"), skippable=True) try: mail.item = await waiter.wait() except Skipped: pass if mail.item is not None: human_item, _ = HumanItem.get_or_create(item=mail.item, human=human) if human_item.amount < 1: raise SendableException(ctx.translate("item_not_found")) human_item.amount -= 1 human_item.save() mail.residence = human.country mail.destination = recipient.country mail.end_date = mail.start_date + datetime.timedelta( minutes=mail.calculate_duration()) human.gold -= mail.gold or 0 sender.status = Pigeon.Status.mailing mail.save() human.save() sender.save() remind_emoji = "❗" embed = self.get_base_embed(ctx.guild) embed.description = f"Okay. Your pigeon is off to send a package to {recipient.mention}!" embed.set_footer( text= f"React with {remind_emoji} to get reminded when available.\n'{ctx.prefix}pigeon retrieve' to check on your pigeon" ) message = await ctx.send(embed=embed) waiter = ReactionWaiter(ctx, message, emojis=(remind_emoji, ), members=(ctx.author, )) await waiter.add_reactions() emoji = await waiter.wait(remove=True) if emoji is not None: Reminder.create(user_id=ctx.author.id, channel_id=ctx.channel.id, text=ctx.translate("pigeon_ready_to_be_retrieved"), due_date=mail.end_date) asyncio.gather(ctx.success(ctx.translate("reminder_created")))