def on_pubmsg(self, c, e):
        target = e.target()

        if target in self.channels:
            self.channels[target].printMsg(user2name(e.source()), "\n".join(e.arguments()))
        if self.client.GalacticWar.channel and target == self.client.GalacticWar.channel.name :
            self.client.GalacticWar.channel.printMsg(user2name(e.source()), "\n".join(e.arguments()))
Example #2
0
    def on_privnotice(self, c, e):
        source = user2name(e.source())
        notice = e.arguments()[0]
        prefix = notice.split(" ")[0]
        target = prefix.strip("[]")

        # It is surprising that SimpleIRCClient doesn't handle this for us.
        # I suspect, in reality, it probably can do...
        if source and source.lower() == 'nickserv':
            if notice.find("registered under your account") or \
               notice.find("Password accepted"):
                if not self.identified :
                    self.identified = True
                    self.on_identified()

            elif notice.find("isn't registered") >= 0:
                self.nickservRegister()

            elif notice.find("RELEASE") >= 0:
                self.connection.privmsg('nickserv', 'release %s %s' % (self.client.login, util.md5text(self.client.password)))

            elif notice.find("hold on") >= 0:
                self.connection.nick(self.client.login)

        message = "\n".join(e.arguments()).lstrip(prefix)
        if target in self.channels:
            self.channels[target].printMsg(source, message)
        elif source == "Global":
            for channel in self.channels:
                self.channels[channel].printAnnouncement(message, "yellow", "+2")
        elif source == "AeonCommander":
            for channel in self.channels:
                self.channels[channel].printMsg(source, message)
        else:
            self.serverLogArea.appendPlainText("%s: %s" % (source, notice))
Example #3
0
 def on_part(self, c, e):
     channel = e.target()
     name = user2name(e.source())
     if name == self.client.login:  #We left ourselves.
         self.removeTab(self.indexOf(self.channels[channel]))
         del self.channels[channel]
     else:  #Someone else left
         self.channels[channel].removeChatter(name, "left.")
Example #4
0
 def on_part(self, c, e):
     channel = e.target()
     name = user2name(e.source())
     if name == self.client.login:   #We left ourselves.
         self.removeTab(self.indexOf(self.channels[channel]))
         del self.channels[channel]
     else:                           #Someone else left
         self.channels[channel].removeChatter(name, "left.")
Example #5
0
    def on_privmsg(self, c, e):
        name = user2name(e.source())

        if self.client.isFoe(name) :
            return
        # Create a Query if it's not open yet, and post to it if it exists.
        if self.openQuery(name):
            self.channels[name].printMsg(name, "\n".join(e.arguments()))
Example #6
0
    def on_nick(self, c, e):
        oldnick = user2name(e.source())
        newnick = e.target()
        if oldnick not in self._chatters:
            return

        self._chatters[oldnick].update(name=newnick)
        self.log_event(e)
Example #7
0
    def on_privmsg(self, c, e):
        name = user2name(e.source())

        if self.client.isFoe(name):
            return
        # Create a Query if it's not open yet, and post to it if it exists.
        if self.openQuery(name):
            self.channels[name].printMsg(name, "\n".join(e.arguments()))
Example #8
0
    def on_mode(self, c, e):
        if e.target() not in self.channels:
            return
        if len(e.arguments()) < 2:
            return
        name = user2name(e.arguments()[1])
        if name not in self._chatters:
            return
        chatter = self._chatters[name]

        self.elevate_chatter(chatter, e.target(), e.arguments()[0])
Example #9
0
    def on_part(self, c, e):
        channel = e.target()
        name = user2name(e.source())
        if name not in self._chatters:
            return
        chatter = self._chatters[name]

        if name == self.client.login:  # We left ourselves.
            self.removeTab(self.indexOf(self.channels[channel]))
            del self.channels[channel]
        else:  # Someone else left
            self._remove_chatter_channel(chatter, channel, "left.")
Example #10
0
    def on_join(self, c, e):
        channel = e.target()

        # If we're joining, we need to open the channel for us first.
        if channel not in self.channels:
            self.channels[channel] = Channel(self, channel)
            if (channel.lower() in self.crucialChannels):
                self.insertTab(1, self.channels[channel], channel)    #CAVEAT: This is assumes a server tab exists.
                self.client.localBroadcast.connect(self.channels[channel].printRaw)
                self.channels[channel].printAnnouncement("Welcome to Forged Alliance Forever !", "red", "+3")
                self.channels[channel].printAnnouncement("The documentation is the wiki. Check the Links menu !", "red", "+1")
                self.channels[channel].printAnnouncement("", "black", "+1")
                self.channels[channel].printAnnouncement("", "black", "+1")

            else:
                if channel.lower() == "#uef" or channel.lower() == "#aeon" or channel.lower() == "#cybran" or channel.lower() == "#seraphim" :
                    self.client.GalacticWar.createChannel(self, channel)
                    self.client.GalacticWar.network_Chat.layout().addWidget(self.client.GalacticWar.channel)
                    self.client.GalacticWar.channel.addChatter(user2name(e.source()), True)
                    self.client.GalacticWar.channel.resizing()

                self.addTab(self.channels[channel], channel)


            if channel.lower() in self.crucialChannels: #Make the crucial channels not closeable, and make the last one the active one
                self.setCurrentWidget(self.channels[channel])
                self.tabBar().setTabButton(self.currentIndex(), QtGui.QTabBar.RightSide, None)
            else:
                self.channels[channel].joinLabel.hide()
                self.channels[channel].channelsComboBox.hide()

        username = user2name(e.source())
        self.channels[channel].addChatter(username, True)

        if channel.lower() in self.crucialChannels and username != self.client.login:
            # TODO: search better solution, that html in nick & channel no rendered
            self.client.notificationSystem.on_event(ns.NotificationSystem.USER_ONLINE,{'user':username, 'channel':channel})
            # TODO: use signal?
            self.client.friendList.addUser(username)
        self.channels[channel].resizing()
Example #11
0
    def on_action(self, c, e):
        name = user2name(e.source())
        target = e.target()

        if self.client.isFoe(name) :
            return

        # Create a Query if it's not an action intended for a channel
        if target not in self.channels:
            self.openQuery(name)
            self.channels[name].printAction(name, "\n".join(e.arguments()))
        else:
            self.channels[target].printAction(name, "\n".join(e.arguments()))
Example #12
0
    def on_action(self, c, e):
        name = user2name(e.source())
        target = e.target()

        if self.client.isFoe(name):
            return

        # Create a Query if it's not an action intended for a channel
        if target not in self.channels:
            self.openQuery(name)
            self.channels[name].printAction(name, "\n".join(e.arguments()))
        else:
            self.channels[target].printAction(name, "\n".join(e.arguments()))
Example #13
0
    def on_join(self, c, e):
        channel = e.target()

        # If we're joining, we need to open the channel for us first.
        if channel not in self.channels:
            self.channels[channel] = Channel(self, channel)
            if (channel.lower() in self.crucialChannels):
                self.insertTab(
                    1, self.channels[channel],
                    channel)  #CAVEAT: This is assumes a server tab exists.
                self.client.localBroadcast.connect(
                    self.channels[channel].printRaw)
                self.channels[channel].printAnnouncement(
                    "Welcome to Forged Alliance Forever !", "red", "+3")
                self.channels[channel].printAnnouncement(
                    "The documentation is the wiki. Check the Links menu !",
                    "red", "+1")
                self.channels[channel].printAnnouncement("", "black", "+1")
                self.channels[channel].printAnnouncement("", "black", "+1")

            else:
                #     if channel.lower() == "#uef" or channel.lower() == "#aeon" or channel.lower() == "#cybran" or channel.lower() == "#seraphim" :
                #         self.client.GalacticWar.createChannel(self, channel)
                #         self.client.GalacticWar.network_Chat.layout().addWidget(self.client.GalacticWar.channel)
                #         self.client.GalacticWar.channel.addChatter(user2name(e.source()), True)
                #         self.client.GalacticWar.channel.resizing()

                self.addTab(self.channels[channel], channel)

            if channel.lower(
            ) in self.crucialChannels:  #Make the crucial channels not closeable, and make the last one the active one
                self.setCurrentWidget(self.channels[channel])
                self.tabBar().setTabButton(self.currentIndex(),
                                           QtGui.QTabBar.RightSide, None)
            else:
                self.channels[channel].joinLabel.hide()
                self.channels[channel].channelsComboBox.hide()

        username = user2name(e.source())
        self.channels[channel].addChatter(username, True)

        if channel.lower(
        ) in self.crucialChannels and username != self.client.login:
            # TODO: search better solution, that html in nick & channel no rendered
            self.client.notificationSystem.on_event(
                ns.NotificationSystem.USER_ONLINE, {
                    'user': username,
                    'channel': channel
                })
        self.channels[channel].resizing()
Example #14
0
    def addChatter(self, user, join = False):
        '''
        Adds an user to this chat channel, and assigns an appropriate icon depending on friendship and FAF player status
        '''          
        name = user2name(user)

        if name not in self.chatters:
            item = Chatter(self.nickList, user, self.lobby, None)                        
            self.chatters[name] = item        
            
        self.chatters[name].update()

        self.updateUserCount()
        
        if join and self.lobby.client.joinsparts:
            self.printAction(name, "joined the channel.", server_action=True)
Example #15
0
    def openQuery(self, name, activate=False):
        # In developer mode, allow player to talk to self to test chat functions
        if (name == self.client.login) and not util.developer():
            return False

        #not allowing foes to talk to us.
        if (self.client.isFoe(name)) :
            return False

        if name not in self.channels:
            self.channels[name] = Channel(self, name, True)
            self.addTab(self.channels[name], user2name(name))

        if activate:
            self.setCurrentWidget(self.channels[name])

        self.channels[name].resizing()
        return True
Example #16
0
    def openQuery(self, name, activate=False):
        # In developer mode, allow player to talk to self to test chat functions
        if (name == self.client.login) and not util.developer():
            return False

        #not allowing foes to talk to us.
        if (self.client.isFoe(name)):
            return False

        if name not in self.channels:
            self.channels[name] = Channel(self, name, True)
            self.addTab(self.channels[name], user2name(name))

        if activate:
            self.setCurrentWidget(self.channels[name])

        self.channels[name].resizing()
        return True
Example #17
0
    def on_privnotice(self, c, e):
        source = user2name(e.source())
        notice = e.arguments()[0]
        prefix = notice.split(" ")[0]
        target = prefix.strip("[]")

        if source and source.lower() == 'nickserv':

            if e.arguments()[0].find("registered under your account") >= 0:
                if self.identified == False:
                    self.identified = True
                    self.on_authentified()

            elif e.arguments()[0].find("isn't registered") >= 0:

                self.nickservRegister()

            elif e.arguments()[0].find("Password accepted"):
                if self.identified == False:
                    self.identified = True
                    self.on_authentified()

            elif e.arguments()[0].find("RELEASE") >= 0:
                self.connection.privmsg(
                    'nickserv', 'release %s %s' %
                    (self.client.login, util.md5text(self.client.password)))

            elif e.arguments()[0].find("hold on") >= 0:
                self.connection.nick(self.client.login)
        elif source and source.lower() == 'botserv':
            print "botserv", notice

        message = "\n".join(e.arguments()).lstrip(prefix)
        if target in self.channels:
            self.channels[target].printMsg(source, message)
        elif source == "Global":
            for channel in self.channels:
                self.channels[channel].printAnnouncement(
                    message, "yellow", "+2")
        elif source == "AeonCommander":
            for channel in self.channels:
                self.channels[channel].printMsg(source, message)
        else:
            self.serverLogArea.appendPlainText("%s: %s" % (source, notice))
Example #18
0
    def on_privnotice(self, c, e):
        source = user2name(e.source())
        notice = e.arguments()[0]
        prefix = notice.split(" ")[0]
        target = prefix.strip("[]")

        if source and source.lower() == 'nickserv':

            if e.arguments()[0].find("registered under your account") >= 0:
                if self.identified == False :
                    self.identified = True
                    self.on_authentified()

            elif e.arguments()[0].find("isn't registered") >= 0:

                self.nickservRegister()

            elif e.arguments()[0].find("Password accepted") :
                if self.identified == False :
                    self.identified = True
                    self.on_authentified()

            elif e.arguments()[0].find("RELEASE") >= 0:
                self.connection.privmsg('nickserv', 'release %s %s' % (self.client.login, util.md5text(self.client.password)))

            elif e.arguments()[0].find("hold on") >= 0:
                self.connection.nick(self.client.login)
        elif source and source.lower() == 'botserv':
            print "botserv", notice


        message = "\n".join(e.arguments()).lstrip(prefix)
        if target in self.channels:
            self.channels[target].printMsg(source, message)
        elif source == "Global":
            for channel in self.channels:
                self.channels[channel].printAnnouncement(message, "yellow", "+2")
        elif source == "AeonCommander":
            for channel in self.channels:
                self.channels[channel].printMsg(source, message)
        else:
            self.serverLogArea.appendPlainText("%s: %s" % (source, notice))
Example #19
0
    def __init__(self, parent, user, lobby, *args, **kwargs):
        QtGui.QTableWidgetItem.__init__(self, *args, **kwargs)
                
        #TODO: for now, userflags and ranks aren't properly interpreted :-/ This is impractical if an operator reconnects too late.
        self.parent = parent
        self.lobby = lobby

        if user[0] in self.lobby.OPERATOR_COLORS:
            self.elevation = user[0]
        else:
            self.elevation = None

        self.name = user2name(user)
        
        self.avatar = None
        self.status = None
        self.rating = None
        self.country = None
        self.league = None
        self.clan = ""
        self.avatarTip = ""
        
        self.setup()
Example #20
0
    def __init__(self, parent, user, lobby, *args, **kwargs):
        QtGui.QTableWidgetItem.__init__(self, *args, **kwargs)

        #TODO: for now, userflags and ranks aren't properly interpreted :-/ This is impractical if an operator reconnects too late.
        self.parent = parent
        self.lobby = lobby

        if user[0] in self.lobby.OPERATOR_COLORS:
            self.elevation = user[0]
        else:
            self.elevation = None

        self.name = user2name(user)

        self.avatar = None
        self.status = None
        self.rating = None
        self.country = None
        self.league = None
        self.clan = ""
        self.avatarTip = ""

        self.setup()
Example #21
0
    def on_pubmsg(self, c, e):
        target = e.target()

        if target in self.channels:
            self.channels[target].printMsg(user2name(e.source()), "\n".join(e.arguments()))
Example #22
0
 def on_mode(self, c, e):
     if len(e.arguments()) < 2:
         return
     name = user2name(e.arguments()[1])
     if e.target() in self.channels:
         self.channels[e.target()].elevateChatter(name, e.arguments()[0])
Example #23
0
 def on_quit(self, c, e):
     name = user2name(e.source())
     for channel in self.channels:
         if (not self.channels[channel].private) or (self.channels[channel].name == user2name(name)):
             self.channels[channel].removeChatter(name, "quit.")
Example #24
0
 def on_mode(self, c, e):
     if len(e.arguments()) < 2:
         return
     name = user2name(e.arguments()[1])
     if e.target() in self.channels:
         self.channels[e.target()].elevateChatter(name, e.arguments()[0])
Example #25
0
 def on_quit(self, c, e):
     name = user2name(e.source())
     for channel in self.channels:
         if (not self.channels[channel].private) or (
                 self.channels[channel].name == user2name(name)):
             self.channels[channel].removeChatter(name, "quit.")
Example #26
0
 def on_quit(self, c, e):
     name = user2name(e.source())
     self._remove_chatter(name)
Example #27
0
    def on_pubmsg(self, c, e):
        target = e.target()

        if target in self.channels:
            self.channels[target].printMsg(user2name(e.source()),
                                           "\n".join(e.arguments()))