예제 #1
0
파일: c.py 프로젝트: kaaveland/munin
    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

        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 "+self.__class__.__name__+" command (log in with P and set mode +x)")
            return 1

        m=self.paramre.search(m.group(1))
        if not m:
            irc_msg.reply("Usage: %s" % (self.usage,))
            return 0

        # assign param variables
        call_id=m.group(1)
        new_comment=m.group(3)

        # do stuff here
        d=loadable.defcall(call_id)
        if not d.load_most_recent(self.cursor):
            irc_msg.reply("No defcall matching id %s found" %(call_id,))
            return 0

        c=d.comment

        if not new_comment:
            if not c:
                reply="Defcall %s has no comment"%(d.id,)
            else:
                reply="Defcall %s has comment '%s'"%(d.id,c)
            irc_msg.reply(reply)
            return 1

        query="UPDATE defcalls SET comment=%s WHERE id=%s"
        args=(new_comment,d.id)

        self.cursor.execute(query,args)

        if self.cursor.rowcount < 1:
            irc_msg.reply("Something went wrong. Defcall id was %s and new comment was '%s'"%(d.id,new_comment))
        else:
            p=d.actual_target
            irc_msg.reply("Updated defcall %s on %s:%s:%s landing pt %s with comment '%s'"%(d.id,p.x,p.y,p.z,d.landing_tick,new_comment))

        return 1
예제 #2
0
파일: s.py 프로젝트: kaaveland/munin
    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

        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 "+self.__class__.__name__+" command (log in with P and set mode +x)")
            return 1

        m=self.paramre.search(m.group(1))
        if not m:
            irc_msg.reply("Usage: %s" % (self.usage,))
            return 0

        # assign param variables
        call_id=m.group(1)
        s_command=m.group(3)

        # do stuff here
        d=loadable.defcall(call_id)
        if not d.load_most_recent(self.cursor):
            irc_msg.reply("No defcall matching id %s found" %(call_id,))
            return 0

        p=d.actual_target

        if not s_command:
            irc_msg.reply(str(d))
            return 1

        query="SELECT id, status FROM defcall_status WHERE status ilike %s"
        self.cursor.execute(query,(s_command+'%',))
        s=self.cursor.dictfetchone()
        if not s:
            irc_msg.reply("%s is not a valid defcall status, defcall was not modified"%(s_command,))
            return 0

        query="UPDATE defcalls SET status = %s,claimed_by=%s WHERE id = %s"
        print str(u.id)
        self.cursor.execute(query,(s['id'],user,d.id))
        if self.cursor.rowcount < 1:
            irc_msg.reply("Something went wrong. Old status was %s, new status was %s, defcall id was %s"%(old_status,s['status'],d.id))
        else:
            irc_msg.reply("Updated defcall %s on %s:%s:%s landing pt %s from status '%s' to '%s'"%(d.id,p.x,p.y,p.z,d.landing_tick,d.actual_status,s['status']))

        return 1
예제 #3
0
파일: i.py 프로젝트: kaaveland/munin
    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

        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 "+self.__class__.__name__+" command (log in with P and set mode +x)")
            return 1

        m=self.paramre.search(m.group(1))
        if not m:
            irc_msg.reply("Usage: %s" % (self.usage,))
            return 0

        # assign param variables
        call_id=m.group(1)

        # do stuff here
        d=loadable.defcall(call_id)
        if not d.load_most_recent(self.cursor):
            irc_msg.reply("No defcall matching id %s found" %(call_id,))
            return 0

        query="SELECT t1.id AS fleet_id, t4.id AS defcall_id"
        query+=", t2.race AS race, t2.x AS owner_x, t2.y AS owner_y, t2.z AS owner_z"
        query+=", t3.x AS target_x, t3.y AS target_y, t3.z AS target_z"
        query+=", t1.fleet_size AS fleet_size, t1.fleet_name AS fleet_name"
        query+=", t1.landing_tick AS landing_tick, t1.mission AS mission"
        query+=" FROM fleet AS t1"
        query+=" INNER JOIN planet_dump AS t2 ON t1.owner_id=t2.id"
        query+=" INNER JOIN planet_dump AS t3 ON t1.target=t3.id"
        query+=" INNER JOIN defcalls AS t4"
        query+=" ON t1.target=t4.target AND t1.landing_tick=t4.landing_tick"
        query+=" WHERE t2.tick = (SELECT max_tick()) AND t3.tick = (SELECT max_tick())"
        query+=" AND t4.id=%s"
        
        self.cursor.execute(query,(int(d.id),))

        if self.cursor.rowcount < 1:
            irc_msg.reply("No fleets found for defcall with ID '%s'"%(call_id,))
            return 1

        all=self.cursor.dictfetchall()
        reply="Fleets hitting %s:%s:%s as part of defcall %s"%(d.actual_target.x,
                                                               d.actual_target.y,
                                                               d.actual_target.z,
                                                               d.id)
        reply+=" with eta %d"%(d.landing_tick-self.current_tick(),)
        irc_msg.reply(reply)

        for s in all:
            reply="-> (id: %s) from %s:%s:%s (%s)"%(s['fleet_id'],s['owner_x'],s['owner_y'],s['owner_z'],s['race'])
            reply+=" named '%s' with %s ships set to %s"%(s['fleet_name'],s['fleet_size'],s['mission'])
            irc_msg.reply(reply)



        return 1