minerbot-phoenix/plugins/mainfunctions.py

78 lines
2.4 KiB
Python

import plugin, os
try:
with open(os.path.expanduser("~/minerbot.admins")) as f:
BOT_NICKS = [l.strip() for l in f if l.strip()]
except:
BOT_NICKS = ["minerobber"]
@plugin.listener("admin")
def admin(bot,channel,nick,msg):
if nick not in BOT_NICKS: return
if not msg.startswith(bot.nick+": "): return
args = msg[len(bot.nick)+2:].split()
subcmd = args.pop(0)
if subcmd=="down":
bot._bot.die("Stopping...")
elif subcmd=="reload":
bot.load_modules()
elif subcmd=="nick":
bot._bot.conn.nick(args[0])
bot.nick = args[0]
elif subcmd=="prefix":
bot.prefix = args[0]
elif subcmd=="minercoin":
subsubcmd = args.pop(0)
if subsubcmd=="reset":
value = args.pop(0)
if value=="all" or value=="times":
os.remove("times.json")
if value=="all" or value=="challenges":
os.remove("challenges.json")
if value=="all" or value=="scores":
os.remove("minercoin.json")
bot.load_module("minercoin","plugins/minercoin.py")
elif subsubcmd=="reload":
bot.load_module("minercoin","plugins/minercoin.py")
elif subcmd=="pull":
subprocess.run("git pull",shell=True)
bot.load_modules()
elif subcmd=="add":
BOT_NICKS.append(args.pop(0))
elif subcmd=="del":
BOT_NICKS.remove(args.pop(0))
@plugin.listener("water_joke")
def water_joke(bot,channel,nick,msg):
if msg.startswith("!water minerbot"):
bot.say(channel,"{}: BZZ-ZAP! Please don't water me! I'm not waterproofed yet!!!!! BZZ-BZZ-ZZZ-ZAP!".format(nick))
@plugin.command("rollcall")
def rollcall(bot,channel,nick,*args):
bot.say(channel,nick+": Hi! I'm minerbot! Commands: {}".format(", ".join("!"+cmd for cmd in plugin.cmds if cmd!=bot.cmd)))
@plugin.listener("rollcall")
def rollcall_listen(bot,channel,nick,msg):
if bot.prefix!="!" and msg.startswith("!rollcall"):
rollcall(bot,channel,nick,*list())
@plugin.command("minerbotsrc")
def minerbotsrc(bot,channel,nick,*args):
bot.say(channel,nick+": https://tildegit.org/khuxkm/minerbot-phoenix")
@plugin.command("minerbothelp")
def help(bot,channel,nick,*args):
bot.say(channel,nick+": currently loaded commands: {}".format(", ".join("!"+cmd for cmd in plugin.cmds.keys())))
@plugin.command("minomad","<GO AWAY DINKLEBERG>")
def minomad(bot,channel,nick,*args):
if nick not in BOT_NICKS: return
args = list(args)
command = args.pop(0)
if command == "join":
for channel in args:
bot._bot.conn.join(channel)
elif command == "part":
for channel in args:
bot._bot.conn.part(channel,"Leaving...")