Пример #1
0
    def post_message(self, command, args):
        # command = command.decode("UTF-8", errors="replace")
        if self.stopping:
            print("ignoring message", command, "because we're stopping")
            return
        # print("post_message", command, args)
        # self.on_message(command, args)
        # print(command, args)

        args = list(args)

        # for i, arg in enumerate(args):
        #     if arg is not None:
        #         args[i] = arg.decode("UTF-8", errors="replace")

        def func():
            # if IRC.broadcast(command, args):
            #     return
            if self.irc_server_message(command, args):
                return
            name = "irc_" + command
            try:
                method = getattr(self, name)
            except AttributeError:
                self.info(" ".join([command] + args))
                pass
            else:
                method(*args)

        call_after(func)
Пример #2
0
    def post_message(self, command, args):
        # command = command.decode("UTF-8", errors="replace")
        if self.stopping:
            print("ignoring message", command, "because we're stopping")
            return
        # print("post_message", command, args)
        # self.on_message(command, args)
        # print(command, args)

        args = list(args)

        # for i, arg in enumerate(args):
        #     if arg is not None:
        #         args[i] = arg.decode("UTF-8", errors="replace")

        def func():
            # if IRC.broadcast(command, args):
            #     return
            if self.irc_server_message(command, args):
                return
            name = "irc_" + command
            try:
                method = getattr(self, name)
            except AttributeError:
                self.info(" ".join([command] + args))
                pass
            else:
                method(*args)

        call_after(func)
Пример #3
0
    def irc_thread(self):
        try:
            self.irc_main()
        except Exception as e:
            def func():
                self.warning(repr(e))

            call_after(func)
            import traceback
            traceback.print_exc()
        self.running = False
Пример #4
0
    def irc_thread(self):
        try:
            self.irc_main()
        except Exception as e:

            def func():
                self.warning(repr(e))

            call_after(func)
            import traceback
            traceback.print_exc()
        self.running = False
Пример #5
0
    def set_host(self, host, last_error):
        if last_error:
            last_error = "attempt {1} {0}".format(last_error,
                                                  self.connection_attempt)
        values = [("__netplay_host", host),
                  ("__netplay_host_last_error", last_error)]
        if last_error or not host:
            # force not ready when we cannot connect to server
            values.append(("__netplay_ready", "0"))

        def function():
            LauncherConfig.set_multiple(values)

        call_after(function)
Пример #6
0
    def irc_thread(self):
        try:
            self.irc_main()
        except Exception as e:
            import traceback
            traceback.print_exc()
            # Bind exception to local variable, so the inline function below
            # can access it.
            exception = e

            def func():
                self.warning(repr(exception))

            call_after(func)
        self.running = False
Пример #7
0
    def irc_thread(self):
        try:
            self.irc_main()
        except Exception as e:
            import traceback
            traceback.print_exc()
            # Bind exception to local variable, so the inline function below
            # can access it.
            exception = e

            def func():
                self.warning(repr(exception))

            call_after(func)
        self.running = False
Пример #8
0
    def set_host(self, host, last_error):
        if last_error:
            last_error = "attempt {1} {0}".format(
                last_error, self.connection_attempt
            )
        values = [
            ("__netplay_host", host),
            ("__netplay_host_last_error", last_error),
        ]
        if last_error or not host:
            # force not ready when we cannot connect to server
            values.append(("__netplay_ready", "0"))

        def function():
            LauncherConfig.set_multiple(values)

        call_after(function)
Пример #9
0
    def irc_main(self):
        def func():
            self.message("connecting to {0}...".format(
                self.get_irc_server_host()))

        call_after(func)

        self.client = IRCClient(CommandHandler,
                                host=self.get_irc_server_host(),
                                port=6667,
                                nick=self.generate_nick(True),
                                blocking=True,
                                connect_cb=self.connect_callback)
        self.client.handler = self
        self.connection = self.client.connect()

        while not self.stopping:
            next(self.connection)
        print("irc_main done")
        self.running = False
Пример #10
0
    def irc_main(self):
        def func():
            self.message("connecting to {0}...".format(
                    self.get_irc_server_host()))

        call_after(func)

        self.client = IRCClient(
                CommandHandler,
                host=self.get_irc_server_host(),
                port=6667,
                nick=self.generate_nick(True),
                blocking=True,
                connect_cb=self.connect_callback)
        self.client.handler = self
        self.connection = self.client.connect()

        while not self.stopping:
            next(self.connection)
        print("irc_main done")
        self.running = False
Пример #11
0
    def connect_callback(self, client):
        def func():
            self.message("connected to {0}".format(self.get_irc_server_host()))

        call_after(func)
Пример #12
0
    def connect_callback(self, client):
        def func():
            self.message("connected to {0}".format(self.get_irc_server_host()))

        call_after(func)