Plugins!
parent
d0cb0dffa0
commit
25741faa93
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import pinhook.plugin
|
||||
import util.tilde
|
||||
|
||||
@pinhook.plugin.command('&eval', help_text='Evaluates a string in the bot', ops=True, ops_msg='This command is ops only for safety reasons')
|
||||
def eval_cmd(msg):
|
||||
if msg.nick in msg.ops:
|
||||
try:
|
||||
def r(txt): msg.privmsg(msg.channel,str(txt))
|
||||
return pinhook.plugin.message(str(eval(msg.arg)))
|
||||
except Exception as e:
|
||||
return pinhook.plugin.message('error {}'.format(e))
|
||||
|
||||
@pinhook.plugin.command('&exec', help_text='Executes a string in the bot', ops=True, ops_msg='This command is ops only for safety reasons')
|
||||
def exec_cmd(msg):
|
||||
try:
|
||||
def r(txt): msg.privmsg(msg.channel,str(txt))
|
||||
exec(msg.arg)
|
||||
return False #pinhook.plugin.message('executed {}'.format(msg.arg))
|
||||
except Exception as e:
|
||||
return pinhook.plugin.message('error {}'.format(e))
|
|
@ -0,0 +1,24 @@
|
|||
from pinhook import plugin as p
|
||||
|
||||
@p.command('&echo', ops=True, help_text='Replies the current message to the current channel/user')
|
||||
def echo(msg):
|
||||
if msg.nick in msg.ops:
|
||||
return p.message(msg.arg)
|
||||
|
||||
@p.command('&ech', ops=True, help_text='Sends a message to a channel you specify')
|
||||
def echo(msg):
|
||||
if msg.nick in msg.ops:
|
||||
arg = msg.arg.split(' ')
|
||||
chan = arg[0]
|
||||
mesg = ' '.join(arg[1:])
|
||||
msg.privmsg(chan, mesg)
|
||||
return p.message(f'"{mesg}" sent to {chan}')
|
||||
|
||||
@p.command('&nech', ops=True, help_text='Sends a notice to a channel you specify')
|
||||
def notice(msg):
|
||||
if msg.nick in msg.ops:
|
||||
arg = msg.arg.split(' ')
|
||||
chan = arg[0]
|
||||
mesg = ' '.join(arg[1:])
|
||||
msg.notice(chan, mesg)
|
||||
return p.message(f'notice: "{mesg}" sent to {chan}')
|
|
@ -0,0 +1,124 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import pinhook.plugin
|
||||
import util.tilde
|
||||
import importlib
|
||||
import subprocess
|
||||
from random import randint
|
||||
from decimal import Decimal,ROUND_DOWN,ROUND_UP
|
||||
notifchan = '#ju-botlog'
|
||||
CTR = {}
|
||||
|
||||
@pinhook.plugin.command('&tildescore', help_text='See how many tildes you have with ju.')
|
||||
@pinhook.plugin.command('&ts', help_text='Alias -- &tildescore')
|
||||
def tildescore_plugin(msg):
|
||||
return pinhook.plugin.message(util.tilde.show_tildescore(msg.nick))
|
||||
|
||||
@pinhook.plugin.command('&jackpot', help_text='See the current jackpot.')
|
||||
def jackpot_plugin(msg):
|
||||
return pinhook.plugin.message(util.tilde.show_jackpot())
|
||||
|
||||
# ADMIN PLUGIN
|
||||
@pinhook.plugin.command('&tao', help_text='[Admin] Set the admin only mode', ops=True)
|
||||
def debug_plugin(msg):
|
||||
if msg.nick not in msg.ops:
|
||||
return
|
||||
if msg.arg:
|
||||
util.tilde.ADMIN_ONLY = (msg.arg.lower() == 'true' or msg.arg.lower() == 't')
|
||||
return pinhook.plugin.message("ADMIN_ONLY set to '{}'".format(util.tilde.ADMIN_ONLY))
|
||||
|
||||
# ADMIN PLUGIN
|
||||
@pinhook.plugin.command('&dbg', help_text='[Admin] Set the debug mode', ops=True)
|
||||
def debug_plugin(msg):
|
||||
if msg.nick not in msg.ops:
|
||||
return
|
||||
if msg.arg:
|
||||
util.tilde.DEBUG = (msg.arg.lower() == 'true' or msg.arg.lower() == 't')
|
||||
return pinhook.plugin.message("DEBUG set to '{}'".format(util.tilde.DEBUG))
|
||||
|
||||
# ADMIN PLUGIN
|
||||
@pinhook.plugin.command('&tsk', help_text='[Admin] Set the timeskip mode', ops=True)
|
||||
def timeskip_plugin(msg):
|
||||
if msg.nick not in msg.ops:
|
||||
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))
|
||||
|
||||
|
||||
# ADMIN PLUGIN
|
||||
@pinhook.plugin.command('&tilde_requests', help_text='[Admin] See the current requests for the jugame', ops=True)
|
||||
def tilde_requests_plugin(msg):
|
||||
if msg.nick not in msg.ops and not util.tilde.DEBUG:
|
||||
return
|
||||
return pinhook.plugin.message("Outstanding requests: {}".format(str(util.tilde.challenges)) if util.tilde.challenges else "(none)")
|
||||
|
||||
# ADMIN PLUGIN
|
||||
@pinhook.plugin.command('&delete_request', help_text='[Admin] Delete your jugame request', ops=True)
|
||||
def delete_tilde_request_plugin(msg):
|
||||
if (msg.nick not in msg.ops and not util.tilde.DEBUG) and (not msg.nick in util.tilde.challenges):
|
||||
return
|
||||
del util.tilde.challenges[msg.nick]
|
||||
return pinhook.plugin.message("Deleted")
|
||||
|
||||
@pinhook.plugin.command('!tilde', help_text='Alias -- &tilde')
|
||||
@pinhook.plugin.command('&tilde', help_text='Play the tildegame!')
|
||||
def tilde_plugin(msg):
|
||||
if util.tilde.ADMIN_ONLY and msg.nick not in msg.ops:
|
||||
return
|
||||
if msg.channel != util.tilde.GOOD_CHAN and not util.tilde.DEBUG:
|
||||
return pinhook.plugin.message("{} is a meanie and gets no tildes. **ju only gives out tildes in the {} channel.**".format(msg.nick, util.tilde.GOOD_CHAN))
|
||||
if msg.nick not in util.tilde.challenges:
|
||||
challenge = util.tilde.challenge(msg.channel, msg.nick, msg.timestamp)
|
||||
#return pinhook.plugin.message("{} (bonus {})".format(challenge,util.tilde.challenges[msg.nick][1]))
|
||||
return pinhook.plugin.message(challenge)
|
||||
|
||||
@pinhook.plugin.listener('tilde_guess')
|
||||
def tilde_guess_plugin(msg):
|
||||
if util.tilde.ADMIN_ONLY and msg.nick not in msg.ops:
|
||||
return
|
||||
if msg.nick in util.tilde.challenges and (msg.channel == util.tilde.GOOD_CHAN or util.tilde.DEBUG) and not msg.text.startswith('!'):
|
||||
chalres = util.tilde.challenge_response(msg.nick, msg.timestamp, msg.text)
|
||||
resp = pinhook.plugin.message(chalres[0])
|
||||
importlib.import_module('os').system('/home/jmjl/bin/juUpdate')
|
||||
if chalres[1][1] != 0: msg.privmsg(notifchan, f"({chalres[1][0]}) +{chalres[1][1]}")
|
||||
return resp
|
||||
|
||||
@pinhook.plugin.command('&brainwash', help_text='Alias -- &cleanwash')
|
||||
@pinhook.plugin.command('&cleanwash', help_text='Clean your dirty money.')
|
||||
def cleanwash_money(msg):
|
||||
if util.tilde.ADMIN_ONLY and msg.nick not in msg.ops:
|
||||
return
|
||||
if msg.channel != util.tilde.GOOD_CHAN and not util.tilde.DEBUG:
|
||||
return pinhook.plugin.message("{} is a meanie and gets no washed money. **ju only works in the {} channel.**".format(msg.nick, util.tilde.GOOD_CHAN))
|
||||
with open(util.tilde.SCORE_FILE, "r") as scorefile:
|
||||
time = 0
|
||||
scores = scorefile.readlines()
|
||||
for score in scores:
|
||||
name, score_on_file, timestamp = score.strip("\n").split("&^%")
|
||||
if name == msg.nick:
|
||||
time = int(timestamp.split('.')[0])
|
||||
if time == 0 or time <= 1000: return pinhook.plugin.message("You must waste your time with &tilde twice.")
|
||||
if util.tilde.too_recent(msg.timestamp, time) and not (util.tilde.DEBUG or util.tilde.TIMESKIP): return pinhook.plugin.message("You must wait until being able to use this again.")
|
||||
nick = msg.nick
|
||||
if msg.nick in msg.ops and msg.arg: nick = msg.arg
|
||||
balance = Decimal(subprocess.check_output(['/home/jmjl/bin/coin','Ju','internal_balance',nick],universal_newlines=True))
|
||||
subprocess.check_output(['/home/jmjl/bin/coin','Ju','add_internal_balance',nick,f'-{str(balance)}'],universal_newlines=True).strip()
|
||||
#new_balance=((__import__('random').randint(80,110)/100)*balance).split('.')[0]
|
||||
new_balance = Decimal(randint(80,110))/Decimal(100)*Decimal(balance)
|
||||
new_balance = new_balance.quantize(Decimal('1.'), rounding=ROUND_DOWN)
|
||||
#jackpot_balance=(0.10*balance).split('.')[0]
|
||||
jackpot_balance = (Decimal(0.10)*Decimal(balance)).quantize(Decimal('1.'), rounding=ROUND_DOWN)
|
||||
with open(util.tilde.JACKPOT_FILE, "r+") as jackpotfile:
|
||||
jackpot = int(jackpotfile.readline().strip("\n"))
|
||||
jackpotfile.seek(0)
|
||||
jackpotfile.truncate()
|
||||
jackpot_now = str(jackpot + jackpot_balance)
|
||||
jackpotfile.write(jackpot_now)
|
||||
message = f"Cleanwashed {balance}TCN, and given the user {new_balance}TCN and contributed {jackpot_balance}TCN to the balance, jackpot at {jackpot_now}TCN"
|
||||
util.tilde.admin_update_tilde(nick,amount=new_balance,time=msg.timestamp,comment=message)
|
||||
return pinhook.plugin.message(message)
|
|
@ -0,0 +1,64 @@
|
|||
|
||||
#!/usr/bin/python3
|
||||
import pinhook.plugin
|
||||
import util.tilde
|
||||
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
|
||||
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:
|
||||
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)
|
||||
#msg.nick, 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))
|
||||
#msg.nick, timecalc, '\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)
|
||||
#msg.nick, 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))
|
||||
#msg.nick, timecalc, '\u200b'.join(nicktouse)
|
||||
)
|
||||
else:
|
||||
return pinhook.plugin.message("{}: User not found in db (talking about {})".format(msg.nick, '\u200b'.join(nicktouse)))
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import pinhook.plugin
|
||||
import util.tilde
|
||||
import subprocess
|
||||
|
||||
@pinhook.plugin.command('&utilscore', ops=True, ops_msg='This command should only be used by ops', help_text='Shows how many tildecoins Util has')
|
||||
def utilscore(msg):
|
||||
bal = subprocess.check_output(['/home/jmjl/bin/coin','Util',f'-b{"d" if msg.arg else ""}']).decode('utf-8').split('\n')[0]
|
||||
return pinhook.plugin.message(bal)
|
Loading…
Reference in New Issue