59 lines
3.0 KiB
Python
59 lines
3.0 KiB
Python
#!/usr/bin/python3
|
|
import pinhook.plugin
|
|
import importlib
|
|
import subprocess
|
|
import util.tilde
|
|
|
|
@pinhook.plugin.command('&tw',help_text='Alias -- &tildewait')
|
|
@pinhook.plugin.command('&tildewait', help_text='See how much time you have to wait for ju\'s game')
|
|
def tilde_wait(msg):
|
|
found = False
|
|
if msg.arg: nicktouse = ''.join(msg.arg.split(' '))
|
|
else: nicktouse = msg.nick
|
|
with open("/home/jmjl/dev/juju/data/tildescores.txt", "r") as scorefile:
|
|
scores = scorefile.readlines()
|
|
for score in scores:
|
|
name, score_on_file, timestamp = score.strip("\n").split("&^%")
|
|
if name == nicktouse:
|
|
usertime = timestamp
|
|
found = True
|
|
if found:
|
|
timecalc = int(float(usertime)) + util.tilde.WAIT_TIME - int(float(importlib.import_module('time').time()))
|
|
if timecalc > 1:
|
|
return pinhook.plugin.message("{}: wait {} until playing again (talking about {})".format(
|
|
msg.nick, importlib.import_module('datetime').timedelta(seconds=timecalc), '\u200b'.join(nicktouse)
|
|
))
|
|
else:
|
|
return pinhook.plugin.message("{}: wasted {} time, *can play* (talking about {})".format(
|
|
msg.nick, importlib.import_module('datetime').timedelta(seconds=timecalc * -1), '\u200b'.join(nicktouse))
|
|
)
|
|
else:
|
|
return pinhook.plugin.message("{}: User not found in db (talking about {})".format(msg.nick, '\u200b'.join(nicktouse)))
|
|
|
|
@pinhook.plugin.command('!tw',help_text='Alias -- !tildewait')
|
|
@pinhook.plugin.command('!tildewait',help_text='See how much time you have to wait for tildebot, (obsolete)')
|
|
def tildebot_wait(msg):
|
|
return pinhook.plugin.message("Disabled, as tildebot is no longer running. Please contact the bot operator to re-enable when it comes back up, (probably never)")
|
|
found = False
|
|
if msg.arg: nicktouse = ''.join(msg.arg.split(' '))
|
|
else: nicktouse = msg.nick
|
|
with open("/home/krowbar/Code/irc/data/tildescores.txt", "r") as scorefile:
|
|
scores = scorefile.readlines()
|
|
for score in scores:
|
|
name, score_on_file, timestamp = score.strip("\n").split("&^%")
|
|
if name == nicktouse:
|
|
usertime = timestamp
|
|
found = True
|
|
if found:
|
|
timecalc = int(float(usertime)) + 60*60 - int(float(importlib.import_module('time').time()))
|
|
if timecalc > 1:
|
|
return pinhook.plugin.message("{}: wait {} until playing again (talking about {})".format(
|
|
msg.nick, importlib.import_module('datetime').timedelta(seconds=timecalc), '\u200b'.join(nicktouse)
|
|
))
|
|
else:
|
|
return pinhook.plugin.message("{}: wasted {} time, *can play* (talking about {})".format(
|
|
msg.nick, importlib.import_module('datetime').timedelta(seconds=timecalc * -1), '\u200b'.join(nicktouse))
|
|
)
|
|
else:
|
|
return pinhook.plugin.message("{}: User not found in db (talking about {})".format(msg.nick, '\u200b'.join(nicktouse)))
|