Пример #1
0
    def hivemindStart(self):
        if self.irc != None:
            msgBox = QMessageBox()
            msgBox.setText("Hivemind is already running.")
            if self.server == str(self.defTab.server):
                msgBox.setInformativeText("Do you want to change channel?")
            else:
                msgBox.setInformativeText("Do you want to change server?")
            msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
            msgBox.sethivemindButton(QMessageBox.Cancel)
            ret = msgBox.exec_()

            if ret == QMessageBox.Cancel:
                return

            if self.server == str(self.defTab.server.text()):
                self.channel = str(self.defTab.channel.text())
                self.irc.changeChannel(str(self.defTab.channel.text()))
            else:
                irc.disconnect()
                irc.host = str(self.defTab.server.text())
                irc.port = int(self.defTab.port.text())
                irc.channel = str(self.defTab.channel.text())
                irc.connect()

        self.server = str(self.defTab.server.text())
        self.port = int(self.defTab.port.text())
        self.channel = str(self.defTab.channel.text())

        if self.irc == None:
            self.irc = IRC(self.server, self.port, self.channel)
Пример #2
0
	def _do_connect(self):
		host = self.ircServ.get().strip()
		if len(host) == 0:
			getEventManager().signalEvent(Event(ERR,"Invalid Server"))
			return
		port = None
		try:
			port = int(self.ircPort.get().strip())
		except:
			getEventManager().signalEvent(Event(ERR,"Invalid Port"))
			return
		channel = self.ircChan.get().strip()
		if len(channel) == 0:
			getEventManager().signalEvent(Event(ERR,"Channel Needed"))
			return
 		if channel[0] != '#':
			getEventManager().signalEvent(Event(ERR,"Invalid Channel"))
			return
		if self.irc:
			Thread(target=self.irc.disconnect,args=()).start()

		self.irc = IRC(host,port,channel)
		Thread(target=self.irc.connect,args=()).start()
Пример #3
0
def main(args):
    global irc, flooder, socks5ip, socks5port

    getEventManager().addListener(LAZER_RECV, lazerParseHook)
    getEventManager().addListener(START_LAZER, lazerStartHook)
    getEventManager().addListener(IRC_RESTART, restartIRCHook)

    try:
        host = args[1]
        port = int(args[2])
        channel = args[3]
        if len(args[4:]):
            try:
                opts, argv = getopt.getopt(args[4:], "ts:", ["tor","socks5="])
            except getopt.GetoptError:
                print "Usage: python main.py <hivemind irc server> <irc port> <irc channel> [--tor] [--socks5=ip:port]"
                sys.exit()

            for o, a in opts:
                if o in ("-t", "--tor"):
                    socks5ip = "127.0.0.1"
                    socks5port = 9050
                elif o in ("-s", "--socks5"):
                    socks5 = a.split(':')
                    socks5ip = socket.gethostbyname(socks5[0])
                    socks5port = int(socks5[1])

    except (ValueError, IndexError):
        print "Usage: python main.py <hivemind irc server> <irc port> <irc channel> [--tor] [--socks5=ip:port]"
        sys.exit()

    if channel[0] != '#':
        channel = '#' + channel

    getEventManager().start()

    irc = IRC(host, port, channel)

    while running:
        try:
            i = raw_input()
            if i.find("connect") == 0:
                info = i.split(" ")
                print info
                if len(info) == 4 and info[2].isdigit():
                    newhost = info[1]
                    newport = int(info[2])
                    newchannel = info[3].replace("\\", "")
                    if newhost == host and newport == port and irc.connected:
                        print "changing channel to", newchannel
                        irc.changeChannel(newchannel)
                        channel = newchannel
                    else:
                        host = newhost
                        port = newport
                        channel = newchannel
                        print "changing host to", host, port, channel
                        irc.disconnect()
                        irc.host = host
                        irc.port = port
                        irc.channel = channel
                        irc.connect()
                else:
                    print "not enough info. connect server port channel"
            elif i == "stopflood":
                if flooder:
                    flooder.stop()
            elif i == "startflood":
                if flooder:
                    flooder.start()
            elif i == "floodcount":
                if flooder:
                    print flooder.floodCount()
            elif i == "quit" or i == "exit":
                irc.disconnect()
                if flooder:
                    flooder.stop()
                getEventManager().stop()
                break
        except KeyboardInterrupt:
            irc.disconnect()
            if flooder:
                flooder.stop()
            getEventManager().stop()
            break

    time.sleep(1)
    sys.exit()