Compare commits

...

3 Commits

Author SHA1 Message Date
jmjl 4f631e96fe Add the flaky last_tilde plugin
This commit adds the aftermentioned to be flaky last_tilde_answer
command and the lte alias.
2023-09-02 19:54:38 +00:00
jmjl 1d3622d0cb Tildewait do not inform timeskip state
It doesn't make sense for tildewait to show the timeskip state if it is
purposefully hidden from a file.
2023-09-02 17:38:09 +00:00
jmjl 44377a58e9 Timeskip do not write to file
This commit makes &tsk not write to a file.
This commit also changes tilde.py's permission to not be +x, as that's
not required for python.
2023-09-01 17:19:52 +00:00
3 changed files with 32 additions and 7 deletions

View File

@ -0,0 +1,29 @@
#!/usr/bin/python3
import pinhook.plugin
import util.tilde
import inspect
def err(msg): return pinhook.plugin.message(msg)
@pinhook.plugin.command('&lte', help_text='Alias -- &last_tilde_answer')
@pinhook.plugin.command('&last_tilde_answer', help_text='See the last_tilde\'s answer', ops=False, ops_msg='This command is admin-only as it\'s flaky, and a bit broken.')
def last_tilde(msg):
nick = msg.nick
pnick = msg.nick
if nick not in msg.ops:
retmsg = None
if not msg.arg: return err("This command is a bit flaky, if you accept that run this command again with a parameter called flaky, so run `&last_tilde flaky`")
if msg.arg and msg.arg != 'flaky': return err("This command maybe won't return what you expect, if you want to run it anyways pass a argument called `flaky`")
elif msg.arg: nick = msg.arg.split(' ')[0]
answer = None
try: data = util.tilde.old_challenges[nick][0]
except KeyError: return err("User hasn't played &tilde from the last boot.")
if callable(data):
data = inspect.getclosurevars(data).nonlocals
if len(data) == 0:
data = inspect.getsource(data)
if answer is None:
data = str(data)
answer = f"{pnick}'s last tilde's answer was supposed to be `{data}`."
return pinhook.plugin.message(answer)

4
plugins/tilde.py 100755 → 100644
View File

@ -43,10 +43,6 @@ def timeskip_plugin(msg):
return
if msg.arg:
util.tilde.TIMESKIP = (msg.arg.lower() == 'true' or msg.arg.lower() == 't')
with open(util.tilde.TIMESKIP_FILE, "r+") as timeskipfile:
timeskipfile.seek(0)
timeskipfile.truncate()
timeskipfile.write(str(util.tilde.TIMESKIP))
return pinhook.plugin.message("TIMESKIP set to '{}'".format(util.tilde.TIMESKIP))

View File

@ -1,7 +1,7 @@
#!/usr/bin/python3
import pinhook.plugin
import util.tilde
#import util.tilde
import importlib
import subprocess
@ -11,8 +11,8 @@ def tilde_wait(msg):
found = False
if msg.arg: nicktouse = ''.join(msg.arg.split(' '))
else: nicktouse = msg.nick
if util.tilde.TIMESKIP:
return pinhook.plugin.message(f"{msg.nick}: You don't have to wait, timeskip is on")
# if util.tilde.TIMESKIP:
# return pinhook.plugin.message(f"{msg.nick}: You don't have to wait, timeskip is on")
with open("/home/jmjl/dev/juju/data/tildescores.txt", "r") as scorefile:
scores = scorefile.readlines()
for score in scores: