mcpath = config.get('config', 'mcpath') mapurl = config.get('config', 'mapurl') helpurl = config.get('config', 'helpurl') screen = config.get('config', 'screen') gmail = config.get('config', 'gmail') gpw = config.get('config', 'gmailpw') mailrcvr = config.get('config', 'sendto') #### announce that i'm running #### action.connect(mchost, mcport, mcpwd) action.load(gmail, gpw, mailrcvr, screen) action.say("Minecraft Monitor Version "+version+" now running!", 1) action.say("Type !help for available commands", 0) ops = action.load_op(mcpath) #### check if enabled & op func #### def enabled(onoroff): try: setting = config.get('config', onoroff) except: setting = "disabled" print "NO setting entry for "+onoroff+", disabled." if "enabled" in setting: return True else: action.say("This command has been disabled!", 0) return False
def trigger(name): if "!sheen" in chatlog: if enabled("!sheen"): command.sheen() log.save(timestamp, "TEXT", "!sheen", name) elif "logged in with entity" in chatlog and not "CONSOLE" in chatlog: if enabled("login_manner"): player = command.login(chatlog) log.save(timestamp, "GREEN", "Login:"******"lost connection:" in chatlog and not "CONSOLE" in chatlog: if enabled("logout_manner"): player = command.logout(chatlog) log.save(timestamp, "RED", "Logout:", player) elif "!hax" in chatlog and not "[Rcon]" in chatlog: if enabled("!hax"): if check_op(name): command.hax(name) log.save(timestamp, "SYSTEM", "!hax", name) elif "!unhax" in chatlog and not "CONSOLE" in chatlog: if enabled("!unhax"): if check_op(name): command.unhax(name) log.save(timestamp, "SYSTEM", "!unhax", name) elif "!day" in chatlog: if enabled("!day"): command.day() log.save(timestamp, "SYSTEM", "!day", name) elif "!night" in chatlog: if enabled("!night"): command.night() log.save(timestamp, "SYSTEM", "!night", name) elif "!tp" in chatlog and not "CONSOLE" in chatlog: if enabled("!tp"): who = command.tp(name, chatlog) log.save2(timestamp, "TEXT", "!tp", name, "] [ -> ] [", who) elif "!pull" in chatlog and not "CONSOLE" in chatlog: if enabled("!pull"): if check_op(name): who = command.pull(name, chatlog) log.save2(timestamp, "TEXT", "!pull", name, "] [ <- ] [", who) elif "!map" in chatlog: if enabled("!map"): command.map(mapurl) log.save(timestamp, "SYSTEM", "!map", name) elif "!help" in chatlog: if enabled("!help"): command.help(helpurl) log.save(timestamp, "SYSTEM", "!help", name) elif "!version" in chatlog: action.say("Running MineMon version: " + version, 0) log.save(timestamp, "SYSTEM", "!version", name) elif "!list" in chatlog: action.say("Deprecated. Press <tab>", 0) elif "!roll" in chatlog and not "CONSOLE" in chatlog: if enabled("!roll"): roll = command.roll(name) log.save2(timestamp, "TEXT", "!roll", name, "] [", roll) elif "!rain" in chatlog and not "CONSOLE" in chatlog: if enabled("!rain"): command.rain() log.save(timestamp, "SYSTEM", "!rain", name) elif "!xp" in chatlog and not "CONSOLE" in chatlog: if enabled("!xp"): if check_op(name): command.xp(name) log.save(timestamp, "TEXT", "!xp", name) elif "!kit" in chatlog and not "CONSOLE" in chatlog: if enabled("!kit"): command.kit(name) log.save(timestamp, "TEXT", "!kit", name) elif "!leatherset" in chatlog and not "CONSOLE" in chatlog: if enabled("!leatherset"): command.leatherset(name) log.save(timestamp, "TEXT", "!leatherset", name) elif "!diamondset" in chatlog and not "CONSOLE" in chatlog: if enabled("!diamondset"): if check_op(name): command.diamondset(name) log.save(timestamp, "TEXT", "!diamondset", name) elif "!bow" in chatlog and not "CONSOLE" in chatlog: if enabled("!bow"): command.bow(name) log.save(timestamp, "TEXT", "!bow", name) elif "!train" in chatlog and not "CONSOLE" in chatlog: if enabled("!train"): command.train(name) log.save(timestamp, "TEXT", "!train", name) elif "!sleep" in chatlog and not "CONSOLE" in chatlog: if enabled("!sleep"): command.sleep(name) log.save(timestamp, "TEXT", "!sleep", name) elif "!rail" in chatlog and not "CONSOLE" in chatlog: if enabled("!rail"): command.rail(name) log.save(timestamp, "TEXT", "!rail", name) elif "!food" in chatlog and not "CONSOLE" in chatlog: if enabled("!food"): command.food(name) log.save(timestamp, "TEXT", "!food", name) elif "!item" in chatlog and not "[Rcon]" in chatlog: if enabled("!item"): if check_op(name): item = command.item(name, chatlog) log.save2(timestamp, "TEXT", "!item", name, "] [", item) elif "!restart" in chatlog and not "CONSOLE" in chatlog: if enabled("!restart"): if check_op(name): command.restart() log.save(timestamp, "SYSTEM", "!restart", name) elif "!monsters" in chatlog: if enabled("!monsters"): if check_op(name): onoff = command.monsters(mcpath) log.save2(timestamp, "SYSTEM", "!monsters", name, "] [", onoff) elif "!update" in chatlog: if enabled("!update"): if check_op(name) or "CONSOLE" in chatlog: status = command.update(mcpath, mcport) log.save2(timestamp, "SYSTEM", "!update", name, "] [", status) elif "!temphax" in chatlog and not "CONSOLE" in chatlog: action.say("not implemented yet gogo MYSQL", 0) elif "!report" in chatlog and not "CONSOLE" in chatlog: if enabled("!report"): command.mail(name, chatlog) log.save(timestamp, "SYSTEM", "!report", name) elif "Opping" in chatlog or "De-opping" in chatlog: global ops ops = action.load_op(mcpath) action.say("Detecting change in OP's, refreshing list!", 0) log.save(timestamp, "SYSTEM", "OP-refresh", "SYSTEM") elif "[INFO] Done (" in chatlog or "[INFO] RCON running on" in chatlog: print "< STARTING SERVER > - Reconnecting to rcon" action.connect(mchost, mcport, mcpwd) elif "[INFO] Saving chunks" in chatlog: print "< STOPPING SERVER >" #old non-supported commands elif "!tnt" in chatlog or "!stone" in chatlog or "!wood" in chatlog or "!dirt" in chatlog: action.say("Deprecated command. use !hax or !item", 0)
def trigger(name): global serverstop if "!help" in chatlog: if enabled("!help"): if check_op(name, "!help"): helpcmnd = command.help(helpurl, chatlog) log.save2(timestamp, "SYSTEM", "!help", name, "] [", helpcmnd) elif "!sheen" in chatlog: if enabled("!sheen"): if check_op(name, "!sheen"): command.sheen() log.save(timestamp, "TEXT", "!sheen", name) elif "joined the game" in chatlog and not "[Rcon]" in chatlog: if enabled("login_manner"): player = command.login(chatlog, v, helpurl) log.save(timestamp, "GREEN", "Login:"******"left the game" in chatlog and not "[Rcon]" in chatlog: if enabled("logout_manner"): player = command.logout(chatlog) log.save(timestamp, "RED", "Logout:", player) elif "!hax" in chatlog and not "[Rcon]" in chatlog: if enabled("!hax"): if check_op(name, "!hax"): command.hax(name) log.save(timestamp, "SYSTEM", "!hax", name) elif "!unhax" in chatlog and not "[Rcon]" in chatlog: if enabled("!unhax"): if check_op(name, "!unhax"): command.unhax(name) log.save(timestamp, "SYSTEM", "!unhax", name) elif "!adv" in chatlog and not "[Rcon]" in chatlog: if enabled("!adv"): if check_op(name, "!adv"): command.adv(name) log.save(timestamp, "SYSTEM", "!adv", name) elif "!day" in chatlog: if enabled("!day"): if check_op(name, "!day"): command.day() log.save(timestamp, "SYSTEM", "!day", name) elif "!night" in chatlog: if enabled("!night"): if check_op(name, "!night"): command.night() log.save(timestamp, "SYSTEM", "!night", name) elif "!tp" in chatlog and not "[Rcon]" in chatlog: if enabled("!tp"): if check_op(name, "!tp"): who = command.tp(name, chatlog) log.save2(timestamp, "TEXT", "!tp", name, "] -> [", who) elif "!pull" in chatlog and not "[Rcon]" in chatlog: if enabled("!pull"): if check_op(name, "!pull"): who = command.pull(name, chatlog) log.save2(timestamp, "TEXT", "!pull", name, "] <- [", who) elif "!map" in chatlog: if enabled("!map"): if check_op(name, "!map"): command.map(mapurl) log.save(timestamp, "SYSTEM", "!map", name) elif "!version" in chatlog and not "[Rcon]" in chatlog: if enabled("!version"): if check_op(name, "!version"): command.version(v) log.save(timestamp, "SYSTEM", "!version", name) elif "!list" in chatlog: action.say("Deprecated. Press Tab on your keyboard", 0) elif "!roll" in chatlog and not "[Rcon]" in chatlog: if enabled("!roll"): if check_op(name, "!roll"): roll = command.roll(name) log.save2(timestamp, "TEXT", "!roll", name, "] [", roll) elif "!rain" in chatlog and not "[Rcon]" in chatlog: if enabled("!rain"): if check_op(name, "!rain"): command.rain() log.save(timestamp, "SYSTEM", "!rain", name) elif "!xp" in chatlog and not "[Rcon]" in chatlog: if enabled("!xp"): if check_op(name, "!xp"): command.xp(name) log.save(timestamp, "TEXT", "!xp", name) elif "!kit" in chatlog and not "[Rcon]" in chatlog: if enabled("!kit"): if check_op(name, "!kit"): command.kit(name) log.save(timestamp, "TEXT", "!kit", name) elif "!leatherset" in chatlog and not "[Rcon]" in chatlog: if enabled("!leatherset"): if check_op(name, "!leatherset"): command.leatherset(name) log.save(timestamp, "TEXT", "!leatherset", name) elif "!diamondset" in chatlog and not "[Rcon]" in chatlog: if enabled("!diamondset"): if check_op(name, "!diamondset"): command.diamondset(name) log.save(timestamp, "TEXT", "!diamondset", name) elif "!bow" in chatlog and not "[Rcon]" in chatlog: if enabled("!bow"): if check_op(name, "!bow"): command.bow(name) log.save(timestamp, "TEXT", "!bow", name) elif "!train" in chatlog and not "[Rcon]" in chatlog: if enabled("!train"): if check_op(name, "!train"): command.train(name) log.save(timestamp, "TEXT", "!train", name) elif "!sleep" in chatlog and not "[Rcon]" in chatlog: if enabled("!sleep"): if check_op(name, "!sleep"): command.sleep(name) log.save(timestamp, "TEXT", "!sleep", name) elif "!rail" in chatlog and not "[Rcon]" in chatlog: if enabled("!rail"): if check_op(name, "!rail"): command.rail(name) log.save(timestamp, "TEXT", "!rail", name) elif "!food" in chatlog and not "[Rcon]" in chatlog: if enabled("!food"): if check_op(name, "!food"): command.food(name) log.save(timestamp, "TEXT", "!food", name) elif "!item" in chatlog and not "[Rcon]" in chatlog: if enabled("!item"): if check_op(name, "!item"): item = command.item(name, chatlog) log.save2(timestamp, "TEXT", "!item", name, "] [", item) elif "!restart" in chatlog and not "[Rcon]" in chatlog: if enabled("!restart"): if check_op(name, "!restart"): command.restart() log.save(timestamp, "SYSTEM", "!restart", name) elif "!monsters" in chatlog: if enabled("!monsters"): if check_op(name, "!monsters"): onoff = command.monsters(mcpath) log.save2(timestamp, "SYSTEM", "!monsters", name, "] [", onoff) elif "!update" in chatlog: if enabled("!update"): if check_op(name, "!update") or "Banned Player" in chatlog: status = command.update(mcpath, mcport) log.save2(timestamp, "SYSTEM", "!update", name, "] [", status) elif "!temphax" in chatlog and not "[Rcon]" in chatlog: if enabled("!temphax"): if check_op(name, "!temphax"): who = command.temphax(chatlog) log.save2(timestamp, "TEXT", "!temphax", name, "] -> [", who) elif "!report" in chatlog and not "[Rcon]" in chatlog: if enabled("!report"): if check_op(name, "!report"): command.mail(name, chatlog, False) log.save(timestamp, "SYSTEM", "!report", name) elif "!played" in chatlog and not "[Rcon]" in chatlog: if enabled("!played"): if check_op(name, "!played"): print "Checking played with name:"+ str(name) command.played(name) log.save(timestamp, "TEXT", "!played", name) elif "!world" in chatlog and not "[Rcon]" in chatlog: if enabled("!world"): if check_op(name, "!world"): success = command.world(name, chatlog, mcpath) if success: log.save2(timestamp, "SYSTEM", "!world", name, "] [", success) elif "!clear" in chatlog and not "[Rcon]" in chatlog: if enabled("!clear"): if check_op(name, "!clear"): command.clear(name) log.save(timestamp, "TEXT", "!clear", name) elif "!spawn" in chatlog and not "[Rcon]" in chatlog: if enabled("!spawn"): if check_op(name, "!spawn"): command.spawn(name) log.save(timestamp, "TEXT", "!spawn", name) elif "!gateway" in chatlog and not "[Rcon]" in chatlog: if enabled("!gateway"): if check_op(name, "!gateway"): gw = command.gateway(name, chatlog) log.save2(timestamp, "TEXT", "!gateway", name, gw[0], gw[1]) elif "!dial" in chatlog and not "[Rcon]" in chatlog: if enabled("!dial"): if check_op(name, "!dial"): dest = command.dial(name, chatlog) log.save2(timestamp, "TEXT", "!dial", name, "] -> [", dest) elif "!warp" in chatlog and not "[Rcon]" in chatlog: if enabled("!warp"): if check_op(name, "!warp"): dest = command.warp(name, chatlog) log.save2(timestamp, "TEXT", "!warp", name, "] -> [", dest) elif "Opped" in chatlog or "De-opped" in chatlog: global ops ops = action.load_op(mcpath) action.say("Detecting change in OP's, refreshing list!", 0) log.save(timestamp, "SYSTEM", "OP-refresh", "SYSTEM") elif "[INFO] Done (" in chatlog or "[INFO] RCON running on" in chatlog: print "< STARTING SERVER > - Reconnecting to rcon" action.connect(mchost, mcport, mcpwd) log.raw_log("< STARTING SERVER >") serverstop = False global timetrk if silent_enabled("timetrack"): timetrk=timetrack.playtime() timetrk.start() print "< Playtime-tracking started >" elif "[INFO] Saving chunks" in chatlog and serverstop == False: print "< STOPPING SERVER >" log.raw_log("< STOPPING SERVER >") serverstop = True if silent_enabled("timetrack"): try: timetrk.stop() while timetrk.isAlive(): time.sleep(1) del timetrk print "< Playtime-tracking stopped >" except: print "Could not stop timetrack!" log.raw_log("Could not stop timetrack!") #old non-supported commands elif "!tnt" in chatlog or "!stone" in chatlog or "!wood" in chatlog or "!dirt" in chatlog: action.say("Deprecated command. use !hax or !item", 0) # Un-commented since mc console now logs severe @ disconnect # elif "[SEVERE]" in chatlog or "(SourceFile:" in chatlog and not "<" in chatlog: # command.mail("SYSTEM", "MINECRAFT SEVERE EXCEPTION - TRYING TO RESTART", True) # action.say("§c[FATAL]: Minecraft Server encountered a serious error.", 4) # action.say("§c[WARNING] MineMon will try to restart the server as a precaution", 3) # time.sleep(2) # command.restart() elif "qwophidden" in chatlog: command.late() else: if '<' in chatlog: log.save_chat(name, chatlog)