minerbot-phoenix/plugins/mainfunctions.py

56 lines
1.8 KiB
Python

import plugin, os
@plugin.listener("admin")
def admin(bot,channel,nick,msg):
if not bot.is_admin: 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()
@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())))