Example #1
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())
Example #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())
Example #3
0
 def send_global_message(self, ship, user, message, server=None):
     if not check_pso2_with_irc(message):
         return
     fb = ("G-%02i") % ship
     shipl = ShipLabel.get(fb, fb)
     if server is None:
         self.msg(self.factory.channel, "[%s] <%s> %s" % (shipl, user, replace_pso2_with_irc(message)))
     else:
         self.msg(self.factory.channel, "(%s) [%s] <%s> %s" % (server, shipl, user, replace_pso2_with_irc(message)))
Example #4
0
 def send_global_message(self, ship, user, message, server=None):
     if not check_pso2_with_irc(message):
         return
     fb = ("G-%02i") % ship
     shipl = ShipLabel.get(fb, fb)
     if server is None:
         self.msg(self.factory.channel, "[%s] <%s> %s" % (shipl, user, replace_pso2_with_irc(message)))
     else:
         self.msg(self.factory.channel, "(%s) [%s] <%s> %s" % (server, shipl, user, replace_pso2_with_irc(message)))
Example #5
0
 def send_global_message(self, ship, user, message, server=None):
     if not check_pso2_with_irc(message):
         return
     fb = ("G-%02i") % ship
     shipl = ShipLabel.get(fb, fb)
     if server is None and redisEnabled:
         server = PSO2PDConnector.connector_conf['server_name']
     if discord:
         if server is None:
             self.say(self.factory.channel, "`[%s] %s`: %s" % (shipl, user, replace_pso2_with_irc(message)), 250)
         else:
             self.msg(self.factory.channel, "`(%s) [%s] %s`: %s" % (server, shipl, user, replace_pso2_with_irc(message)))
     else:
         if server is None:
             self.msg(self.factory.channel, "[%s] <%s> %s" % (shipl, user, replace_pso2_with_irc(message)))
         else:
             self.msg(self.factory.channel, "(%s) [%s] <%s> %s" % (server, shipl, user, replace_pso2_with_irc(message)))
Example #6
0
 def call_from_client(self, client):
     global ircMode
     if not data.clients.connectedClients[client.playerId].preferences.get_preference('globalChat'):
         client.send_crypto_packet(packetFactory.SystemMessagePacket(
             "[GlobalChat] You do not have global chat enabled, and can not send a global message.", 0x3).build())
         return
     if data.clients.connectedClients[client.playerId].preferences.has_preference("chatMuted") and data.clients.connectedClients[client.playerId].preferences['chatMuted']:
         client.send_crypto_packet(packetFactory.SystemMessagePacket("[GChat] {red}You have been muted from GChat and can not talk in it. :(", 0x3).build())
         return
     print("[GlobalChat] <%s> %s" % (data.players.playerList[client.playerId][0], self.args[3:]))
     if redisEnabled:
                 PSO2PDConnector.db_conn.publish("plugin-message-gchat", json.dumps({'sender': 0, 'text': self.args[3:], 'server': PSO2PDConnector.connector_conf['server_name'], 'playerName': data.players.playerList[client.playerId][0], 'playerId': client.playerId, 'ship': data.clients.connectedClients[client.playerId].ship}))
     if ircMode:
         global ircBot
         if ircBot is not None:
             ircBot.send_global_message(data.clients.connectedClients[client.playerId].ship, data.players.playerList[client.playerId][0].encode('utf-8'), self.args[3:].encode('utf-8'))
     fb = ("G-%02i") % data.clients.connectedClients[client.playerId].ship
     shipl = ShipLabel.get(fb, fb)
     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(client.playerId, "[%s] %s" % (shipl, data.players.playerList[client.playerId][0]), data.players.playerList[client.playerId][0], "%s%s" % (client_data.preferences.get_preference('globalChatPrefix'), self.args[3:])).build())
             else:
                 client_data.get_handle().send_crypto_packet(packetFactory.SystemMessagePacket("[%s] <%s> %s" % (shipl, data.players.playerList[client.playerId][0], "%s%s" % (client_data.preferences.get_preference('globalChatPrefix'), self.args[3:])), 0x3).build())
Example #7
0
 def call_from_client(self, client):
     global ircMode
     if not data.clients.connectedClients[client.playerId].preferences.get_preference('globalChat'):
         client.send_crypto_packet(packetFactory.SystemMessagePacket(
             "{yel}[PCP Bot] {gre}Gchat Status: {ora}OFF{gre}, dan tidak dapat mengirim pesan", 0x3).build())
         return
     if data.clients.connectedClients[client.playerId].preferences.has_preference("chatMuted") and data.clients.connectedClients[client.playerId].preferences['chatMuted']:
         client.send_crypto_packet(packetFactory.SystemMessagePacket("{yel}[PCP Bot] {red}Anda dinonaktifkan dari Gchat dan anda tidak dapat mengirim pesan ke Gchat. :(", 0x3).build())
         return
     print("[GlobalChat] [%s] %s" % (data.players.playerList[client.playerId][0], self.args[3:]))
     if redisEnabled:
                 PSO2PDConnector.db_conn.publish("plugin-message-gchat", json.dumps({'sender': 0, 'text': self.args[3:], 'server': PSO2PDConnector.connector_conf['server_name'], 'playerName': data.players.playerList[client.playerId][0], 'playerId': client.playerId, 'ship': data.clients.connectedClients[client.playerId].ship}))
     if ircMode:
         global ircBot
         if ircBot is not None:
             ircBot.send_global_message(data.clients.connectedClients[client.playerId].ship, data.players.playerList[client.playerId][0].encode('utf-8'), self.args[3:].encode('utf-8'))
     fb = ("Ship-%02i") % data.clients.connectedClients[client.playerId].ship
     shipl = ShipLabel.get(fb, fb)
     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(client.playerId, "[%s] %s" % (shipl, data.players.playerList[client.playerId][0]), data.players.playerList[client.playerId][0], "%s%s" % (client_data.preferences.get_preference('globalChatPrefix'), self.args[3:])).build())
             else:
                 client_data.get_handle().send_crypto_packet(packetFactory.SystemMessagePacket("{ora}[%s] <%s>{yel} %s" % (shipl, data.players.playerList[client.playerId][0], "%s%s" % (client_data.preferences.get_preference('globalChatPrefix'), self.args[3:])), 0x3).build())
Example #8
0
 def call_from_client(self, client):
     global ircMode
     if not data.clients.connectedClients[client.playerId].preferences.get_preference('globalChat'):
         client.send_crypto_packet(packetFactory.SystemMessagePacket(
             "[GlobalChat] You do not have global chat enabled, and can not send a global message.", 0x3).build())
         return
     if data.clients.connectedClients[client.playerId].preferences.has_preference("chatMuted") and data.clients.connectedClients[client.playerId].preferences['chatMuted']:
         client.send_crypto_packet(packetFactory.SystemMessagePacket("[GChat] {red}You have been muted from GChat and can not talk in it. :(", 0x3).build())
         return
     print("[GlobalChat] <%s> %s" % (data.players.playerList[client.playerId][0], self.args[3:]))
     if redisEnabled:
                 PSO2PDConnector.db_conn.publish("plugin-message-gchat", json.dumps({'sender': 0, 'text': self.args[3:], 'server': PSO2PDConnector.connector_conf['server_name'], 'playerName': data.players.playerList[client.playerId][0], 'playerId': client.playerId, 'ship': data.clients.connectedClients[client.playerId].ship}))
     if ircMode:
         global ircBot
         if ircBot is not None:
             ircBot.send_global_message(data.clients.connectedClients[client.playerId].ship, data.players.playerList[client.playerId][0].encode('utf-8'), self.args[3:].encode('utf-8'))
     fb = ("G-%02i") % data.clients.connectedClients[client.playerId].ship
     shipl = ShipLabel.get(fb, fb)
     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(client.playerId, "[%s] %s" % (shipl, data.players.playerList[client.playerId][0]), data.players.playerList[client.playerId][0], "%s%s" % (client_data.preferences.get_preference('globalChatPrefix'), self.args[3:])).build())
             else:
                 client_data.get_handle().send_crypto_packet(packetFactory.SystemMessagePacket("[%s] <%s> %s" % (shipl, data.players.playerList[client.playerId][0], "%s%s" % (client_data.preferences.get_preference('globalChatPrefix'), self.args[3:])), 0x3).build())
Example #9
0
def GChatDirect(context, data):
    """
    :type context: ShipProxy.ShipProxy
    """
    idsega = context.myUsername
    if idsega is None or str(idsega) == "None" or idsega == "None":
        return data
    else:
        pref = dataclients.ClientPreferences(idsega)
        if pref.has_preference("globalChatDirect"):
            isActive = pref.get_preference("globalChatDirect")
            if isActive:
                if pref.has_preference("chatMuted") and pref.get_preference(
                        'chatMuted'):
                    pref.set_preference("globalChatDirect", False)
                    isActive = False
        else:
            isActive = False
        if isActive:
            try:
                player_id = struct.unpack_from('I', data, 0x8)[0]
                message1 = data[0x1C:].decode('utf-16')
                if player_id == 0:
                    message1 = message1.rstrip('\0')
                    if message1.startswith("/"): return data
                    player_name = dataplayers.playerList[
                        context.playerId][0].rstrip('\0')
                    fb = ("SHIP-%02i") % dataclients.connectedClients[
                        context.playerId].ship
                    shipl = ShipLabel.get(fb, fb)
                    tUser = "******" % (shipl, player_name)
                    print("[GlobalChat] <%s> %s" %
                          (dataplayers.playerList[context.playerId][0],
                           message1))
                if redisEnabled:
                    PSO2PDConnector.db_conn.publish(
                        "plugin-message-gchat",
                        json.dumps({
                            'sender':
                            0,
                            'text':
                            message1,
                            'server':
                            PSO2PDConnector.connector_conf['server_name'],
                            'playerName':
                            dataplayers.playerList[context.playerId][0],
                            'playerId':
                            client.playerId,
                            'ship':
                            dataclients.connectedClients[client.playerId].ship
                        }))
                if ircMode:
                    global ircBot
                    if ircBot is not None:
                        ircBot.send_global_message1(
                            dataclients.connectedClients[
                                context.playerId].ship, dataplayers.playerList[
                                    context.playerId][0].encode('utf-8'),
                            message1.encode('utf-8'))
                    for client_data in dataclients.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(
                                        context.playerId,
                                        "[%s] %s" % (shipl, player_name),
                                        player_name, "%s%s" %
                                        (client_data.preferences.
                                         get_preference('globalChatPrefix'),
                                         message1)).build())
                            else:
                                client_data.get_handle().send_crypto_packet(
                                    packetFactory.SystemMessagePacket(
                                        "{ora}[%s] <%s>{yel} %s" %
                                        (shipl, player_name, "%s%s" %
                                         (client_data.preferences.
                                          get_preference('globalChatPrefix'),
                                          message)), 0x3).build())
                    return None
            except Exception as e:
                print("[Error] %s" % e)
                return data
        return data
Example #10
0
 def send_global_message(self, ship, user, message, server=None):
     if not check_pso2_with_irc(message):
         return
     fb = ("SHIP-%02i") % ship
     shipl = ShipLabel.get(fb, fb)
Example #11
0
    },
    True
)


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(