Example #1
0
	def me(self, string, connection, event):
		server = self.bot.irc.server_nick(connection)
		(password, target, message) = splitnum(string, split_num=2)
		pass_hash = self.bot.encrypt(password.encode('utf-8'))
		
		if self.bot.pass_hash == pass_hash:
			self.bot.irc.action(server, target, message)
Example #2
0
	def quit(self, string, connection, event):
		server = self.bot.irc.server_nick(connection)
		(password, message) = splitnum(string)
		password = self.bot.encrypt(password.encode('utf-8'))
		
		if self.bot.pass_hash == password:
			self.bot.irc.quit(server, message)
Example #3
0
    def quit(self, string, connection, event):
        server = self.bot.irc.server_nick(connection)
        (password, message) = splitnum(string)
        password = self.bot.encrypt(password.encode('utf-8'))

        if self.bot.pass_hash == password:
            self.bot.irc.quit(server, message)
Example #4
0
    def me(self, string, connection, event):
        server = self.bot.irc.server_nick(connection)
        (password, target, message) = splitnum(string, split_num=2)
        pass_hash = self.bot.encrypt(password.encode('utf-8'))

        if self.bot.pass_hash == pass_hash:
            self.bot.irc.action(server, target, message)
Example #5
0
def retrieve_indent(string):
    """ Extracts indent from the beginning of the given string."""
    try:
        (indent_string, out_string) = splitnum(string, split_char="}")
        indent = int(indent_string[2:])
    except:
        indent = 0
        out_string = string
    return (indent, out_string)
Example #6
0
File: strings.py Project: dgw/goshu
def retrieve_indent(string):
    """ Extracts indent from the beginning of the given string."""
    try:
        (indent_string, out_string) = splitnum(string, split_char='}')
        indent = int(indent_string[2:])
    except:
        indent = 0
        out_string = string
    return (indent, out_string)
Example #7
0
File: suggest.py Project: dgw/goshu
    def suggest(self, string, connection, event):
        server = self.bot.irc.server_nick(connection)
        channel = event.target().split('!')[0]
        nick = event.source().split('!')[0]
        if channel == self.bot.nick:
            channel = nick

        (command, suggestion) = splitnum(string)
        command = command.lower()

        if suggestion == '':
            output_lines = [
                'SUGEST SYNTAX: ' + self.bot.prefix +
                'suggest <command> <suggestion>',
                "<command> is what about goshu the suggestion affects; for example: if suggesting a different "
                + self.bot.prefix +
                "who output for someone, <command> would be who",
                '<suggestion> is the suggestion you want to pass on'
            ]
            for i in range(0, len(output_lines)):
                if i > 0:
                    output = ' ' * self.bot.indent
                else:
                    output = ''

                output += output_lines[i]

                self.bot.irc.privmsg(server, nick, output)
            return

        output = server + ' - '
        output += event.source() + ' - '
        output += command
        output += '\n\t'
        output += suggestion
        output += '\n'

        command_escape = ''
        for character in command:
            if character in self.valid_characters:
                command_escape += character
            else:
                command_escape += '_'
        path = 'suggestions/' + command_escape
        outfile = open(path, 'a')
        outfile.write(output)
        outfile.close()

        self.bot.irc.privmsg(server, nick, 'Thanks for your suggestion')
Example #8
0
	def ignore(self, string, connection, event):
		server = self.bot.irc.server_nick(connection)
		nick = event.source().split('!')[0]
		(password, nickhost) = splitnum(string)
		pass_hash = self.bot.encrypt(password.encode('utf-8'))
		
		if self.bot.pass_hash == pass_hash:
			ignore_nick = nickhost.split('!')[0]
			self.bot.irc._nick_ignore_list.append(ignore_nick)
			try:
				ignore_host = nickhost.split('!')[1]
				if ignore_host != '':
					self.bot.irc._host_ignore_list.append(ignore_host)
			except:
				pass
			self.bot.irc.privmsg(server, nick, nickhost+' has been ignored')
Example #9
0
    def ignore(self, string, connection, event):
        server = self.bot.irc.server_nick(connection)
        nick = event.source().split('!')[0]
        (password, nickhost) = splitnum(string)
        pass_hash = self.bot.encrypt(password.encode('utf-8'))

        if self.bot.pass_hash == pass_hash:
            ignore_nick = nickhost.split('!')[0]
            self.bot.irc._nick_ignore_list.append(ignore_nick)
            try:
                ignore_host = nickhost.split('!')[1]
                if ignore_host != '':
                    self.bot.irc._host_ignore_list.append(ignore_host)
            except:
                pass
            self.bot.irc.privmsg(server, nick, nickhost + ' has been ignored')
Example #10
0
def printable_len(in_string=None):
    """ Gives how many printable characters long the string is."""
    printable = 0
    if in_string:
        running = True
        while running:
            if in_string[0] == "/" and in_string[1] == "{":
                (temp_first, temp_last) = splitnum(in_string, split_char="}")
                in_string = temp_last
            elif in_string[0] == "/" and in_string[1] == "/":
                printable += 1
                in_string = in_string[2:]
            elif in_string[0].isprintable():
                printable += 1
                in_string = in_string[1:]
            if len(in_string) < 1:
                running = False
    return printable
Example #11
0
File: strings.py Project: dgw/goshu
def printable_len(in_string=None):
    """ Gives how many printable characters long the string is."""
    printable = 0
    if in_string:
        running = True
        while running:
            if in_string[0] == '/' and in_string[1] == '{':
                (temp_first, temp_last) = splitnum(in_string, split_char='}')
                in_string = temp_last
            elif in_string[0] == '/' and in_string[1] == '/':
                printable += 1
                in_string = in_string[2:]
            elif in_string[0].isprintable():
                printable += 1
                in_string = in_string[1:]
            if len(in_string) < 1:
                running = False
    return printable
Example #12
0
	def suggest(self, string, connection, event):
		server = self.bot.irc.server_nick(connection)
		channel = event.target().split('!')[0]
		nick = event.source().split('!')[0]
		if channel == self.bot.nick:
			channel = nick
		
		(command, suggestion) = splitnum(string)
		command = command.lower()
		
		if suggestion == '':
			output_lines = ['SUGEST SYNTAX: '+self.bot.prefix+'suggest <command> <suggestion>',
							"<command> is what about goshu the suggestion affects; for example: if suggesting a different "+self.bot.prefix+"who output for someone, <command> would be who",
							'<suggestion> is the suggestion you want to pass on']
			for i in range(0, len(output_lines)):
				if i > 0:
					output = ' ' * self.bot.indent
				else:
					output = ''
				
				output += output_lines[i]
				
				self.bot.irc.privmsg(server, nick, output)
			return
		
		output = server + ' - '
		output += event.source() + ' - '
		output += command
		output += '\n\t'
		output += suggestion
		output += '\n'
		
		command_escape = ''
		for character in command:
			if character in self.valid_characters:
				command_escape += character
			else:
				command_escape += '_'
		path = 'suggestions/'+command_escape
		outfile = open(path, 'a')
		outfile.write(output)
		outfile.close()
		
		self.bot.irc.privmsg(server, nick, 'Thanks for your suggestion')
Example #13
0
	def unignore(self, string, connection, event):
		server = self.bot.irc.server_nick(connection)
		nick = event.source().split('!')[0]
		(password, nickhost) = splitnum(string)
		pass_hash = self.bot.encrypt(password.encode('utf-8'))
		
		if self.bot.pass_hash == pass_hash:
			nickhost = nickhost.split('!')[0]
			for i in range(len(self.bot.irc._nick_ignore_list)):
				if self.bot.irc._nick_ignore_list[i] == nickhost:
					del self.bot.irc._nick_ignore_list[i]
			try:
				ignore_host = nickhost.split('!')[1]
				if ignore_host != '':
					for i in range(len(self.bot.irc._host_ignore_list)):
						if self.bot.irc._host_ignore_list[i] == ignore_host:
							del self.bot.irc._host_ignore_list[i]
			except:
				pass
			self.bot.irc.privmsg(server, nick, nickhost+' has been unignored')
Example #14
0
    def unignore(self, string, connection, event):
        server = self.bot.irc.server_nick(connection)
        nick = event.source().split('!')[0]
        (password, nickhost) = splitnum(string)
        pass_hash = self.bot.encrypt(password.encode('utf-8'))

        if self.bot.pass_hash == pass_hash:
            nickhost = nickhost.split('!')[0]
            for i in range(len(self.bot.irc._nick_ignore_list)):
                if self.bot.irc._nick_ignore_list[i] == nickhost:
                    del self.bot.irc._nick_ignore_list[i]
            try:
                ignore_host = nickhost.split('!')[1]
                if ignore_host != '':
                    for i in range(len(self.bot.irc._host_ignore_list)):
                        if self.bot.irc._host_ignore_list[i] == ignore_host:
                            del self.bot.irc._host_ignore_list[i]
            except:
                pass
            self.bot.irc.privmsg(server, nick,
                                 nickhost + ' has been unignored')
Example #15
0
File: strings.py Project: dgw/goshu
def split_line(in_string=''):
    """ Splits line into an alternating string/list format, string for text and 
		list for attributes to be used/parsed."""
    split_line = []
    while len(in_string) > 0:
        if in_string[0] == '/':
            if in_string[1] == '{':  #attributes
                attribute_line, in_string = splitnum(in_string, split_char='}')
                attributes = attribute_line[2:].split(',')
                attributes_split = []
                for attribute in attributes:
                    if ':' in attribute:
                        attribute = attribute.split(':')
                    attributes_split.append(attribute)

                split_line.append(attributes_split)
                split_line.append('')
            else:
                split_line[-1] += in_string[0:2]
                in_string = in_string[2:]
        else:
            split_line[-1] += in_string[0]
            in_string = in_string[1:]
    return split_line
Example #16
0
File: strings.py Project: dgw/goshu
def wrap(in_string, indent):
    try:
        rows, columns = os.popen('stty size', 'r').read().split()
    except:  #not being executed in a terminal
        return in_string
    output = ''
    running = True
    i = 1
    line = 0
    while running:
        if in_string[0] == '/' and in_string[1] == '{':
            (temp_first, temp_last) = splitnum(in_string, split_char='}')
            output += temp_first + '}'
            in_string = temp_last
        elif in_string[0] == '/':
            output += '/' + in_string[1]
            i += 1
            in_string = in_string[2:]
        elif in_string[0] in string.printable:
            output += in_string[0]
            i += 1
            in_string = in_string[1:]
        else:
            output += in_string[0]
            in_string = in_string[1:]

        if int(i) > int(columns):
            output += ' ' * int(indent)
            i = 1
            if line == 0:
                columns = int(columns) - int(indent)
            line += 1
        if len(in_string) < 1:
            running = False

    return output
Example #17
0
def wrap(in_string, indent):
    try:
        rows, columns = os.popen("stty size", "r").read().split()
    except:  # not being executed in a terminal
        return in_string
    output = ""
    running = True
    i = 1
    line = 0
    while running:
        if in_string[0] == "/" and in_string[1] == "{":
            (temp_first, temp_last) = splitnum(in_string, split_char="}")
            output += temp_first + "}"
            in_string = temp_last
        elif in_string[0] == "/":
            output += "/" + in_string[1]
            i += 1
            in_string = in_string[2:]
        elif in_string[0] in string.printable:
            output += in_string[0]
            i += 1
            in_string = in_string[1:]
        else:
            output += in_string[0]
            in_string = in_string[1:]

        if int(i) > int(columns):
            output += " " * int(indent)
            i = 1
            if line == 0:
                columns = int(columns) - int(indent)
            line += 1
        if len(in_string) < 1:
            running = False

    return output
Example #18
0
def split_line(in_string=""):
    """ Splits line into an alternating string/list format, string for text and 
		list for attributes to be used/parsed."""
    split_line = []
    while len(in_string) > 0:
        if in_string[0] == "/":
            if in_string[1] == "{":  # attributes
                attribute_line, in_string = splitnum(in_string, split_char="}")
                attributes = attribute_line[2:].split(",")
                attributes_split = []
                for attribute in attributes:
                    if ":" in attribute:
                        attribute = attribute.split(":")
                    attributes_split.append(attribute)

                split_line.append(attributes_split)
                split_line.append("")
            else:
                split_line[-1] += in_string[0:2]
                in_string = in_string[2:]
        else:
            split_line[-1] += in_string[0]
            in_string = in_string[1:]
    return split_line