Exemplo n.º 1
0
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)
Exemplo n.º 2
0
def topData(period, startdate, enddate, idb, destdir, bots, npeople):
    top_senders = {}
    top_senders['senders.'] = \
        IRC.GetTopSendersIRC(0, startdate, enddate, idb, bots, npeople)
    # dataFrame2Dict(vizr.GetTopSendersIRC(0, startdate, enddate, idb, bots))
    top_senders['senders.last year'] = \
        IRC.GetTopSendersIRC(365, startdate, enddate, idb, bots, npeople)
    # dataFrame2Dict(vizr.GetTopSendersIRC(365, startdate, enddate, idb, bots))
    top_senders['senders.last month'] = \
        IRC.GetTopSendersIRC(31, startdate, enddate, idb, bots, npeople)
    # dataFrame2Dict(vizr.GetTopSendersIRC(31, startdate, enddate, idb, bots))
    top_file = destdir + "/irc-top.json"
    createJSON(top_senders, top_file)

    return (top_senders)
Exemplo n.º 3
0
    def __init__(self):

        # our irc-object
        self.irc = IRC(self.update_window2)

        # init the screen
        self.scr = curses.initscr()
        curses.noecho()
        curses.cbreak()
        self.scr.keypad(1)

        # init the first window as status window
        y, x = self.scr.getmaxyx()
        self.statuswin = curses.newwin(1, x, y - 2, 0)
        self.statuswin.addstr(0, 0, "[NOT CONNECTED]")

        # staus win 2 who@where
        statuswin2W = 10
        self.statuswin2 = curses.newwin(1, statuswin2W, y - 1, 0)
        self.statuswin2.addstr(0, 0, "NICK")

        # type win
        self.typewin = curses.newwin(1, x - statuswin2W - 1, y - 1,
                                     statuswin2W - 1)
        self.typewin.keypad(1)

        # message win
        self.messagewin = curses.newwin(
            y - 2, x - 13, 0,
            0)  # nick lengt is 9 char should be done dynamically
        # so that windows size should depend on nick lenghts

        # nick win
        self.nickwin = curses.newwin(y - 2, 13, 0,
                                     x - 13)  # should also be dynamic

        self.textbuffer = EditBuffer()  # edit buffer for text input

        # list of our window (channel)
        self.mwindows = list()
        self.active_mwindow = 0

        # refresh the windows
        self.messagewin.refresh()
        self.statuswin.refresh()
        self.statuswin2.refresh()
        self.typewin.refresh()
Exemplo n.º 4
0
def aggData(period, startdate, enddate, idb, destdir):
    agg_data = {}

    # Tendencies
    for i in [7, 30, 365]:
        # period_data = dataFrame2Dict(vizr.GetIRCDiffSentDays(period, enddate, i))
        period_data = IRC.GetIRCDiffSentDays(period, enddate, i)
        agg_data = dict(agg_data.items() + period_data.items())
        # period_data = dataFrame2Dict(vizr.GetIRCDiffSendersDays(period, enddate, idb, i))
        period_data = IRC.GetIRCDiffSendersDays(period, enddate, idb, i)
        agg_data = dict(agg_data.items() + period_data.items())

    # Global aggregated data
    # static_data = vizr.GetStaticDataIRC(period, startdate, enddate, idb)
    static_data = IRC.GetStaticDataIRC(period, startdate, enddate, idb, None)
    agg_data = dict(agg_data.items() + static_data.items())

    createJSON(agg_data, destdir + "/irc-static.json")
Exemplo n.º 5
0
def reposData(period, startdate, enddate, idb, destdir):
    # repos = valRtoPython(vizr.GetReposNameIRC())
    repos = IRC.GetReposNameIRC()
    repos_file = destdir + "/irc-repos.json"
    createJSON(repos, repos_file)

    for repo in repos:
        # evol = vizr.GetRepoEvolSentSendersIRC(repo, period, startdate, enddate)
        evol = IRC.GetRepoEvolSentSendersIRC(repo, period, startdate, enddate)
        # evol = completePeriodIds(dataFrame2Dict(evol))
        evol = completePeriodIds(evol)
        repo_file = destdir + "/" + repo + "-irc-rep-evolutionary.json"
        createJSON(evol, repo_file)

        repo_file = destdir + "/" + repo + "-irc-rep-static.json"
        # aggdata = dataFrame2Dict(vizr.GetRepoStaticSentSendersIRC(repo, startdate, enddate))
        aggdata = IRC.GetRepoStaticSentSendersIRC(repo, startdate, enddate)
        createJSON(aggdata, repo_file)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
def peopleData(period, startdate, enddate, idb, destdir, top_data):
    top = top_data['senders.']["id"]
    top += top_data['senders.last year']["id"]
    top += top_data['senders.last month']["id"]
    # remove duplicates
    people = list(set(top))
    # the order is not the same than in R json
    createJSON(people, destdir + "/irc-people.json", False)

    for upeople_id in people:
        # evol = dataFrame2Dict(vizr.GetEvolPeopleIRC(upeople_id, period, startdate, enddate))
        evol = IRC.GetEvolPeopleIRC(upeople_id, period, startdate, enddate)
        evol = completePeriodIds(evol)
        person_file = destdir + "/people-" + str(
            upeople_id) + "-irc-evolutionary.json"
        createJSON(evol, person_file)

        person_file = destdir + "/people-" + str(
            upeople_id) + "-irc-static.json"
        # aggdata = dataFrame2Dict(vizr.GetStaticPeopleIRC(upeople_id, startdate, enddate))
        aggdata = IRC.GetStaticPeopleIRC(upeople_id, startdate, enddate)
        createJSON(aggdata, person_file)
Exemplo n.º 8
0
def userStuff(server,i):#The user list.
    global USERS
    if len(i.split(" ")) > 1:
        msgCode = i.split(" ")[1]
    else:
        return

    #!--USERS STUFF--!#
    if ("353" == msgCode):
        if i.startswith(":"):
            USERS += "\n"
            USERS += i
    if ("366" == msgCode):
        USERS += "\n"
        USERS += i
        m = ResponseParser.parseServer(i)
        for channel in server.channels:
            if channel.cName == m[0].channel:
                #Add the users correctly.
                pDebug("\033[1;34mParsed server msg 'channel' is " + m[0].channel + "\033[1;m")
                channel.cUsers = []
                
                for user in ResponseParser.parseUsers(USERS,server,channel):
                    usr = IRC.user()
                    #Get the user mode.
                    userF=user
                    usr.cChannel=channel
                    usr.cTextBuffer=gtk.TextBuffer()
                    while(userF.startswith("*") or userF.startswith("!") or userF.startswith("@") or userF.startswith("%") 
or userF.startswith("+") or userF.startswith("~") or userF.startswith("&")):
                        usr.cMode += userF[:1]
                        userF=userF[1:]
                    #Get the nickname.
                    usr.cNick = user.replace(usr.cMode,"").replace(" ","")
                    channel.cUsers.append(usr)
                    pDebug("\033[1;32mAdded " + usr.cNick + " to " + channel.cName + " users list " + " with mode " + usr.cMode + "\033[1;m")

                USERS = ""

                for event in IRC.eventFunctions:
                    if event.eventName == "onUsersChange" and event.cServer == server:
                        #event.aFunc(channel,server)
                        gobject.idle_add(event.aFunc,channel, server, priority=gobject.PRIORITY_HIGH)
Exemplo n.º 9
0
def tsData(period, startdate, enddate, idb, destdir):
    ts_data = {}
    # ts_data = dataFrame2Dict(vizr.GetEvolDataIRC(period, startdate, enddate, idb))
    ts_data = IRC.GetEvolDataIRC(period, startdate, enddate, idb, None)
    ts_data = completePeriodIds(ts_data)
    createJSON(ts_data, destdir + "/irc-evolutionary.json")
Exemplo n.º 10
0
import FileHandler
import IRC

fh = FileHandler.FileHandler()
options = fh.getOptions("twitch.ini")
chat = IRC.ircClient(options)
chat.connect()
run = True
while chat.run:
    chat.recive()
chat.disconnect()
Exemplo n.º 11
0
Arquivo: Tester.py Projeto: dom96/nyx
import IRC
import IRCHelper

def onServerMsg(m):
    print "Event" + m

def onMOTDMsg(m,cServer):
    IRCHelper.join(cServer,"#botplay")
def onJoinMsg(m,cServer):
    print m.nick
    

#IRCLibraryTesting app.
print "IRCLibrary testing app 0.1"

server = IRC.server()
IRC.connectEvent("serverMsg",onServerMsg,server)
IRC.connectEvent("onMotdMsg",onMOTDMsg,server)
IRC.connectEvent("onPartMsg",onJoinMsg,server)

server = IRC.connect("irc.spotchat.org","vIRC","vIRC",6667,server)
print server.cNick
#server2 = IRC.server()
#IRC.connectEvent("serverMsg",onServerMsg,server2)
#IRC.connectEvent("onMotdMsg",onMOTDMsg,server2)
#server = IRC.connect("irc.freenode.net","vIRC","vIRC",8001,server2)

while(True):
    pass

Exemplo n.º 12
0
# Umi is a simple IRC client

import IRC, Config, Logger

# An instance of Config to pull configuration options
conf = Config.Config()

# A Logger object for writing to the Terminal
log = Logger.Logger(conf)

# Establish a connection to the IRC network
Umi = IRC.IRC(conf.network(), log, conf)
Exemplo n.º 13
0
class CursesGui:
    def __init__(self):

        # our irc-object
        self.irc = IRC(self.update_window2)

        # init the screen
        self.scr = curses.initscr()
        curses.noecho()
        curses.cbreak()
        self.scr.keypad(1)

        # init the first window as status window
        y, x = self.scr.getmaxyx()
        self.statuswin = curses.newwin(1, x, y - 2, 0)
        self.statuswin.addstr(0, 0, "[NOT CONNECTED]")

        # staus win 2 who@where
        statuswin2W = 10
        self.statuswin2 = curses.newwin(1, statuswin2W, y - 1, 0)
        self.statuswin2.addstr(0, 0, "NICK")

        # type win
        self.typewin = curses.newwin(1, x - statuswin2W - 1, y - 1,
                                     statuswin2W - 1)
        self.typewin.keypad(1)

        # message win
        self.messagewin = curses.newwin(
            y - 2, x - 13, 0,
            0)  # nick lengt is 9 char should be done dynamically
        # so that windows size should depend on nick lenghts

        # nick win
        self.nickwin = curses.newwin(y - 2, 13, 0,
                                     x - 13)  # should also be dynamic

        self.textbuffer = EditBuffer()  # edit buffer for text input

        # list of our window (channel)
        self.mwindows = list()
        self.active_mwindow = 0

        # refresh the windows
        self.messagewin.refresh()
        self.statuswin.refresh()
        self.statuswin2.refresh()
        self.typewin.refresh()

    def update_status(self):
        # update the status bar
        self.statuswin.erase()
        chan = self.mwindows[self.active_mwindow]
        channelsupdated = ''
        for channel in self.mwindows:
            if channel.updated == 1:
                channelsupdated += " [" + str(
                    self.mwindows.index(channel)) + "]"

        self.statuswin.addstr(
            0, 0, '[' + chan.server + '] ' + chan.name + ' ' +
            str(self.mwindows.index(chan)) + ' ' + channelsupdated)

    def update_nickwin(self):
        self.nickwin.erase()
        chan = self.mwindows[self.active_mwindow]
        x = 0
        maxy, maxx = self.scr.getmaxyx()
        maxy = (maxy - (len(self.textbuffer.lines) - 1))
        for user in chan.users:
            self.nickwin.addstr(x, 0, user.status + user.nick)
            x = x + 1
            if x + 3 > maxy:  # break if too many nicks to fit window
                break
        self.nickwin.refresh()

    def resizewindows(self):
        numlines = ((len(self.textbuffer.lines) - 1))
        if numlines < 1:
            numlines = 0

        # numlines is according to typewin

        # init the first window as status window
        y, x = self.scr.getmaxyx()

        self.statuswin = curses.newwin(1, x, (y - (2 + numlines)), 0)
        #self.statuswin.addstr(0,0,"[NOT CONNECTED]")

        # staus win 2 who@where
        statuswin2W = 10
        self.statuswin2 = curses.newwin((1 + numlines), statuswin2W,
                                        (y - (1 + numlines)), 0)
        self.statuswin2.addstr(0, 0, "NICK")

        # type win
        self.typewin = curses.newwin((1 + numlines), x - statuswin2W - 1,
                                     (y - (1 + numlines)), statuswin2W - 1)
        self.typewin.keypad(1)

        # message win
        self.messagewin = curses.newwin(
            (y - (2 + numlines)), x - 13, 0,
            0)  # nick lengt is 9 char should be done dynamically
        # so that windows size should depend on nick lenghts

        # nick win
        self.nickwin = curses.newwin((y - (2 + numlines)), 13, 0,
                                     x - 13)  # should also be dynamic

        # refresh the windows
        self.update_window()

    # draw the window again
    def update_window(self):
        channel = self.mwindows[self.active_mwindow]

        self.draw_lines_to_message_win(channel)
        self.update_status()
        self.update_nickwin()
        # refresh the windows
        self.messagewin.refresh()
        self.statuswin.refresh()
        self.statuswin2.refresh()
        self.typewin.refresh()

    def update_window2(self, channel, network, command):
        if command == 'NEWWINDOW':
            self.mwindows.append(channel)
            self.active_mwindow = len(self.mwindows) - 1
        elif command == 'REMOVEWINDOW':
            self.active_mwindow = 0
            self.mwindows.remove(channel)
            self.update_window()
        elif command == 'NAMES':
            self.update_nickwin()  # fix later
        if self.mwindows[self.active_mwindow] == channel:
            for chanwin in self.mwindows:
                if chanwin.name == channel.name:
                    self.draw_lines_to_message_win(channel)
        else:  # mark channel updated
            for chanwin in self.mwindows:
                if chanwin.name == channel.name:
                    channel.updated = 1

        self.update_status()
        self.update_nickwin()
        # refresh the windows
        self.messagewin.refresh()
        self.statuswin.refresh()
        self.statuswin2.refresh()
        self.typewin.refresh()

    def get_time(self, loctime):
        # example
        # strftime("%a, %d %b %Y %H:%M:%S", loctime)
        # 'Sun, 24 Apr 2005 13:46:24'
        return strftime("%H:%M", loctime)

    def draw_lines_to_message_win(self, channel, uplines=0):
        # mark that we have seen the channel
        channel.updated = 0

        # This is f****d up. Write better when time
        # first clear the window
        self.messagewin.erase()
        lines = channel.lines[:(len(channel.lines) - channel.linecount)]
        mwy, mwx = self.messagewin.getmaxyx()
        currentline = 0
        lines.reverse()
        # get the lines for lines
        splittedlines = list()

        # check the length of the time prefix
        prefixlength = (len(self.get_time(localtime())) + 1
                        )  # +1 for one space
        for line in lines:
            # if the sender is nick (it has ! in it) cut the host for now
            # REMEMBER TO FIX LATER
            nik = line.sender.find('!')
            if nik > 0:
                nikki = line.sender[0:nik]
            else:
                nikki = line.sender

            linetime = self.get_time(line.time) + ' '

            justwords = line.text.split(' ')
            justwords2 = list()
            pituus2 = (mwx - 1 - (len(nikki) + 3 + prefixlength)
                       )  # carefull with the parenthesis

            for word in justwords:
                x = 0
                if len(word) > pituus2:
                    while len(word[x:len(word)]) > pituus2:
                        justwords2.append(word[x:(x + pituus2)])
                        x = x + pituus2
                    justwords2.append(word[x:len(word)])
                else:
                    justwords2.append(word)

            # now all the words should be nice length
            sline = linetime + '<' + nikki + '> '
            templines = list()
            for word in justwords2:
                if len(sline) + len(word) < mwx:
                    if len(sline) == len(nikki) + 3 + prefixlength:
                        sline = sline + '' + word
                    else:
                        sline = sline + ' ' + word
                else:
                    templines.append(sline)
                    sline = linetime + '<' + nikki + '> ' + word
            templines.append(sline)

            templines.reverse()
            splittedlines.extend(templines)

        numlines = len(splittedlines)

        # put the splitted lines to screen
        for line in splittedlines:
            if currentline < mwy:
                try:
                    self.messagewin.addstr(mwy - currentline - 1, 0, line)
                except:
                    self.messagewin.addstr(mwy - currentline - 1, 0,
                                           'FATAL ERROR')
                currentline = currentline + 1
            else:
                break
        lines.reverse()

    def start(self):
        self.irc.connect('ORJAnet', '192.168.1.2', 6667, 'petteri', 'asd2dasv',
                         'dyksi')
        self.irc.start()

        currentserver = 0
        self.mwindows.append(self.irc.messages)
        #self.irc.connect('EFnet','someseerver',6667,'pzq2','asd2dasv','dyksi',self.update_window2)
        pirssion = 1
        # lets take some key input this just a quick method. Remember to fix later
        while pirssion == 1:
            enterpushed = 0
            oldlen = 0
            gotalt = 0  # for alt characters
            self.textbuffer.reset()
            while enterpushed == 0:
                isinlist = 0
                ty, tx = self.typewin.getmaxyx()
                ch = self.typewin.getch(self.textbuffer.y, self.textbuffer.x)
                if ch > 0:
                    if ch == 10:  # enter
                        enterpushed = 1
                    elif ch in (curses.KEY_PPAGE,
                                curses.ascii.STX):  # page up also ctrl-b
                        self.mwindows[self.active_mwindow].page_up()
                        self.update_window()
                        ch = 0
                    elif ch in (curses.KEY_NPAGE,
                                curses.ascii.EOT):  # page down also ctrl-d
                        self.mwindows[self.active_mwindow].page_down()
                        self.update_window()
                        ch = 0
                    else:
                        name = curses.keyname(ch)
                        if gotalt == 1:
                            for altchar in list(
                                    '123456789'):  #change the window
                                if ch == ord(altchar):
                                    isinlist = 1
                                    window_number = int(altchar) - 1
                                    if len(self.mwindows) > window_number:
                                        self.active_mwindow = window_number
                                        self.update_window()
                                    ch = 0  # delete the character
                            gotalt = 0
                        if name.startswith("M-") or name.startswith(
                                "m-") or name.startswith("^["):  # get alt/meta
                            gotalt = 1
                        if ch > 0:
                            lines = self.textbuffer.input(ch, ty, tx)
                            # update the typewindow
                            self.typewin.erase()
                            if len(lines) != oldlen:
                                self.resizewindows()
                                oldlen = len(lines)
                            linecounter = 0
                            wholestring = ''
                            for line in lines:
                                self.typewin.addstr(linecounter, 1, line)
                                wholestring = wholestring + line
                                linecounter = linecounter + 1
                            self.typewin.refresh()
            # enter has been pushed, back to normal window sizes
            self.resizewindows()

            #put our message to channel or status screen
            self.putmessagetoscreen(wholestring)
            self.update_window()
            channel = self.mwindows[self.active_mwindow].name
            self.irc.message(wholestring,
                             self.mwindows[self.active_mwindow].server,
                             channel)
            self.typewin.erase()

        curses.nocbreak()
        stdscr.keypad(0)
        curses.echo()
        curses.endwin()

    def putmessagetoscreen(self, inputstring):
        chan = self.mwindows[self.active_mwindow]
        # dirty hack FIX LATER
        try:
            nick = self.irc.get_server(chan.server).nick
        except:
            nick = 'pyRKKI ERROR: NOT CONNECTED'
        chan.add_line(IRCMessage(str(nick), 'itse', inputstring, localtime()))
        self.update_window()
Exemplo n.º 14
0
def main(torBool, sslBool):
    global shodanAPI
    global irc
    global botNick
    global channel
    global botPassword
    global email

    ##Shodan
    shodanAPI = shodan.Shodan(shodanKey)

    ##TOR
    if (False):
        tor = TOR(controlPort, torKey)
        tor.torConnect()

    ##IRC
    irc = IRC(serverAddress, ircPort, True, True, socksPort)
    irc.bootStrap(botNick, channel)

    flag = True
    while flag:
        text = irc.getText()
        if (text != None):
            print text

            #NickServ and Bot Name
            if ("NOTICE" in text and "This nickname is registered" in text):
                irc.nickServIdentify(botPassword)
            elif ("NickServ" in text and "PRIVMSG" in text
                  and "is not a registered nickname" in text):
                irc.nickServRegister(botPassword, email)
            elif ("JOIN :You have not registered\r\n" in text):
                irc.nickServRegister(botPassword, email)
                irc.nickServIdentify(botPassword)
                irc.nick(botNick)
                irc.join(channel)
            elif ("PRIVMSG" in text and channel in text
                  and "Nickname is already in use" in text):
                botNick = "IfNot" + botNick
                irc.nick(botNick)

            #Bot Functions
            elif ("PRIVMSG" in text and channel in text and "?help" in text):
                irc.send(channel, "?help, ?about, ?shodan host")
            elif ("PRIVMSG" in text and channel in text
                  and "?shodan host" in text):
                try:
                    user = re.search(r':(.*)!', text).group(1)
                    host = re.search(r'\?shodan host (.*)\r\n', text).group(1)
                    print '[+] User:'******'[+] URL: ' + host
                except AttributeError:
                    pass
                shodanHost(host, user)
            elif (("JOIN :" + channel + "\r\n") in text
                  and "NOTICE" not in text and botNick not in text):
                try:
                    user = re.search(r':(.*)!', text).group(1)
                    irc.send(channel, "hey " + user)
                except AttributeError:
                    pass
            elif ("PRIVMSG" in text and channel in text and "?about" in text):
                irc.send(channel, "PikeBot V0.1 By:NotPike")
            elif ("PRIVMSG" in text and channel in text and killWord in text):
                try:
                    user = re.search(r':(.*)!', text).group(1)
                    if (user == ownerNick):
                        flag = False
                        irc.part(channel, partMsg)
                        irc.close()
                        sys.exit(0)
                    else:
                        irc.send(channel, "try harder")
                except AttributeError:
                    pass

            #Error handling
            elif ("ERROR :Closing link:" in text):
                print "[!] Reconnecting..."
                irc.close()
                irc.restart()
                irc.bootStrap(botNick, channel)

        else:
            print "[!] Reconnecting..."
            irc.close()
            irc.restart()
            irc.bootStrap(botNick, channel)
Exemplo n.º 15
0
def sendMsg(server,cChannel,msg):
    if "\n" in msg or len(msg) > 400:
        #If there are new lines in the msg
        if "\n" in msg:
            #Just split it into new lines.
            msgSplit=msg.split("\n")
        #Else, if the message is bigger then 400 characters
        else:
            #split the message into 400 characters
            msgSplit=[]
            iMsg=msg
            while (len(iMsg) > 400):
                msgSplit.append(iMsg[:400])
                iMsg=iMsg[400:]
            msgSplit.append(iMsg)

        newMsgSplit=[]
        #Loop through the msgSplit to see if any of the messages are more then 400 characters
        for i in range(0,len(msgSplit)):
            if len(msgSplit[i]) > 400:
                #If this message is bigger then 400 characters then split it.
                iMsg=msgSplit[i]
                while (len(iMsg) > 400):
                    newMsgSplit.append(iMsg[:400])
                    iMsg=iMsg[400:]
                newMsgSplit.append(iMsg)
            else:
                #If this message is not bigger then 400 characters, then add it to the new list without spliting it.
                newMsgSplit.append(msgSplit[i])
        msgSplit=newMsgSplit

        #Loops through the parts of the message(the split message)
        for i in range(0,len(msgSplit)):
            if msgSplit[i] != "":
                import time
                instantMsg=False #If this is set to true the message won't be added to the msg buffer.
                #Loops through the channels to find the right channel, to append the new msgBuffer
                for ch in server.channels:
                    usrDest=IRC.user() #Made it not None, it couses a bug with or ch.cName == usrDest.cChannel.cName, so i changed it to this...
                    if cChannel.startswith("#") == False:
                        for usr in ch.cUsers:
                            if usr.cNick == cChannel:
                                usrDest=usr
                    if ch.cName == cChannel or ch.cName == usrDest.cChannel.cName:
                        channel=ch       
                        pDebug("Setting channel to " + ch.cName)

                #If this message is the 5th message to be sent in a row, then add >the number of sendInstantly equal to False msgBuffers< * 3
                #(So it waits 3 times the number of non instantly sent messages, to send this message.)
                if i >= 5:
                    time=time.time() + (3*(len(channel.cMsgBuffer)+1))
                elif i < 5 and len(channel.cMsgBuffer) != 0:
                    time=time.time() + (3*(len(channel.cMsgBuffer)+1))
                #Else, this is a message to be sent instantly.
                else:
                    cmdSendMsg(server,cChannel,msgSplit[i])
                    instantMsg=True

                if instantMsg != True:
                    msgBuff=IRC.msgBuffer()
                    msgBuff.msg=msgSplit[i]
                    msgBuff.sendTimestamp=time
                    msgBuff.dest=cChannel

                    channel.cMsgBuffer.append(msgBuff)
                    #Call all the onByteSendChange events
                    for event in IRC.eventFunctions:
                        if event.eventName == "onByteSendChange" and event.cServer == server:
                            gobject.idle_add(event.aFunc,server,len(channel.cMsgBuffer))


    else:
        msgSent = False
    
        for ch in server.channels:
            usrDest=IRC.user() #Made it not None, it couses a bug with or ch.cName == usrDest.cChannel.cName, so i changed it to this...
            if cChannel.startswith("#") == False:
                for usr in ch.cUsers:
                    if usr.cNick == cChannel:
                        usrDest=usr

            if ch.cName == cChannel or ch.cName == usrDest.cChannel.cName:
                #If the msgBuffer(msg queue) has no messages waiting to be sent, send this message right now.
                if len(ch.cMsgBuffer) == 0:
                    cmdSendMsg(server,cChannel,msg)
                    msgSent = True
                    break
                #If the msgBuffer(msg queue) has messages waiting, add this new message to the end of the queue.
                else:
                    import time
                    instantMsg=False #If this is set to true the message won't be added to the msg buffer.
                    #If this message is the 5th message to be sent in a row, then add >the number of sendInstantly equal to False msgBuffers< * 3
                    #(So it waits 3 times the number of non instantly sent messages, to send this message.)
                    if len(ch.cMsgBuffer) >= 5:
                        time=time.time() + (3*(len(ch.cMsgBuffer)+1))
                    #Else, this is a message to be sent instantly.
                    else:
                        cmdSendMsg(server, ch.cName, msg)
                        instantMsg = True
                        msgSent = True

                    if instantMsg != True:
                        msgBuff=IRC.msgBuffer()
                        msgBuff.msg=msg
                        msgBuff.sendTimestamp=time
                        msgBuff.dest=cChannel
                        ch.cMsgBuffer.append(msgBuff)
                        pDebug("\033[1;31mAdded to " + ch.cName)
                        #Call all the onByteSendChange events
                        for event in IRC.eventFunctions:
                            if event.eventName == "onByteSendChange" and event.cServer == server:
                                gobject.idle_add(event.aFunc,server,len(ch.cMsgBuffer))

                    break
                    
        #If you can't find a message buffer for a channel or a user, just send the message
        #TODO: Maybe make it add to the server buffer ??
        if msgSent == False:
            cmdSendMsg(server, cChannel, msg)
Exemplo n.º 16
0
import FileHandler
import IRC

fh = FileHandler.FileHandler()
options = fh.getOptions("twitch.ini")
chat = IRC.ircClient(options)
chat.connect()
run = True
while chat.run:
	chat.recive()
chat.disconnect()
Exemplo n.º 17
0
def main(torBool, sslBool):
    global shodanAPI
    global irc
    global botNick
    global channel
    global botPassword
    global email

    ##Shodan
    shodanAPI = shodan.Shodan(shodanKey)

    ##TOR
    if (False):
        tor = TOR(controlPort, torKey)
        tor.torConnect()

    ##IRC
    irc = IRC(serverAddress, ircPort, True, True, socksPort)
    irc.bootStrap(botNick, channel, True, True)

    flag = True
    while flag:
        text = irc.getText()
        if (text != None):
            print text

            if ("NOTICE" in text and "This nickname is registered" in text):
                irc.send('NickServ', 'VERIFY REGISTER PikeBot iwwxzqbtrwsc')
                irc.nickServIdentify(botPassword)
            elif ("NickServ" in text and "PRIVMSG" in text
                  and "is not a registered nickname" in text):
                irc.nickServRegister(botPassword, email)
            elif ("PRIVMSG" in text and channel in text and "?help" in text):
                irc.send(channel, "?help, ?about, ?shodan host")
            elif ("PRIVMSG" in text and channel in text
                  and "?shodan host" in text):
                try:
                    user = re.search(r':(.*)!', text).group(1)
                    host = re.search(r'\?shodan host (.*)\r\n', text).group(1)
                    print '[+] User:'******'[+] URL: ' + host
                except AttributeError:
                    pass
                shodanHost(host, user)
            elif (("JOIN :" + channel + "\r\n") in text
                  and "NOTICE" not in text and botNick not in text):
                try:
                    user = re.search(r':(.*)!', text).group(1)
                    #irc.send(channel, "hey " + user + ". " + "how's it going?")
                except AttributeError:
                    pass
            elif ("PRIVMSG" in text and channel in text and "?about" in text):
                irc.send(channel, "PikeBot V0.1 By:NotPike")
            elif ("PRIVMSG" in text and channel in text
                  and "Nickname is already in use" in text):
                botNick = "IfNot" + botNick
                irc.bootStrap(botNick, channel, True, True)
            elif ("ERROR :Closing link:" in text):
                irc.close()
                print "[!] Reconnecting..."
                time.sleep(5)
                irc.bootStrap(botNick, channel, True, True)
            elif ("JOIN :You have not registered\r\n" in text):
                irc.nickServRegister(botPassword, email)
                irc.nickServIdentify(botPassword)
                irc.nick(botNick)
                irc.join(channel)

        else:
            irc.close()
            print "[!] Reconnecting..."
            time.sleep(5)
            irc.bootStrap(botNick, channel, True, True)
Exemplo n.º 18
0
import globals
import IRC

#print(globals.channel)

IrcClient = IRC.IRC("irc.chat.twitch.tv", 6667,
                    "#" + globals.channel.user_name, globals.channel.user_name,
                    "robost4r", 'oauth:' + globals.channel.secret)

IrcClient.main()
Exemplo n.º 19
0
import os
import shlex
import random
from IRC import *
from dcc import *

query = raw_input("Book title: ")

## IRC Config
server = "irc.irchighway.net"
port = 6667
channel = "#ebooks"
botnick = "bOOkbot"
irc = IRC()
irc.connect(server, port, channel, botnick)

irc.send("#ebooks", "@search " + query)

while True:
    text = irc.get_response()
    #if text.find('PRIVMSG') != -1: #see all messages, for fun
    #    print(text)
    if "DCC SEND" in text:
        print(text)
        break

dccString = text.split("DCC SEND ", 1)[1].replace('\x01', '')
dccString = shlex.split(dccString)

downloadfile(dccString)