This commit is contained in:
mrhanky
2017-05-16 13:44:39 +02:00
parent 6636d906fd
commit a86ee5e33d
5 changed files with 56 additions and 50 deletions

View File

@ -28,7 +28,5 @@ class Coins(Plugin):
'High: {bold}{color}{green}${high:,.2f}{reset} - '
'Low: {bold}{color}{maroon}${low:,.2f}{reset} - '
'Volume: {bold}฿{volume:,.2f}',
last=float(data['last']),
high=float(data['high']),
low=float(data['low']),
volume=float(data['volume']))
last=float(data['last']), high=float(data['high']),
low=float(data['low']), volume=float(data['volume']))

View File

@ -55,12 +55,8 @@ class CTCP(Plugin):
unit = 'ms'
else:
unit = 's'
reply = '{delta:.3f} {unit}'.format(
unit=unit, # 'ms' if delta < 0 else 's',
delta=delta)
return fmt('{bold}[PING]{reset} {nick}: {text}',
nick=nick,
text=reply)
reply = '{delta:.3f} {unit}'.format(unit=unit, delta=delta)
return fmt('{bold}[PING]{reset} {nick}: {text}', nick=nick, text=reply)
@command
async def finger(self, mask: IrcString, channel: IrcString,

View File

@ -21,9 +21,6 @@ class Futures(DatabasePlugin):
def __init__(self, bot: IrcBot):
super().__init__(bot)
self.restore()
def restore(self):
self.cur.execute('select * from timers')
for res in self.cur.fetchall():
delta = res['until'] - datetime.utcnow()
@ -33,7 +30,9 @@ class Futures(DatabasePlugin):
@command
def timer(self, mask: IrcString, channel: IrcString, args: DocOptDict):
"""Timer command.
"""Timer command, delay can be: s(econd), m(min), h(our), w(week),
mon(th), y(ear)
%%timer <delay> <message>...
"""
delay = args['<delay>']
@ -42,14 +41,15 @@ class Futures(DatabasePlugin):
date = datetime.utcnow() + delta
message = ' '.join(args['<message>'])
self.cur.execute('''insert into timers (mask, channel, message,
delay, until) values (?, ?, ?, ?, ?)''',
[mask.nick, channel, message, delay, date])
delay, until) values (?, ?, ?, ?, ?)''', [mask.nick, channel,
message, delay, date])
self.con.commit()
asyncio.ensure_future(self._timer(
mask, channel, delta, message, delay, self.cur.lastrowid))
asyncio.ensure_future(self._timer(mask, channel, delta, message,
delay, self.cur.lastrowid))
self.bot.notice(mask.nick, 'Timer in {delay} set: {message}'
.format(delay=delay, message=message))
else:
self.bot.notice(mask.nick, 'Invalid delay "{delay}" for "timer"'
.format(delay=args['<delay>']))
self.bot.privmsg(channel, 'Invalid timer delay')
async def _timer(self, mask: IrcString, channel: IrcString,
delta: timedelta, message: str, delay: str, row_id: int):
@ -60,10 +60,8 @@ class Futures(DatabasePlugin):
seconds = delta.total_seconds()
if seconds > 0:
await asyncio.sleep(seconds)
text = fmt('{bold}[Reminder]{reset} {nick}: {message} ({delay})',
message=message,
delay=delay,
nick=mask.nick)
text = fmt('{bold}[Timer]{reset} {nick}: {message} ({delay})',
message=message, delay=delay, nick=mask.nick)
self.bot.privmsg(channel, text)
self.cur.execute('delete from timers where id = ?', [row_id])
self.con.commit()