2023-06-26 15:31:30 +00:00
#!/usr/bin/python3
import pinhook . plugin
import importlib
import subprocess
2024-02-13 10:22:26 +00:00
import util . tilde
2023-06-26 15:31:30 +00:00
@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 :
2024-02-13 10:22:26 +00:00
timecalc = int ( float ( usertime ) ) + util . tilde . WAIT_TIME - int ( float ( importlib . import_module ( ' time ' ) . time ( ) ) )
2023-06-26 15:31:30 +00:00
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 ) :
2024-10-27 11:12:50 +00:00
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) " )
2023-06-26 15:31:30 +00:00
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 ) ) )