Skip to content

Commit

Permalink
uptime: replace use of deprecated datetime.utcnow()
Browse files Browse the repository at this point in the history
  • Loading branch information
dgw committed Jun 3, 2023
1 parent 571444b commit ced222c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sopel/modules/uptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
"""
from __future__ import annotations

import datetime
from datetime import datetime, timedelta, timezone

from sopel import plugin


def setup(bot):
if "start_time" not in bot.memory:
bot.memory["start_time"] = datetime.datetime.utcnow()
bot.memory["start_time"] = datetime.now(timezone.utc)


@plugin.command('uptime')
@plugin.example('.uptime', user_help=True)
@plugin.output_prefix('[uptime] ')
def uptime(bot, trigger):
"""Return the uptime of Sopel."""
delta = datetime.timedelta(seconds=round((datetime.datetime.utcnow() -
bot.memory["start_time"])
.total_seconds()))
delta = timedelta(seconds=round((datetime.now(timezone.utc) -
bot.memory["start_time"])
.total_seconds()))
bot.say("I've been sitting here for {} and I keep going!".format(delta))

0 comments on commit ced222c

Please sign in to comment.