コード例 #1
0
ファイル: PongStuff.py プロジェクト: dom96/nyx
def topicStuff(server,i,otherStuff):
    #:irc.archerseven.com 332 Nyx28 #Nyx :The Nyx channel
    #:[email protected] TOPIC #ogame :This is the ogame channel, talk about ogame battles and look for ogame help here....
    #:irc.archerseven.com 333 Nyx28 #ogame dom96 1252250064
    if len(i.split(" ")) > 1: 
        msgCode=i.split(" ")[1]
    else:
        return

    datParsed = ResponseParser.parseServerRegex(i)[0]
    
    if msgCode == "332":
        for ch in server.channels:
            if ch.cName == datParsed.channel:
                ch.cTopic = datParsed.msg

        for event in IRC.eventFunctions:
            if event.eventName == "onTopicChange" and event.cServer == server:
                gobject.idle_add(event.aFunc,datParsed,server,otherStuff)
    elif msgCode == "333":
        for event in IRC.eventFunctions:
            if event.eventName == "onTopicChange" and event.cServer == server:
                gobject.idle_add(event.aFunc,datParsed,server,otherStuff)

    elif "TOPIC" in i:
        m = ResponseParser.parseMsg(i,False)

        if m.typeMsg == "TOPIC":
            for ch in server.channels:
                if ch.cName == m.channel:
                    ch.cTopic = m.msg
            for event in IRC.eventFunctions:
                if event.eventName == "onTopicChange" and event.cServer == server:
                    gobject.idle_add(event.aFunc,m,server,otherStuff)
コード例 #2
0
ファイル: PongStuff.py プロジェクト: dom96/nyx
def nickResp(server,i,otherStuff):
    if "NICK" in i:
        m = ResponseParser.parseMsg(i,True)
        if m is not False:
            if m.typeMsg == "NICK":
                #If the person who changed their nick is you, change the nick in the server.
                if m.nick == server.cNick:
                    server.cNick = str(m.msg)

                for ch in server.channels:
                        for usr in ch.cUsers:
                            if usr.cNick.lower() == m.nick.lower():
                                pDebug(usr.cTreeIter)
                                cTreeIter = usr.cTreeIter
                                for event in IRC.eventFunctions:
                                    if event.eventName == "onUserRemove" and event.cServer == server:
                                        gobject.idle_add(event.aFunc,ch,server,cTreeIter,None)

                for ch in server.channels:
                        for usr in ch.cUsers:
                            if usr.cNick.lower() == m.nick.lower():
                                usr.cNick = m.msg
                                cIndex = findIndex(usr,server,ch)
                                for event in IRC.eventFunctions:
                                    if event.eventName == "onUserJoin" and event.cServer == server:
                                        event.aFunc(ch,server,cIndex,usr) #Might couse some random SEGFAULTS!!!!!!!!!!!!!!

                pDebug("NICK----" + m.nick + " = " + m.msg)
                for event in IRC.eventFunctions:
                    if event.eventName == "onNickChange" and event.cServer == server:
                        gobject.idle_add(event.aFunc,m,server,otherStuff)
コード例 #3
0
ファイル: PongStuff.py プロジェクト: dom96/nyx
def joinResp(server,i,otherStuff):#The join message
    #!--JOIN MSG--!#
    if "JOIN" in i:
        m = ResponseParser.parseMsg(i,False)
        if m is not False:
            #Make sure it's a JOIN msg.
            if m.typeMsg == "JOIN":

                #If it's you that JOINed, check if there is a TreeIter already for this channel
                #and if not then add one.
                if m.nick.lower() == server.cNick.lower():
                    addNewUser=True

                    #Check if there is already a channel created...
                    for ch in server.channels:
                        if ch.cName == m.channel:
                            addNewUser=False

                    if addNewUser==True:
                        nChannel = IRC.channel()
                        nChannel.cName = m.channel
                        nChannel.cTextBuffer = gtk.TextBuffer()
                        nChannel.UserListStore = gtk.ListStore(str,str)
                        try:
                            nChannel.cTreeIter = server.listTreeStore.append(server.cTreeIter, \
                            [m.channel, None, otherStuff.settings.normalTColor, "channel"])
                        except:
                            import traceback; traceback.print_exc()
                        nChannel.cMsgBuffer = [] #This fixes the weird problem with the queue being in the wrong channel.
                        #Add the newly JOINed channel to the Servers channel list
                        server.channels.append(nChannel)

                    #Send the MODE message, to ask for the MODE of the channel.
                    server.cSocket.send("MODE " + m.channel + "\r\n")
                    server.cSocket.send("WHO " + m.channel + "\r\n")
                else:
                    #Add the user who JOINed to the list of users
                    for ch in server.channels:
                        if ch.cName == m.channel:
                            usr=IRC.user()
                            usr.cNick=m.nick
                            usr.cChannel=ch
                            usr.cTextBuffer = gtk.TextBuffer()
                            ch.cUsers.append(usr)
                            try:
                                cIndex=findIndex(usr,server,ch)
                            except:
                                import traceback;traceback.print_exc()

                            #Call the onUsersChange event
                            for event in IRC.eventFunctions:
                                if event.eventName == "onUserJoin" and event.cServer == server:
                                    #Set the users cTreeIter immediately
                                    event.aFunc(ch,server,cIndex,usr) #Might couse some random SEGFAULTS!!!!!!!!!!!!!!

                for event in IRC.eventFunctions:
                    if event.eventName == "onJoinMsg" and event.cServer == server:
                        gobject.idle_add(event.aFunc,m,server,otherStuff)
コード例 #4
0
ファイル: PongStuff.py プロジェクト: dom96/nyx
def noticeResp(server,i,otherStuff):
    #:[email protected] NOTICE Nyx :test
    if "NOTICE" in i:
        m = ResponseParser.parseMsg(i,False)
        if m is not False:
            if m.typeMsg == "NOTICE":
                for event in IRC.eventFunctions:
                    if event.eventName == "onNoticeMsg" and event.cServer == server:
                        gobject.idle_add(event.aFunc,m,server,otherStuff)
コード例 #5
0
ファイル: PongStuff.py プロジェクト: dom96/nyx
def killResp(server, i, error, otherStuff):
    #:[email protected] KILL Nyx :DED48385.E7388619.9D7A5108.IP!dom96 (Testing)
    if "KILL" in i:
        m = ResponseParser.parseMsg(i,False)
        pDebug(m);pDebug(m.typeMsg)
        if m is not False:
            if m.typeMsg == "KILL":
                for event in IRC.eventFunctions:
                    if event.eventName == "onKillMsg" and event.cServer == server:
                        gobject.idle_add(event.aFunc,m,server,otherStuff)
                return "RECONNECT" #Make Nyx reconnect to the server.
    return error
コード例 #6
0
ファイル: PongStuff.py プロジェクト: dom96/nyx
def privmsgResp(server,i,otherStuff):#the private msg(Normal message)
    #!--PRIVMSG STUFF START--!#
    if "PRIVMSG" in i:
        m = ResponseParser.parseMsg(i,False)
        if m is not False:
            #Make sure it's PRIVMSG
            if m.typeMsg == "PRIVMSG":
                #pDebug(m.msg)
                #!--CTCP VERSION--!#
                if m.msg.startswith("VERSION"):
                    import platform
                    IRCHelper.sendNotice(server,m.nick,"VERSION Nyx 0.1 151309 Copyleft 2009 Mad Dog software - http://sourceforge.net/projects/nyxirc/ - running on " + platform.linux_distribution()[0] + "")
                #!--CTCP VERSION END--!#
                #!--CTCP TIME--!#
                if m.msg.startswith("TIME"):
                    IRCHelper.sendNotice(server,m.nick,"TIME " + strftime("%b %d %H:%M:%S %Z", localtime()) + "")
                    #TIME Aug 02 12:56:09 BST
                #!--CTCP TIME END--!#
                #!--CTCP PING--!#
                if m.msg.startswith("PING"):
                    IRCHelper.sendNotice(server,m.nick,m.msg)
                    #PING 123456789
                #!--CTCP PING END--!#
                
                #If someone sent YOU a PRIVMSG(i.e to you, not a channel), then make a new 'channel' for that user.
                if m.channel == server.cNick and m.msg.startswith("") == False:
                    addNewUser=True
                    #:[email protected] PRIVMSG dom96 :pie
                    for ch in server.channels:
                        if ch.cName.lower() == m.nick.lower():
                            addNewUser=False

                    if addNewUser==True:
                        nChannel = IRC.channel()
                        nChannel.cName = m.nick
                        nChannel.cTextBuffer = gtk.TextBuffer()
                        nChannel.cType = "chanusr"
                        nChannel.cTopic = m.host
                        nChannel.UserListStore = None
                        try:
                            nChannel.cTreeIter = server.listTreeStore.append(server.cTreeIter, \
                            [m.nick, None, otherStuff.settings.normalTColor, "user"])
                        except:
                            import traceback; traceback.print_exc()
                        nChannel.cMsgBuffer = [] #This fixes the weird problem with the queue being in the wrong channel.
                        #Add the user who PM'ed you to the Channel list
                        server.channels.append(nChannel)

                #Call all the onPrivMsg events
                for event in IRC.eventFunctions:
                    if event.eventName == "onPrivMsg" and event.cServer == server:
                        gobject.idle_add(event.aFunc,m,server,otherStuff)
コード例 #7
0
ファイル: PongStuff.py プロジェクト: dom96/nyx
def quitResp(server,i,otherStuff):#The quit message
    #!--QUIT MSG--!#
    if "QUIT" in i:
        m = ResponseParser.parseMsg(i,False)
        if m is not False:
            #Make sure it's a QUIT msg.
            #:[email protected] KILL gnome|nyx :ikey!admin.ikey.dynalias.com!Dredd (die w***e)
            if m.typeMsg == "QUIT" or "KILL":
                for event in IRC.eventFunctions:
                    if event.eventName == "onQuitMsg" and event.cServer == server:
                        gobject.idle_add(event.aFunc,m,server,otherStuff)

                #Delete the user from the list of users.
                for ch in server.channels:
                    for usr in ch.cUsers:
                        if usr.cNick.lower()==m.nick.lower():
                            cTreeIter = usr.cTreeIter
                            #The user is removed from the userlist in the onUserRemove event

                            #Call the onUserRemove event
                            for event in IRC.eventFunctions:
                                if event.eventName == "onUserRemove" and event.cServer == server:
                                    gobject.idle_add(event.aFunc,ch,server,cTreeIter,usr)
コード例 #8
0
ファイル: PongStuff.py プロジェクト: dom96/nyx
def partResp(server,i,otherStuff):#The part message
    #!--PART MSG--!#
    if "PART" in i:
        m = ResponseParser.parseMsg(i,False)
        if m is not False:
            #Make sure it's a PART msg.
            if m.typeMsg == "PART":
                for event in IRC.eventFunctions:
                    if event.eventName == "onPartMsg" and event.cServer == server:
                        gobject.idle_add(event.aFunc,m,server,otherStuff)

                if m.nick.lower() != server.cNick.lower():
                    #Delete the user from the list of users.
                    for ch in server.channels:
                        if ch.cName.lower() == m.channel.lower():
                            for usr in ch.cUsers:
                                if usr.cNick.lower()==m.nick.lower():
                                    cTreeIter = usr.cTreeIter #The TreeIter in the TreeStore to remove.
                                    ch.cUsers.remove(usr)
    
                                    #Call the onUserRemove event, which will remove the user from the TreeStore
                                    for event in IRC.eventFunctions:
                                        if event.eventName == "onUserRemove" and event.cServer == server:
                                            gobject.idle_add(event.aFunc,ch,server,cTreeIter,None)