time.py 文件源码

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

项目:pcbot 作者: pckv 项目源码 文件源码
def create(message: discord.Message, tag: tag_arg, *time, timezone: tz_arg="UTC"):
    """ Create a countdown with the specified tag, using the same format as `{pre}when`. """
    assert tag not in time_cfg.data["countdown"], "Countdown with tag `{}` already exists.".format(tag)

    timezone_name = timezone
    dt, timezone = await init_dt(message, " ".join(time), timezone)

    seconds = int((dt - pendulum.now(tz=timezone)).total_seconds())
    assert seconds > 0, "A countdown has to be set in the future."

    cd = dict(time=dt.to_datetime_string(), tz=timezone, tz_name=timezone_name, tag=tag,
              author=message.author.id, channel=message.channel.id)
    time_cfg.data["countdown"][tag] = cd
    time_cfg.save()
    await client.say(message, "Added countdown with tag `{}`.".format(tag))

    client.loop.create_task(wait_for_reminder(cd, seconds))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号