Exemple #1
0
def cmd_banner( self, command, params, event, received="channel" ):
        """{0}!X!- Print an ASCII Banner
                {0} <BANNER>!X!- Print <BANNER>
                {0} <BANNER> <CHANNEL>!X!- Print <BANNER> in <CHANNEL>"""

        rec = event.target
        if received == "private":
                rec = event.source
        if len( params ) > 1:
                rec = params[1]

        banner = None
        if params[0] == "text":
                banner = (format.BLUE, requests.get( "https://artii.herokuapp.com/make", params={"text": " ".join(params[2:])}).text.splitlines())
        elif params[0] == "graffiti":
                banner = (format.BLUE, requests.get( "https://artii.herokuapp.com/make", params={"text": " ".join(params[2:]), "font": "graffiti"}).text.splitlines() )
        elif params[0] in banners:
                banner = banners[params[0]]
        else:
                self.send_message( rec, format.color( "ERROR:", format.RED ) + " Banner not found" )
                return

        for line in banner[1]:
                self.send_message( rec, format.color( format.bold( line ), banner[0], format.BLACK ) )
                time.sleep( 0.5 )
Exemple #2
0
 def on_join(self, event):
     message = '{0}: {1} [{2}]'.format(format.color(format.bold('Uploaded patch diff'), format.GREEN),
                                         format.color(format.bold(self.patch), format.DARK_GRAY),
                                         self.address + self.patch.replace(' ', '_') + '#Files_changed'
                                         )
     self.send_message(event.target, message)
     self.quit()
Exemple #3
0
 def announce(self, submission, channel):
     msg = self.MSG_FORMAT.format(
         url=submission.url,
         permalink=submission.permalink,
         shortlink=format.color(submission.short_link[7:], format.RED),
         subreddit=format.color(text_type(submission.subreddit), format.GREEN),
         author=format.color(text_type(submission.author), format.GREEN),
         title=submission.title,
     ).encode("utf-8")
     msg = format.color(re.sub("\s+", " ", msg).strip(), format.GREEN)
     if debug:
         print(msg)
     msg = format.bold(msg)
     self.send_action(channel, msg)
Exemple #4
0
def cmd_shout( self, command, params, event, received="channel" ):
        """ {0}!X!- Shout a Text
                {0} <TEXT>!X!- Shout <TEXT> in current channel
                {0} <CHANNEL> <TEXT>!X!- Shout <TEXT> in channel <CHANNEL> (/msg only)"""

        colors = [ format.GREEN, format.RED, format.AQUA ]
        if received == "private":
                for color, bg in [(x,y) for x in colors for y in colors if not x == y]:
                        self.send_message( params[0], format.color( ' '.join( params[1:] ).strip(), color, bg ) )
                        time.sleep( 0.5 )
        else:
                for color, bg in [(x,y) for x in colors for y in colors]:
                        self.send_message( event.target, format.color( ' '.join( params ).strip() , color, bg ) )
                        time.sleep( 0.5 )
Exemple #5
0
    def on_channel_message( self, event ):
        message = event.message.split()
        command = message[0]
        params  = message[1:]
        self.currentNick = event.source

        if event.source not in self.tell:
            self.tell[event.source] = False

        if command[0] == "!": # only handle commands directed to us...
            if len( command ) == 1: # skip single !'s and stuff
                return

            command =  command[1:].lower()
            if command in self.commands: # ... that exist
                ( level, func ) = self.commands[ command ]

                for name in self.channelusers[ event.target ]:
                    if protocol.strip_name_symbol( name ) == event.source: break # name is now event.target's name

                ulevel = 0
                if name[0] in self.access: # do not handle 'empty' users
                    ulevel = self.access[ name[0] ]

                if  ulevel < self.access[ level ]:
                    self.send_message( event.target, format.color( "ERROR:", format.RED ) + " You are not allowed to use the " + format.bold( command ) + " Command" )
                    return
                func( self, command, params, event )
        elif self.tellre.match(event.message):
            nick = self.tellre.match(event.message).groups()[0]

            if nick in self.tell and self.tell[nick] != False: # known but nont online
                self.tell[nick].append((time.gmtime(), event.target, "{}: {}".format(event.source, format.color(event.message, format.GREEN))))
                self.send_message(event.target, "I'll pass that on to {}".format(nick))
Exemple #6
0
def cmd_help( self, command, params, event, received="channel" ):
        """ {0}!X!- Help for commands
                {0}!X!- List commands
                {0} <COMMAND>!X!- Help for <COMMAND>"""

        if len( params ) < 1:
                self.send_message( event.source, "List of commands:" )
                for cmd in self.commands:
                        self.send_message( event.source, format.color( "## ", format.LIME_GREEN ) + '{:<20} {}'.format( *self.commands[ cmd ][1].__doc__.format( format.bold( format_command( cmd, received ) ) ).splitlines()[0].strip().split( "!X!", 1 ) ) ) # split and justify
                return
        if params[0].lower() in self.commands:
                self.send_message( event.source, "Usage info for command {0}:".format( format.bold( params[0] ) ) )
                for line in self.commands[ params[0].lower() ][1].__doc__.format( *[ format.bold( format_command( c, received ) ) for c in params ] ).splitlines():
                        self.send_message( event.source, format.color( "## ", format.LIME_GREEN ) + '{:<35} {}'.format( *line.strip().split( "!X!", 1 ) ) ) # split and justify
        else:
                self.send_message( event.source, "Unkown Command {0}.".format( format.bold( params[0] ) ) )
Exemple #7
0
 def on_private_message(self, event):
     print("(PRIVATE %r) <%s> %s" % (self.server, event.source, event.message))
     if event.source == "Nick" or event.source == "@Nick":
         if event.message == "terminate":
             self.disconnect("I am promised a bag of fish")
             sys.exit(0)
         else:
             self.send_action("#channel", format.color(event.message, format.GREEN))
Exemple #8
0
    def on_join( self, event ):
        if event.source != self.nickname: # don't welcome yourself
            self.send_message( event.target, "Welcome to " + format.color( format.bold( ' LTFU :' ), format.BLACK, format.LIGHT_GRAY ) + format.color( ': hangout ', format.WHITE, format.GREEN ) + ", " +  format.bold( event.source ) )

        if event.source in self.tell and self.tell[event.source] != False:
            for m in self.tell[event.source]:
                self.send_message( m[1], "[{}] {}".format(time.strftime("%H:%M", (m[0])), m[2]) )

        self.tell[event.source] = False # False = online but known
Exemple #9
0
def cmd_mutesb( self, command, params, event, received="channel" ):
        """ {0}!X!- Toggle the shoutbox echo for this channel
                {0} <CHANNEL> !X!- Toggle the shoutbox echo for <CHANNEL> (/msg only)"""

        chan = event.target
        if len(params) > 0:
                chan = params[0]

        if chan not in self.channels:
                self.send_message( event.target, "'{}' is not a valid channel".format(chan) )
                return

        self.muted[chan] = (chan not in self.muted) or (not self.muted[chan])
        text = "ON"
        if self.muted[chan]:
                text = "OFF"
        self.send_message( chan, "Shoutbox echoing is now toggled {}".format(format.color(text, format.RED)) )
Exemple #10
0
        def on_private_message( self, event ):
                message = event.message.split()
                command = message[0].upper()
                params  = message[1:]

                if command.lower() in self.commands:
                        ( level, func ) = self.commands[ command.lower() ]

                        for name in self.channelusers[next(iter(self.channels))]: # FIXME: random channel
                                if protocol.strip_name_symbol( name ) == event.source: break # name is now event.target's name

                        ulevel = 0
                        if name[0] in self.access: # do not handle 'empty' users
                                ulevel = self.access[ name[0] ]

                        if ulevel < self.access[ level ]:
                                self.send_message( event.source, format.color( "ERROR:", format.RED ) + " You are not allowed to use the " + format.bold( command ) + " Command" )
                                return
                        func( self, command, params, event, received="private" ) # tell the function this was a private message and call it
Exemple #11
0
	def process_queue(self, event):
		actions = IRCAction.objects.filter(performed=False)
		for each in actions:
			c = each.command.command.split()
			if c[0] == "MODE":
				self.execute( str(c[0]), str(event.target), str(c[1]), str(each.target) )
			else:
				if each.args:
					if each.command.color:
						output = format.color( str(each.args), format.RED )
					else:
						output = str(each.args)
				if each.target and each.args:
					self.execute( str(c[0]), str(event.target), str(each.target), trailing=output )
				elif each.target:
					self.execute( str(c[0]), str(event.target), str(each.target) )
				else:
					self.execute( str(c[0]), str(event.target), trailing=output )

			each.performed = True
			each.save()
Exemple #12
0
        def on_channel_message( self, event ):
                message = event.message.split()
                command = message[0]
                params  = message[1:]

                if len( command ) == 1: # skip single !'s and stuff
                        return

                if command[0] == "!": # only handle commands directed to us...
                        command =  command[1:].lower()
                        if command in self.commands: # ... that exist
                                ( level, func ) = self.commands[ command ]

                                for name in self.channelusers[ event.target ]:
                                        if protocol.strip_name_symbol( name ) == event.source: break # name is now event.target's name

                                ulevel = 0
                                if name[0] in self.access: # do not handle 'empty' users
                                        ulevel = self.access[ name[0] ]

                                if  ulevel < self.access[ level ]:
                                        self.send_message( event.target, format.color( "ERROR:", format.RED ) + " You are not allowed to use the " + format.bold( command ) + " Command" )
                                        return
                                func( self, command, params, event )
                currentPgTxt = adminWiki.page( currentPgStr )
                
				appendTxt = ''
                if not currentPg.endswith('\n'):
                        appendTxt = '\n'
                appendTxt = appendTxt + time.strftime("| %a | %b %d | %I:%M %p | ", time.localtime(timeInt) )
                adminWiki.appendPage(event.source, appendTxt, '', False)
                global joinDict
                joinDict[event.source] = timeInt
        #Admin Bot Greeting
        if msgQ != []:
                self.send_message(event.source, 'Here are the last 5 messages in ' + event.target + '!  Enjoy!')

                for item in reversed(msgQ):
                        test = []
                        test.append(format.color(item[0], format.GREEN))
                        test.append(format.color(item[1], format.RED))
                        test.append(format.color(': '+item[2], format.NAVY_BLUE))
                        test.append(format.color(item[3], format.PURPLE))
                        self.send_message(event.source, 'In channel ' + test[0] + ' ' + test[1] + ' said' + test[2] + ' @ ' + test[3])
        else:
                self.send_message(event.source, 'There are no previous messages in ' + event.target + '.')
				
        self.send_message(event.source, 'Thank you!')				
				
    def on_private_message(self, event):

        msg = event.message.split()
        cmd = msg[0].upper()
        params = msg[1:]
Exemple #14
0
def cmd_color( self, command, params, event ):
    if re.match(r"^([a-zA-Z]+|#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}))+$", params[0]):
        self.colors[event.source] = params[0]
    else:
        self.send_message( event.target, format.color( "ERROR:", format.RED ) + " not a valid color: '{}'".format(params[0]) )
Exemple #15
0
 def shoutbox(self, name, message):
     if self.is_connected():
         for chan in self.channels:
             if (chan not in self.muted) or (not self.muted[chan]):
                 self.send_message( chan, "{}: {}".format(format.color(name, format.RED), message) )
 def process_line(self, line, is_test=False):
     l = NagiosLogLine(line)
     is_ack = False
     if l.is_service:
         state_string = None
         if re.search("ACKNOWLEDGEMENT", l.state):
             is_ack = True
             state_string = format.color(l.state, format.BLUE)
         elif l.state == "OK":
             state_string = format.color(l.state, format.GREEN)
         elif l.state == "WARNING":
             state_string = format.color(l.state, format.YELLOW)
         elif l.state == "UNKNOWN":
             state_string = format.color(l.state, format.YELLOW)
         elif l.state == "CRITICAL":
             state_string = format.color(l.state, format.RED)
         else:
             state_string = format.color(l.state, format.RED)
         if is_ack is False:
             self.ackable(l.host, l.service, l.state, l.message)
             try:
                 write_string = "[%i] %s:%s is %s: %s" % (self.get_ack_number() , l.host, l.service, state_string, l.message)
             except:
                 write_string = "%s:%s is %s: %s" % (l.host, l.service, state_string, l.message)
         else:
             #message = "%s;%s" % (m.group(3).split(";")[4], m.group(3).split(";")[5])
             write_string = "%s:%s is %s: %s" % (l.host, l.service, state_string, l.message)
     else:
         if re.search("ACKNOWLEDGEMENT", l.state):
             is_ack = True
             state_string = format.color(l.state, format.BLUE)
         elif re.search(l.state, "UP"):
             state_string = format.color(l.state, format.GREEN)
         elif re.search(l.state, "WARNING"):
             state_string = format.color(l.state, format.YELLOW)
         elif re.search(l.state, "DOWN"):
             state_string = format.color(l.state, format.RED)
         if is_ack is False:
             self.ackable(l.host, None, l.state, l.message)
             write_string = "[%i] %s is %s :%s" % (self.get_ack_number(), l.host, state_string, l.message)
         else:
             state_string = format.color(l.state, format.BLUE)
             write_string = "%s is %s :%s" % (l.host, state_string, l.message)
     channel = self.get_channel_group(l.notification_recipient)
     if is_test is False:
         if self.is_muted(channel) is False:
             self.connection.send_message(channel, write_string)
     elif channel:
         return channel, write_string
     else:
         return None
Exemple #17
0
 def on_join( self, event ):
         if event.source != self.nickname: # don't welcome yourself
                 self.send_message( event.target, "Welcome to " + format.color( format.bold( ' LTFU :' ), format.BLACK, format.LIGHT_GRAY ) + format.color( ': hangout ', format.WHITE, format.GREEN ) + ", " +  format.bold( event.source ) )
 def status_by_host_name(self, event, message, options):
     conf = self.parseConf(self.status_file)
     service_statuses = []
     if conf is not False:
         hostname = options.group(1)
         try:
             service = options.group(2).upper()
         except:
             service = None
         host_statuses = []
         for entry in conf:
             if service is None:
                 if entry[0] == 'hoststatus':
                     host_statuses.append(entry[1])
                 if entry[0] == 'servicestatus':
                     service_statuses.append(entry[1])
             elif service is not None and '*' not in service:
                 if entry[0] == 'servicestatus' and entry[1]['service_description'].upper() == service:
                     service_statuses.append(entry[1])
             elif service is not None and service == '*':
                 if entry[0] == 'servicestatus':
                     service_statuses.append(entry[1])
             elif service is not None and '*' in service:
                 service_search = service.split('*')[0]
                 if entry[0] == 'servicestatus' and entry[1]['service_description'].upper().startswith(service_search):
                     service_statuses.append(entry[1])
             else:
                 return event.target, "%s Sorry, but I can't find any matching services" % (event.source) 
         ## OK, we've looped through everything and added them to the appropriate lists
         if service is not None and '*' not in service:
             if len(service_statuses) == 0:
                     return event.target, "%s Sorry, but I can't find any matching services" % (event.source) 
             else:
                 output_list = []
                 for entry in service_statuses:
                     if entry['host_name'] == hostname:
                         if entry['current_state'] == '0':
                             state_string = format.color('OK', format.GREEN)
                         if entry['current_state'] == '1':
                             state_string = format.color('WARNING', format.YELLOW)
                         if entry['current_state'] == '2':
                             state_string = format.color('CRITICAL', format.RED)
                         write_string = "%s: %s:%s is %s - %s" % (event.source, hostname, entry['service_description'], state_string, entry['plugin_output'])
                         output_list.append(write_string)
                     elif hostname == '*' and entry['service_description'].upper().strip() == service.upper().strip():
                         if entry['current_state'] == '0':
                             state_string = format.color('OK', format.GREEN)
                         if entry['current_state'] == '1':
                             state_string = format.color('WARNING', format.YELLOW)
                         if entry['current_state'] == '2':
                             state_string = format.color('CRITICAL', format.RED)
                         write_string = "%s: %s:%s is %s - %s" % (event.source, entry['host_name'], entry['service_description'], state_string, entry['plugin_output'])
                         output_list.append(write_string)
                     elif '*' in hostname and entry['service_description'].upper().strip() == service.upper().strip() and hostname.split('*')[0] in entry['host_name']:
                         if entry['current_state'] == '0':
                             state_string = format.color('OK', format.GREEN)
                         if entry['current_state'] == '1':
                             state_string = format.color('WARNING', format.YELLOW)
                         if entry['current_state'] == '2':
                             state_string = format.color('CRITICAL', format.RED)
                         write_string = "%s: %s:%s is %s - %s" % (event.source, entry['host_name'], entry['service_description'], state_string, entry['plugin_output'])
                         output_list.append(write_string)
                     elif '*' in hostname and '*' == service.upper().strip() and hostname.split('*')[0] in entry['host_name']:
                         for entry in service_statuses:
                             if entry['current_state'] == '0':
                                 state_string = format.color('OK', format.GREEN)
                             if entry['current_state'] == '1':
                                 state_string = format.color('WARNING', format.YELLOW)
                             if entry['current_state'] == '2':
                                 state_string = format.color('CRITICAL', format.RED)
                             write_string = "%s: %s:%s is %s - %s" % (event.source, hostname, entry['service_description'], state_string, entry['plugin_output'])
                             output_list.append(write_string)
                     elif  '*' in service.upper().strip().split('*')[0] and hostname.split('*')[0] in entry['host_name']:
                         for entry in service_statuses:
                             if entry['current_state'] == '0':
                                 state_string = format.color('OK', format.GREEN)
                             if entry['current_state'] == '1':
                                 state_string = format.color('WARNING', format.YELLOW)
                             if entry['current_state'] == '2':
                                 state_string = format.color('CRITICAL', format.RED)
                             write_string = "%s: %s:%s is %s - %s" % (event.source, hostname, entry['service_description'], state_string, entry['plugin_output'])
                             output_list.append(write_string)
                 if len(output_list) < self.service_output_limit:
                     return event.target, output_list
                 else:
                     write_string = "%s: more than %i services returned. Please be more specific." % (event.source, self.service_output_limit)
                     return event.target, write_string
         elif service is not None and '*' in service and '*' not in hostname:
             service = service.split('*')[0]
             output_list = []
             for entry in service_statuses:
                 if entry['host_name'] == hostname:
                     if entry['current_state'] == '0':
                         state_string = format.color('OK', format.GREEN)
                     if entry['current_state'] == '1':
                         state_string = format.color('WARNING', format.YELLOW)
                     if entry['current_state'] == '2':
                         state_string = format.color('CRITICAL', format.RED)
                     write_string = "%s: %s:%s is %s - %s" % (event.source, hostname, entry['service_description'], state_string, entry['plugin_output'])
                     output_list.append(write_string)
                 elif '*' in hostname and hostname.split('*')[0] in entry['host_name']:
                     if entry['current_state'] == '0':
                         state_string = format.color('OK', format.GREEN)
                     if entry['current_state'] == '1':
                         state_string = format.color('WARNING', format.YELLOW)
                     if entry['current_state'] == '2':
                         state_string = format.color('CRITICAL', format.RED)
                     write_string = "%s: %s:%s is %s - %s" % (event.source, entry['host_name'], entry['service_description'], state_string, entry['plugin_output'])
                     output_list.append(write_string)
             if len(output_list) < self.service_output_limit:
                 return event.target, output_list
             else:
                 write_string = "%s: more than %i services returned. Please be more specific." % (event.source, self.service_output_limit)
                 return event.target, write_string
         elif service is None and '*' in hostname:
             host = hostname.split('*')[0]
             output_list = []
             for entry in service_statuses:
                 if entry['host_name'].upper().startswith(host.upper()) and entry['service_description'] == 'PING':
                     if entry['current_state'] == '0':
                         state_string = format.color('OK', format.GREEN)
                     if entry['current_state'] == '1':
                         state_string = format.color('WARNING', format.YELLOW)
                     if entry['current_state'] == '2':
                         state_string = format.color('CRITICAL', format.RED)
                     write_string = "%s: %s:%s is %s - %s" % (event.source, entry['host_name'], entry['service_description'], state_string, entry['plugin_output'])
                     output_list.append(write_string)
             if len(output_list) < self.service_output_limit:
                 return event.target, output_list
             else:
                 write_string = "%s: more than %i services returned. Please be more specific." % (event.source, self.service_output_limit)
                 return event.target, write_string
         else:
             host_found = False
             for entry in host_statuses:
                 if entry['host_name'] == hostname:
                     if entry['current_state'] == '0':
                         state_string = format.color('OK', format.GREEN)
                     if entry['current_state'] == '1':
                         state_string = format.color('DOWN', format.RED)
                     if entry['current_state'] == '2':
                         state_string = format.color('DOWN', format.RED)
                     host_found = True
                     write_string = "%s: %s is %s - %s" % (event.source, hostname, state_string, entry['plugin_output'])
             if host_found is False:
                 write_string = "%s Sorry, but I can't find any matching services" % (event.source)
             return event.target, write_string
     else:
         return event.target, "%s: Sorry, but I'm unable to open the status file" % event.source
Exemple #19
0
        usermatches = [s[1] for s in srmatches if s[0] == 'u']
        links = []
        if len(subrootmatches) > 0:
            links.append("http://reddit.com/r/{}".format(
                '+'.join(subrootmatches)))
        for link in suburlmatches:
            links.append("http://reddit.com/r/{}".format(link))
        for link in usermatches:
            links.append("http://reddit.com/u/{}".format(link))
        if len(links) > 0:
            self.send_message(event.respond, ' '.join(links))

    #Imply
    if event.command.lower() in self._prefix('imply'):
        self.send_message(event.respond,
                          format.color(">" + event.params, format.GREEN))

    #DNS
    if event.command.lower() in self._prefix('dns'):
        try:
            records = socket.getaddrinfo(event.params.split(' ')[0], 80)
            addresses = set([x[4][0] for x in records])
            self.send_message(event.respond, " ".join(addresses))
        except:
            self.send_message(event.respond,
                              "You must give a valid host name to look up")

    #Reboot
    if event.command.lower() in self._prefix('reboot'):
        if event.host in self.config.adminhosts:
            self.quit("My primary function is failure.")
Exemple #20
0
    def run( self, username, password, base, log_threads=True ):
        regex = re.compile(r'name="_xfToken" value="([^"]+)"')

        self.session = requests.session()
        res = self.session.post(base + "/login/login", params={"login": username, "password": password})
        res = self.session.get (base + "/forums")

        token = regex.findall(res.text)[0]

        self.base = base
        self.params = {
            "sidebar": 0,
            "lastrefresh": 0,
            "fake": 0,
            "room": 1,
            "_xfRequestUri": "/board/forums/",
            "_xfNoRedirect": 1,
            "_xfToken": token,
            "_xfResponseType": "json"
        }

        i = 0
        old_threads = []
        self.muted = {}

        res = self.session.get(base + "/forums")
        soup = BeautifulSoup(res.text)
        for thread in soup.find_all("li", class_="discussionListItem"):
            url = thread.find(class_="PreviewTooltip")["href"]
            user = thread.find(class_="username").text
            title = thread.find(class_="PreviewTooltip").text
            posts = thread.find("dl", class_="major").find("dd").text

            if posts == "0" and not url in old_threads:
                old_threads.append(url)

        while True:
            i += 1
            res = self.session.post(base + "/taigachat/list.json", params=self.params)
            result = json.loads(res.text)
            self.params["lastrefresh"] = result["lastrefresh"]
            soup = BeautifulSoup( result["templateHtml"] )

            for li in soup.find_all('li'):
                if not "taigachat_message" in (li.get('id') or []):
                    continue
                name = li.find(class_="username").text
                message = li.find(class_="taigachat_messagetext").text
                if self.is_connected() and "a new thread was posted by" not in message:
                    for chan in self.channels:
                        if (chan not in self.muted) or (not self.muted[chan]):
                            self.send_ctcp(chan, "ACTION", ["{}: {}".format(format.color(name, format.RED), message)])

            if log_threads:
                res = self.session.get(base + "/forums")
                soup = BeautifulSoup(res.text)
                for thread in soup.find_all("li", class_="discussionListItem"):
                    url = thread.find(class_="PreviewTooltip")["href"]
                    user = thread.find(class_="username").text
                    title = thread.find(class_="PreviewTooltip").text
                    posts = thread.find("dl", class_="major").find("dd").text

                    if posts == "0" and not url in old_threads:
                        old_threads.append(url)
                        shoutytext = "a new thread was posted by {}: [URL={}/{}]{}[/URL]".format(user, base, url, title)
                        self.session.post(base + "/taigachat/post.json", params=dict(self.params, message=shoutytext, color='EEEEEE'))
                        for chan in self.channels:
                            self.send_ctcp(chan, "ACTION", ["{} opened a new thread: [{}/{}]".format(user, base, url)])
                            self.send_ctcp(chan, "ACTION", ["   " + format.color(title, format.GREEN)])

            t = time.time()
            while time.time() < t+1:
                asyncore.loop(count=1)
            time.sleep(0.4)
            if i > 4:
                for chan in self.channels:
                    self.execute("NAMES", chan) # update permissions
Exemple #21
0
        subrootmatches = [s[1] for s in srmatches if s[0] == "r" and not "/" in s[1]]
        suburlmatches = [s[1] for s in srmatches if s[0] == "r" and "/" in s[1]]
        usermatches = [s[1] for s in srmatches if s[0] == "u"]
        links = []
        if len(subrootmatches) > 0:
            links.append("http://reddit.com/r/{}".format("+".join(subrootmatches)))
        for link in suburlmatches:
            links.append("http://reddit.com/r/{}".format(link))
        for link in usermatches:
            links.append("http://reddit.com/u/{}".format(link))
        if len(links) > 0:
            self.send_message(event.respond, " ".join(links))

    # Imply
    if event.command.lower() in self._prefix("imply"):
        self.send_message(event.respond, format.color(">" + event.params, format.GREEN))

    # DNS
    if event.command.lower() in self._prefix("dns"):
        try:
            records = socket.getaddrinfo(event.params.split(" ")[0], 80)
            addresses = set([x[4][0] for x in records])
            self.send_message(event.respond, " ".join(addresses))
        except:
            self.send_message(event.respond, "You must give a valid host name to look up")

    # Reboot
    if event.command.lower() in self._prefix("reboot"):
        if event.host in self.config.adminhosts:
            self.quit("My primary function is failure.")
            os.execl(sys.executable, *([sys.executable] + sys.argv))
Exemple #22
0
        subrootmatches=[s[1] for s in srmatches if s[0] == 'r' and not '/' in s[1]]
        suburlmatches=[s[1] for s in srmatches if s[0] == 'r' and '/' in s[1]]
        usermatches=[s[1] for s in srmatches if s[0] == 'u']
        links = []
        if len(subrootmatches) > 0:
            links.append("http://reddit.com/r/{}".format('+'.join(subrootmatches)))
        for link in suburlmatches:
            links.append("http://reddit.com/r/{}".format(link))
        for link in usermatches:
            links.append("http://reddit.com/u/{}".format(link))
        if len(links) > 0:
            self.send_message(event.respond, ' '.join(links))

    #Imply
    if event.command.lower() in self._prefix('imply'):
        self.send_message(event.respond, format.color(">" + event.params, format.GREEN))

    #DNS
    if event.command.lower() in self._prefix('dns'):
        try:
            records = socket.getaddrinfo(event.params.split(' ')[0], 80)
            addresses = set([x[4][0] for x in records])
            self.send_message(event.respond, " ".join(addresses))
        except:
            self.send_message(event.respond, "You must give a valid host name to look up")

    #Reboot
    if event.command.lower() in self._prefix('reboot'):
        if event.host in self.config.adminhosts:
            self.quit("My primary function is failure.")
            os.execl(sys.executable, *([sys.executable]+sys.argv))