def execute(self,user,access,irc_msg): m=irc_msg.match_command(self.commandre) if not m: return 0 if access < self.level: irc_msg.reply("You do not have enough access to use this command") return 0 m=self.paramre.search(m.group(1)) if not m or not m.group(1): u=loadable.user(pnick=irc_msg.user) if not u.load_from_db(self.cursor): irc_msg.reply("Usage: %s (you must be registered for automatic lookup)" % (self.usage,)) return 1 if u.planet: reply=self.surprise(x=u.planet.x,y=u.planet.y,z=u.planet.z) irc_msg.reply(reply) else: irc_msg.reply("Usage: %s (you must be registered for automatic lookup)" % (self.usage,)) return 0 # assign param variables param=m.group(1) m=self.coordre.search(param) if m: x=m.group(1) y=m.group(2) z=m.group(4) if z: p=loadable.planet(x=x,y=y,z=z) if not p.load_most_recent(self.cursor): irc_msg.reply("No planet matching '%s' found"%(param,)) return 1 reply=self.surprise(x=p.x,y=p.y,z=p.z) irc_msg.reply(reply) return 1 else: g=loadable.galaxy(x=x,y=y) if not g.load_most_recent(self.cursor): irc_msg.reply("No galaxy matching '%s' found"%(param,)) return 1 reply=self.surprise(x=g.x,y=g.y) irc_msg.reply(reply) return 1 a=loadable.alliance(name=param.strip()) if not a.load_most_recent(self.cursor): irc_msg.reply("No alliance matching '%s' found" % (param,)) return 1 reply=self.surprise(alliance=a.name) irc_msg.reply(reply) return 1
def gal_info(self,x,y): g=loadable.galaxy(x=x,y=y) g.load_most_recent(self.cursor) return "Score (%d) Value (%d) Size (%d)"%(g.score_rank,g.value_rank,g.size_rank)
def execute(self,user,access,irc_msg): m=irc_msg.match_command(self.commandre) if not m: return 0 print access, irc_msg.access, irc_msg.target if access < self.level: irc_msg.reply("You do not have enough access to use this command") return 0 m=self.paramre.search(m.group(1)) if not m or not m.group(1): u=loadable.user(pnick=irc_msg.user) if not u.load_from_db(self.cursor): irc_msg.reply("You must be registered to use the automatic "+self.__class__.__name__+" command (log in with P and set mode +x, then make sure you've set your planet with the pref command)") return 1 if u.planet: irc_msg.reply(str(u.planet)) else: irc_msg.reply("Usage: %s" % (self.usage,)) return 1 param=m.group(1) m=self.coordre.search(param) if m: x=m.group(1) y=m.group(2) z=m.group(4) # assign param variables if z: p=loadable.planet(x=x,y=y,z=z) if not p.load_most_recent(self.cursor): irc_msg.reply("No planet matching '%s' found"%(param,)) return 1 irc_msg.reply(str(p)) return 1 else: g=loadable.galaxy(x=x,y=y) if not g.load_most_recent(self.cursor): irc_msg.reply("No galaxy matching '%s' found"%(param,)) return 1 irc_msg.reply(str(g)) return 1 #check if this is an alliance a=loadable.alliance(name=param.strip()) if a.load_most_recent(self.cursor): irc_msg.reply(str(a)) return u=self.load_user_from_pnick(param.strip()) if u and irc_msg.access >= 100: if u.planet: irc_msg.reply(str(u.planet)) else: irc_msg.reply("User %s has not entered their planet details" % (u.pnick,)) return irc_msg.reply("No alliance or user matching '%s' found" % (param,)) return # do stuff here return