예제 #1
0
파일: comms.py 프로젝트: Aumnren/evennia
    def func(self):
        "Send tell across IMC"

        if not settings.IMC2_ENABLED:
            string = """IMC is not enabled. You need to activate it in game/settings.py."""
            self.msg(string)
            return

        from src.comms.imc2 import IMC2_CLIENT

        if not self.args or not '@' in self.lhs or not self.rhs:
            string = "Usage: imctell User@Mud = <msg>"
            self.msg(string)
            return
        target, destination = self.lhs.split("@", 1)
        message = self.rhs.strip()
        data = {"target":target, "destination":destination}

        # send to imc2
        IMC2_CLIENT.msg_imc2(message, from_obj=self.caller, packet_type="imctell", **data)

        self.msg("You paged {c%s@%s{n (over IMC): '%s'." % (target, destination, message))
예제 #2
0
파일: comms.py 프로젝트: Aumnren/evennia
    def func(self):
        "Run the command"

        if not settings.IMC2_ENABLED:
            string = """IMC is not enabled. You need to activate it in game/settings.py."""
            self.msg(string)
            return

        if "update" in self.switches:
            # update the lists
            import time
            from src.comms.imc2lib import imc2_packets as pck
            from src.comms.imc2 import IMC2_MUDLIST, IMC2_CHANLIST, IMC2_CLIENT
            # update connected muds
            IMC2_CLIENT.send_packet(pck.IMC2PacketKeepAliveRequest())
            # prune inactive muds
            for name, mudinfo in IMC2_MUDLIST.mud_list.items():
                if time.time() - mudinfo.last_updated > 3599:
                    del IMC2_MUDLIST.mud_list[name]
            # update channel list
            IMC2_CLIENT.send_packet(pck.IMC2PacketIceRefresh())
            self.msg("IMC2 lists were re-synced.")

        elif("games" in self.switches or "muds" in self.switches
                                            or self.cmdstring == "@imclist"):
            # list muds
            from src.comms.imc2 import IMC2_MUDLIST

            muds = IMC2_MUDLIST.get_mud_list()
            networks = set(mud.networkname for mud in muds)
            string = ""
            nmuds = 0
            for network in networks:
                table = prettytable.PrettyTable(["Name", "Url", "Host", "Port"])
                for mud in (mud for mud in muds if mud.networkname == network):
                    nmuds += 1
                    table.add_row([mud.name, mud.url, mud.host, mud.port])
                string += "\n{wMuds registered on %s:{n\n%s" % (network, table)
            string += "\n %i Muds found." % nmuds
            self.msg(string)

        elif "whois" in self.switches or self.cmdstring == "@imcwhois":
            # find out about a player
            if not self.args:
                self.msg("Usage: @imcwhois <playername>")
                return
            from src.comms.imc2 import IMC2_CLIENT
            self.msg("Sending IMC whois request. If you receive no response, no matches were found.")
            IMC2_CLIENT.msg_imc2(None,
                                 from_obj=self.caller,
                                 packet_type="imcwhois",
                                 target=self.args)

        elif(not self.switches or "channels" in self.switches or
                                              self.cmdstring == "@imcchanlist"):
            # show channels
            from src.comms.imc2 import IMC2_CHANLIST, IMC2_CLIENT

            channels = IMC2_CHANLIST.get_channel_list()
            string = ""
            nchans = 0
            table = prettytable.PrettyTable(["Full name", "Name", "Owner", "Perm", "Policy"])
            for chan in channels:
                nchans += 1
                table.add_row([chan.name, chan.localname, chan.owner,
                               chan.level, chan.policy])
            string += "\n{wChannels on %s:{n\n%s" % (IMC2_CLIENT.factory.network, table)
            string += "\n%i Channels found." % nchans
            self.msg(string)
        else:
            # no valid inputs
            string = "Usage: imcinfo|imcchanlist|imclist"
            self.msg(string)
예제 #3
0
파일: comms.py 프로젝트: YourCyborg/Sun-RPI
    def func(self):
        "Run the command"

        if not settings.IMC2_ENABLED:
            string = """IMC is not enabled. You need to activate it in game/settings.py."""
            self.caller.msg(string)
            return

        if "update" in self.switches:
            # update the lists
            import time
            from src.comms.imc2lib import imc2_packets as pck
            from src.comms.imc2 import IMC2_MUDLIST, IMC2_CHANLIST, IMC2_CLIENT
            # update connected muds
            IMC2_CLIENT.send_packet(pck.IMC2PacketKeepAliveRequest())
            # prune inactive muds
            for name, mudinfo in IMC2_MUDLIST.mud_list.items():
                if time.time() - mudinfo.last_updated > 3599:
                    del IMC2_MUDLIST.mud_list[name]
            # update channel list
            IMC2_CLIENT.send_packet(pck.IMC2PacketIceRefresh())
            self.caller.msg("IMC2 lists were re-synced.")

        elif "games" in self.switches or "muds" in self.switches or self.cmdstring == "@imclist":
            # list muds
            from src.comms.imc2 import IMC2_MUDLIST

            muds = IMC2_MUDLIST.get_mud_list()
            networks = set(mud.networkname for mud in muds)
            string = ""
            nmuds = 0
            for network in networks:
                string += "\n {GMuds registered on %s:{n" % network
                cols = [["Name"], ["Url"], ["Host"], ["Port"]]
                for mud in (mud for mud in muds if mud.networkname == network):
                    nmuds += 1
                    cols[0].append(mud.name)
                    cols[1].append(mud.url)
                    cols[2].append(mud.host)
                    cols[3].append(mud.port)
                ftable = utils.format_table(cols)
                for ir, row in enumerate(ftable):
                    if ir == 0:
                        string += "\n{w" + "".join(row) + "{n"
                    else:
                        string += "\n" + "".join(row)
            string += "\n %i Muds found." % nmuds
            self.caller.msg(string)

        elif "whois" in self.switches or self.cmdstring == "@imcwhois":
            # find out about a player
            if not self.args:
                self.caller.msg("Usage: @imcwhois <playername>")
                return
            from src.comms.imc2 import IMC2_CLIENT
            self.caller.msg("Sending IMC whois request. If you receive no response, no matches were found.")
            IMC2_CLIENT.msg_imc2(None, from_obj=self.caller, packet_type="imcwhois", data={"target":self.args})

        elif not self.switches or "channels" in self.switches or self.cmdstring == "@imcchanlist":
            # show channels
            from src.comms.imc2 import IMC2_CHANLIST, IMC2_CLIENT

            channels = IMC2_CHANLIST.get_channel_list()
            string = ""
            nchans = 0
            string += "\n {GChannels on %s:{n" % IMC2_CLIENT.factory.network
            cols = [["Full name"], ["Name"], ["Owner"], ["Perm"], ["Policy"]]
            for channel in channels:
                nchans += 1
                cols[0].append(channel.name)
                cols[1].append(channel.localname)
                cols[2].append(channel.owner)
                cols[3].append(channel.level)
                cols[4].append(channel.policy)
            ftable = utils.format_table(cols)
            for ir, row in enumerate(ftable):
                if ir == 0:
                    string += "\n{w" + "".join(row) + "{n"
                else:
                    string += "\n" + "".join(row)
            string += "\n %i Channels found." % nchans
            self.caller.msg(string)

        else:
            # no valid inputs
            string = "Usage: imcinfo|imcchanlist|imclist"
            self.caller.msg(string)