57 lines
2.8 KiB
Python
57 lines
2.8 KiB
Python
|
#!/usr/bin/python3
|
||
|
import pinhook.plugin
|
||
|
import importlib
|
||
|
import subprocess
|
||
|
|
||
|
@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)) + 60*60*4 - 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):
|
||
|
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)))
|