示例#1
0
 def action(self, user, channel, msg):
     if not check_irc_with_pso2(msg):
         return
     if channel == self.factory.channel:
         if self.ircOutput is True:
             print("[GlobalChat] [Discord] * %s %s" %
                   (user, replace_irc_with_pso2(msg).decode(
                       'utf-8', 'ignore')))
         for client in data.clients.connectedClients.values():
             if client.preferences.get_preference(
                     'globalChat') and client.get_handle() is not None:
                 if lookup_gchatmode(client.preferences) == 0:
                     client.get_handle().send_crypto_packet(
                         packetFactory.TeamChatPacket(
                             self.get_user_id(user.split("!")[0]),
                             "[Discord] %s" % user.split("!")[0],
                             "[Discord] %s" % user.split("!")[0],
                             "* %s%s" %
                             (client.preferences.get_preference(
                                 'globalChatPrefix'),
                              replace_irc_with_pso2(msg).decode(
                                  'utf-8', 'ignore'))).build())
                 else:
                     client.get_handle().send_crypto_packet(
                         packetFactory.SystemMessagePacket(
                             "[Discord] <%s> * %s" %
                             (user.split("!")[0], "%s%s" %
                              (client.preferences.get_preference(
                                  'globalChatPrefix'),
                               replace_irc_with_pso2(msg).decode(
                                   'utf-8', 'ignore'))), 0x3).build())
示例#2
0
def doRedisGchat(message):
    gchatMsg = json.loads(message['data'])
    fb = ("G-%02i") % gchatMsg['ship']
    shipl = ShipLabel.get(fb, fb)
    strgchatmsg = str(gchatMsg['text'].encode('utf-8'))
    if not check_irc_with_pso2(strgchatmsg):
        return
    if gchatMsg['server'] == PSO2PDConnector.connector_conf['server_name']:
        return
    if gchatMsg['sender'] == 1:
        for client in data.clients.connectedClients.values():
            if client.preferences.get_preference('globalChat') and client.get_handle() is not None:
                if lookup_gchatmode(client.preferences) == 0:
                    client.get_handle().send_crypto_packet(packetFactory.TeamChatPacket(gchatMsg['playerId'], "[GIRC] %s" % gchatMsg['playerName'], "[GIRC] %s" % gchatMsg['playerName'], "%s%s" % (client.preferences.get_preference('globalChatPrefix'), replace_irc_with_pso2(strgchatmsg).decode('utf-8', 'ignore'))).build())
                else:
                    client.get_handle().send_crypto_packet(packetFactory.SystemMessagePacket("[GIRC] <%s> %s" % (gchatMsg['playerName'], "%s%s" % (client.preferences.get_preference('globalChatPrefix'), replace_irc_with_pso2(strgchatmsg).decode('utf-8', 'ignore'))), 0x3).build())
    else:
        if ircMode:
                global ircBot
                if ircBot is not None:
                    ircBot.send_global_message(gchatMsg['ship'], str(gchatMsg['playerName'].encode('utf-8')), strgchatmsg, str(gchatMsg['server']))
        for client_data in data.clients.connectedClients.values():
                if client_data.preferences.get_preference('globalChat') and client_data.get_handle() is not None:
                    if lookup_gchatmode(client_data.preferences) == 0:
                        client_data.get_handle().send_crypto_packet(packetFactory.TeamChatPacket(gchatMsg['playerId'], "(%s) [%s] %s" % (gchatMsg['server'], shipl, gchatMsg['playerName']), gchatMsg['playerName'], "%s%s" % (client_data.preferences.get_preference('globalChatPrefix'), gchatMsg['text'])).build())
                    else:
                        client_data.get_handle().send_crypto_packet(packetFactory.SystemMessagePacket("(%s) [%s] <%s> %s" % (gchatMsg['server'], shipl, gchatMsg['playerName'], "%s%s" % (client_data.preferences.get_preference('globalChatPrefix'), gchatMsg['text'])), 0x3).build())
示例#3
0
 def action(self, user, channel, msg):
     if not check_irc_with_pso2(msg):
         return
     if channel == self.factory.channel:
         if self.ircOutput is True:
             print("[GlobalChat] [IRC] * %s %s" % (user, replace_irc_with_pso2(msg).decode('utf-8', 'ignore')))
         for client in data.clients.connectedClients.values():
             if client.preferences.get_preference('globalChat') and client.get_handle() is not None:
                 if lookup_gchatmode(client.preferences) == 0:
                     client.get_handle().send_crypto_packet(
                         packetFactory.TeamChatPacket(
                             self.get_user_id(
                                 user.split("!")[0]
                             ),
                             u"[GIRC] %s" % user.split("!")[0],
                             u"[GIRC] %s" % user.split("!")[0],
                             u"* %s%s" % (
                                 client.preferences.get_preference('globalChatPrefix'),
                                 replace_irc_with_pso2(msg).decode('utf-8', 'ignore')
                             )
                         ).build()
                     )
                 else:
                     client.get_handle().send_crypto_packet(
                         packetFactory.SystemMessagePacket(
                             u"[GIRC] <%s> * %s" % (
                                 user.split("!")[0],
                                 u"%s%s" % (
                                     client.preferences.get_preference('globalChatPrefix'),
                                     replace_irc_with_pso2(msg).decode('utf-8', 'ignore')
                                 )
                             ),
                             0x3
                         ).build()
                     )
示例#4
0
def doRedisGchat(message):
    gchatMsg = json.loads(message['data'])
    fb = ("G-%02i") % gchatMsg['ship']
    shipl = ShipLabel.get(fb, fb)
    strgchatmsg = str(gchatMsg['text'].encode('utf-8'))
    if not check_irc_with_pso2(strgchatmsg):
        return
    if gchatMsg['server'] == PSO2PDConnector.connector_conf['server_name']:
        return
    if gchatMsg['sender'] == 1:
        for client in data.clients.connectedClients.values():
            if client.preferences.get_preference('globalChat') and client.get_handle() is not None:
                if lookup_gchatmode(client.preferences) == 0:
                    client.get_handle().send_crypto_packet(packetFactory.TeamChatPacket(gchatMsg['playerId'], "[GIRC] %s" % gchatMsg['playerName'], "[GIRC] %s" % gchatMsg['playerName'], "%s%s" % (client.preferences.get_preference('globalChatPrefix'), replace_irc_with_pso2(strgchatmsg).decode('utf-8'))).build())
                else:
                    client.get_handle().send_crypto_packet(packetFactory.SystemMessagePacket("[GIRC] <%s> %s" % (gchatMsg['playerName'], "%s%s" % (client.preferences.get_preference('globalChatPrefix'), replace_irc_with_pso2(strgchatmsg).decode('utf-8'))), 0x3).build())
    else:
        if ircMode:
                global ircBot
                if ircBot is not None:
                    ircBot.send_global_message(gchatMsg['ship'], str(gchatMsg['playerName'].encode('utf-8')), strgchatmsg, str(gchatMsg['server']))
        for client_data in data.clients.connectedClients.values():
                if client_data.preferences.get_preference('globalChat') and client_data.get_handle() is not None:
                    if lookup_gchatmode(client_data.preferences) == 0:
                        client_data.get_handle().send_crypto_packet(packetFactory.TeamChatPacket(gchatMsg['playerId'], "(%s) [%s] %s" % (gchatMsg['server'], shipl, gchatMsg['playerName']), gchatMsg['playerName'], "%s%s" % (client_data.preferences.get_preference('globalChatPrefix'), gchatMsg['text'])).build())
                    else:
                        client_data.get_handle().send_crypto_packet(packetFactory.SystemMessagePacket("(%s) [%s] <%s> %s" % (gchatMsg['server'], shipl, gchatMsg['playerName'], "%s%s" % (client_data.preferences.get_preference('globalChatPrefix'), gchatMsg['text'])), 0x3).build())
示例#5
0
 def action(self, user, channel, msg):
     if not check_irc_with_pso2(msg):
         return
     if channel == self.factory.channel:
         if self.ircOutput is True:
             print("[GlobalChat] [Discord] * %s %s" % (user, replace_irc_with_pso2(msg).decode('utf-8', 'ignore')))
         for client in data.clients.connectedClients.values():
             if client.preferences.get_preference('globalChat') and client.get_handle() is not None:
                 if lookup_gchatmode(client.preferences) == 0:
示例#6
0
 def privmsg(self, user, channel, msg):
     if not check_irc_with_pso2(msg):
         return
     if channel == self.factory.channel:
         if "title: [Ship " in msg:
             self.nickbuf = user
             self.nickmsgbuf = msg.replace("title: ", "", 1)
             return
         elif "title: " in msg and "title: [Ship " not in msg:
             self.nickbuf = None
         if self.nickbuf == user:
             msg = msg.replace("description: ", "", 1)
         if self.ircOutput is True:
示例#7
0
 def privmsg(self, user, channel, msg):
     if not check_irc_with_pso2(msg):
         return
     if channel == self.factory.channel:
         if self.ircOutput is True:
             print(
                 "[GlobalChat] [Discord] <%s> %s" %
                 (user.split("!")[0], replace_irc_with_pso2(msg).decode(
                     'utf-8', 'ignore')))
         if redisEnabled:
             PSO2PDConnector.db_conn.publish(
                 "plugin-message-gchat",
                 json.dumps({
                     'sender':
                     1,
                     'text':
                     replace_irc_with_pso2(msg).decode(
                         'utf-8', 'ignore'),
                     'server':
                     PSO2PDConnector.connector_conf['server_name'],
                     'playerName':
                     user.split("!")[0],
                     'playerId':
                     self.get_user_id(user.split("!")[0])
                 }))
         for client in data.clients.connectedClients.values():
             if client.preferences.get_preference(
                     'globalChat') and client.get_handle() is not None:
                 if lookup_gchatmode(client.preferences) == 0:
                     client.get_handle().send_crypto_packet(
                         packetFactory.TeamChatPacket(
                             self.get_user_id(user.split("!")[0]),
                             "[Discord] %s" % user.split("!")[0],
                             "[Discord] %s" % user.split("!")[0],
                             "%s%s" %
                             (client.preferences.get_preference(
                                 'globalChatPrefix'),
                              replace_irc_with_pso2(msg).decode(
                                  'utf-8', 'ignore'))).build())
                 else:
                     client.get_handle().send_crypto_packet(
                         packetFactory.SystemMessagePacket(
                             "[Discord] <%s> %s" %
                             (user.split("!")[0], "%s%s" %
                              (client.preferences.get_preference(
                                  'globalChatPrefix'),
                               replace_irc_with_pso2(msg).decode(
                                   'utf-8', 'ignore'))), 0x3).build())
     else:
         print("[Discord] <%s> %s" % (user, msg))
示例#8
0
 def privmsg(self, user, channel, msg):
     if not check_irc_with_pso2(msg):
         return
     if channel == self.factory.channel:
         if self.ircOutput is True:
             print("[GlobalChat] [IRC] <%s> %s" % (user.split("!")[0], replace_irc_with_pso2(msg).decode('utf-8', 'ignore')))
         if redisEnabled:
             PSO2PDConnector.db_conn.publish("plugin-message-gchat", json.dumps({'sender': 1, 'text': replace_irc_with_pso2(msg).decode('utf-8', 'ignore'), 'server': PSO2PDConnector.connector_conf['server_name'], 'playerName': user.split("!")[0], 'playerId': self.get_user_id(user.split("!")[0])}))
         for client in data.clients.connectedClients.values():
             if client.preferences.get_preference('globalChat') and client.get_handle() is not None:
                 if lookup_gchatmode(client.preferences) == 0:
                     client.get_handle().send_crypto_packet(packetFactory.TeamChatPacket(self.get_user_id(user.split("!")[0]), "[GIRC] %s" % user.split("!")[0], "[GIRC] %s" % user.split("!")[0], "%s%s" % (client.preferences.get_preference('globalChatPrefix'), replace_irc_with_pso2(msg).decode('utf-8', 'ignore'))).build())
                 else:
                     client.get_handle().send_crypto_packet(packetFactory.SystemMessagePacket("[GIRC] <%s> %s" % (user.split("!")[0], "%s%s" % (client.preferences.get_preference('globalChatPrefix'), replace_irc_with_pso2(msg).decode('utf-8', 'ignore'))), 0x3).build())
     else:
         print("[IRC] <%s> %s" % (user, msg))
示例#9
0
        def privmsg(self, user, channel, msg):
            if not check_irc_with_pso2(msg):
                return
            if channel == self.factory.channel:
                if "title: [Ship " in msg:
                    self.nickbuf = user
                    self.nickmsgbuf = msg.replace("title: ", "", 1)
                    return
                elif "title: " in msg and "title: [Ship " not in msg:
                    self.nickbuf = None
                if self.nickbuf == user:
                    msg = msg.replace("description: ", "", 1)
                if self.ircOutput is True:
                    if self.nickbuf == user:
                        print(
                            "[GlobalChat] [IRC] <{}> {}".format(
                                self.nickmsgbuf.split("] ")[1],
                                replace_irc_with_pso2(msg).decode('utf-8', 'ignore')
                            )
                        )
                    else:
                        print(
                            "[GlobalChat] [IRC] <{}> {}".format(
                                user.split("!")[0],
                                replace_irc_with_pso2(msg).decode('utf-8', 'ignore')
                            )
                        )
                if redisEnabled:
                    if self.nickbuf == user:
                        PSO2PDConnector.db_conn.publish(
                            "plugin-message-gchat",
                            json.dumps(
                                {
                                    'sender': 1,
                                    'text': replace_irc_with_pso2(msg).decode('utf-8', 'ignore'),
                                    'server': PSO2PDConnector.connector_conf['server_name'], 'playerName': self.nickmsgbuf,
                                    'playerId': self.get_user_id(self.nickmsgbuf),
                                    'ship': "GIRC"
                                }
                            )
                        )
                    else:
                        PSO2PDConnector.db_conn.publish(
                            "plugin-message-gchat",
                            json.dumps(
                                {
                                    'sender': 1,
                                    'text': replace_irc_with_pso2(msg).decode('utf-8', 'ignore'),
                                    'server': PSO2PDConnector.connector_conf['server_name'],
                                    'playerName': user.split("!")[0],
                                    'playerId': self.get_user_id(user.split("!")[0]), 'ship': "GIRC"
                                }
                            )
                        )
                for client in data.clients.connectedClients.values():

                    if discord and self.nickbuf == user:
                        nickmsg = self.nickmsgbuf.split(":")[0]
                    else:
                        nickmsg = user.split("!")[0]
                    pso2msg = replace_irc_with_pso2(msg).decode('utf-8', 'ignore')
                    if client.preferences.get_preference('globalChat') and client.get_handle() is not None:
                        if lookup_gchatmode(client.preferences) == 0:
                            client.get_handle().send_crypto_packet(
                                packetFactory.TeamChatPacket(
                                    self.get_user_id(nickmsg),
                                    u"[GIRC] %s" % nickmsg,
                                    u"[GIRC] %s" % nickmsg,
                                    u"%s%s" % (
                                        client.preferences.get_preference('globalChatPrefix'),
                                        pso2msg
                                    )
                                ).build()
                            )
                        else:
                            client.get_handle().send_crypto_packet(
                                packetFactory.SystemMessagePacket(
                                    u"[GIRC] <{}> {}".format(
                                        nickmsg,
                                        u"{}{}".format(
                                            client.preferences.get_preference('globalChatPrefix'),
                                            pso2msg
                                        )
                                    ),
                                    0x3
                                ).build()
                            )
            else:
                if not discord:
                    print("[IRC] <%s> %s" % (user.encode('ascii', 'ignore'), msg.encode('ascii', 'ignore')))
示例#10
0
)


def doRedisGchat(message):
    gchatMsg = json.loads(message['data'])
<<<<<<< HEAD
    fb = ("SHIP-%02i") % gchatMsg['ship']
=======
    if gchatMsg['ship'] == "GIRC":
        fb = "GIRC"
    else:
        fb = ("G-%02i") % gchatMsg['ship']
>>>>>>> d4a7bf2cacdd48a2cfb02935e664e0f093252d00
    shipl = ShipLabel.get(fb, fb)
    strgchatmsg = str(gchatMsg['text'].encode('utf-8'))
    if not check_irc_with_pso2(strgchatmsg):
        return
    if gchatMsg['server'] == PSO2PDConnector.connector_conf['server_name']:
        return
    if gchatMsg['sender'] == 1:
        for client in data.clients.connectedClients.values():
            if client.preferences.get_preference('globalChat') and client.get_handle() is not None:
                if lookup_gchatmode(client.preferences) == 0:
<<<<<<< HEAD
                    client.get_handle().send_crypto_packet(packetFactory.TeamChatPacket(gchatMsg['playerId'], "[Discord] %s" % gchatMsg['playerName'], "[Discord] %s" % gchatMsg['playerName'], "%s%s" % (client.preferences.get_preference('globalChatPrefix'), replace_irc_with_pso2(strgchatmsg).decode('utf-8', 'ignore'))).build())
                else:
                    client.get_handle().send_crypto_packet(packetFactory.SystemMessagePacket("[Discord] <%s> %s" % (gchatMsg['playerName'], "%s%s" % (client.preferences.get_preference('globalChatPrefix'), replace_irc_with_pso2(strgchatmsg).decode('utf-8', 'ignore'))), 0x3).build())
=======
                    client.get_handle().send_crypto_packet(
                        packetFactory.TeamChatPacket(
                            gchatMsg['playerId'],