Пример #1
0
 def privmsg(self, user, channel, msg):
     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')))
         TCPacket = packetFactory.TeamChatPacket(
             self.get_user_id(user.split("!")[0]),
             "[GIRC] %s" % user.split("!")[0], "%s%s" %
             (gchatSettings['prefix'],
              replace_irc_with_pso2(msg).decode('utf-8'))).build()
         SMPacket = packetFactory.SystemMessagePacket(
             "[GIRC] <%s> %s" %
             (user.split("!")[0], "%s%s" %
              (gchatSettings['prefix'],
               replace_irc_with_pso2(msg).decode('utf-8'))),
             0x3).build()
         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(TCPacket)
                 else:
                     client.get_handle().send_crypto_packet(SMPacket)
     else:
         print("[IRC] <%s> %s" % (user, msg))
Пример #2
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())
Пример #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'])
    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'], "%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) [G-%02i] %s" %
                            (gchatMsg['server'], gchatMsg['ship'],
                             gchatMsg['playerName']),
                            "%s%s" % (client_data.preferences.get_preference(
                                'globalChatPrefix'),
                                      gchatMsg['text'])).build())
                else:
                    client_data.get_handle().send_crypto_packet(
                        packetFactory.SystemMessagePacket(
                            "(%s) [G-%02i] <%s> %s" %
                            (gchatMsg['server'], gchatMsg['ship'],
                             gchatMsg['playerName'], "%s%s" %
                             (client_data.preferences.get_preference(
                                 'globalChatPrefix'), gchatMsg['text'])),
                            0x3).build())
Пример #5
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))
Пример #6
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:
Пример #7
0
 def privmsg(self, user, channel, msg):
     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')))
         TCPacket = packetFactory.TeamChatPacket(self.get_user_id(user.split("!")[0]), "[GIRC] %s" % user.split("!")[0], "%s%s" % (gchatSettings['prefix'], replace_irc_with_pso2(msg).decode('utf-8'))).build()
         SMPacket = packetFactory.SystemMessagePacket("[GIRC] <%s> %s" % (user.split("!")[0], "%s%s" % (gchatSettings['prefix'], replace_irc_with_pso2(msg).decode('utf-8'))), 0x3).build()
         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(TCPacket)
                 else:
                     client.get_handle().send_crypto_packet(SMPacket)
     else:
         print("[IRC] <%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 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())
Пример #10
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')))
Пример #11
0
#!/bin/python
from PSO2DataTools import replace_irc_with_pso2
import sys

f = sys.stdin


#    Usage: echo -e "\000308yellow" | python ./IRC2PSO.py
def main():
    global f
    if len(sys.argv) > 1:
        f = open(sys.argv[1])


for line in f:
    replace_irc_with_pso2(line, 1)

if __name__ == "__main__":
    main()
Пример #12
0
        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'],
                            "[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: