Esempio n. 1
0
    def __init__(self, my_pyborg, args):
        """
        Args will be sys.argv (command prompt arguments)
        """
        # PyBorg
        self.pyborg = my_pyborg
        # load settings

        self.settings = cfgfile.cfgset()
        self.settings.load("pyborg-irc.cfg",
            { "myname": ("The bot's nickname", "PyBorg"),
              "realname": ("Reported 'real name'", "Pyborg"),
              "localaddress": ("Local IP to bind to", ""),
              "ipv6": ("Whether to use IPv6", 0),
              "owners": ("Owner(s) nickname", [ "OwnerNick" ]),
              "servers": ("IRC Server to connect to (server, port [,password])", [("irc.starchat.net", 6667)]),
              "chans": ("Channels to auto-join", ["#test"]),
              "speaking": ("Allow the bot to talk on channels", 1),
              "stealth": ("Hide the fact we are a bot", 0),
              "ignorelist": ("Ignore these nicknames:", []),
              "reply2ignored": ("Reply to ignored people", 0),
              "reply_chance": ("Chance of reply (%) per message", 33),
              "quitmsg": ("IRC quit message", "Bye :-("),
              "password": ("password for control the bot (Edit manually !)", "")
            } )

        self.owners = self.settings.owners[:]
        self.chans = self.settings.chans[:]
        self.inchans = []
        self.wanted_myname = self.settings.myname

        # Parse command prompt parameters

        for x in xrange(1, len(args)):
            # Specify servers
            if args[x] == "-s":
                self.settings.servers = []
                # Read list of servers
                for y in xrange(x+1, len(args)):
                    if args[y][0] == "-":
                        break
                    server = args[y].split(":")
                    # Default port if none specified
                    if len(server) == 1:
                        server.append("6667")
                    self.settings.servers.append( (server[0], int(server[1])) )
            # Channels
            if args[x] == "-c":
                self.settings.chans = []
                # Read list of channels
                for y in xrange(x+1, len(args)):
                    if args[y][0] == "-":
                        break
                    self.settings.chans.append("#"+args[y])
            # Nickname
            if args[x] == "-n":
                try:
                    self.settings.myname = args[x+1]
                except IndexError:
                    pass
Esempio n. 2
0
	def __init__(self, my_pyborg, args):
		"""
		Args will be sys.argv (command prompt arguments)
		"""
		# PyBorg
		self.pyborg = my_pyborg
		# load settings
		
		self.settings = cfgfile.cfgset()
		self.settings.load("pyborg-irc.cfg",
			{ "myname": ("The bot's nickname", "PyBorg"),
			  "realname": ("Reported 'real name'", "Pyborg"),
			  "owners": ("Owner(s) nickname", [ "OwnerNick" ]),
			  "servers": ("IRC Server to connect to (server, port [,password])", [("irc.starchat.net", 6667)]),
			  "chans": ("Channels to auto-join", ["#test"]),
			  "rejoin_kick": ("Rejoin channel when kicked out", 0),
			  "logging": ("Enable or disable writing to a logfile", 0),
			  "notify" : ("Enable or disable private message and CTCP notifications to owners", 1),
			  "logfile": ("If logging is enabled, name of logfile", "log.txt"),
			  "speaking": ("Allow the bot to talk on channels", 1),
			  "stealth": ("Hide the fact we are a bot", 0),
			  "ignorelist": ("Ignore these nicknames:", []),
			  "reply2ignored": ("Reply to ignored people", 0),
			  "reply_chance": ("Chance of reply (%) per message", 33),
			  "quitmsg": ("IRC quit message", "Bye :-("),
			  "password": ("password to control the bot (Edit manually !)", "")
			} )

		self.owners = self.settings.owners[:]
		self.chans = self.settings.chans[:]

		# Parse command prompt parameters
		
		for x in xrange(1, len(args)):
			# Specify servers
			if args[x] == "-s":
				self.settings.servers = []
				# Read list of servers
				for y in xrange(x+1, len(args)):
					if args[y][0] == "-":
						break
					server = args[y].split(":")
					# Default port if none specified
					if len(server) == 1:
						server.append("6667")
					self.settings.servers.append( (server[0], int(server[1])) )
			# Channels
			if args[x] == "-c":
				self.settings.chans = []
				# Read list of channels
				for y in xrange(x+1, len(args)):
					if args[y][0] == "-":
						break
					self.settings.chans.append("#"+args[y])
			# Nickname
			if args[x] == "-n":
				try:
					self.settings.myname = args[x+1]
				except IndexError:
					pass
Esempio n. 3
0
	def __init__(self):
		"""
		Open the dictionary. Resize as required.
		"""
		# pike i had old dicts ..
		# marshal.version=0
		
		# Attempt to load settings
		self.settings = cfgfile.cfgset()
		self.settings.load("pyborg.cfg",
			{ "num_contexts": ("Total word contexts", 0),
			  "num_words": ("Total unique words known", 0),
			  "learning": ("Allow the bot to learn", 1)
			} )

		# Read the dictionary
		print "Reading dictionary..."
		try:
			f = open("words.dat", "rb")
			s = f.read()
			f.close()
			self.words = marshal.loads(s)
			del s
			f = open("lines.dat", "rb")
			s = f.read()
			f.close()
			self.lines = marshal.loads(s)
			del s
		except (EOFError, IOError), e:
			# The datafiles are missing or corrupt. First try the
			# backups. Failing that start new database.
			print "Error reading dictionary. Trying backups..."
			try:
				f = open("words.bak", "rb")
				s = f.read()
				f.close()
				self.words = marshal.loads(s)
				del s
				f = open("lines.bak", "rb")
				s = f.read()
				f.close()
				self.lines = marshal.loads(s)
				del s
				os.rename("words.bak", "words.dat")
				os.rename("lines.bak", "lines.dat")
			except (EOFError, IOError), e:
				# Create mew database
				self.words = {}
				self.lines = {}
				print "Error reading backups. New database created."
Esempio n. 4
0
    def __init__(self, my_pyborg, args):
        """
        Args will be sys.argv (command prompt arguments)
        """
        # PyBorg
        self.pyborg = my_pyborg
        # load settings

        self.settings = cfgfile.cfgset()
        self.settings.load(
            "pyborg-discord.json", {
                "myname": ("The bot's nickname", "PyBorg"),
                "owners": ("Owner(s) nickname", []),
                "interaction_settings":
                ("Server/channel combos to pay attention to", {}),
                "interaction_defaults":
                ("Server/channel global settings, for when replacements aren't set.",
                 {}),
                "interaction_private":
                ("Settings for private message replies.", {}),
                "speaking": ("Allow the bot to talk on channels", 1),
                "stealth": ("Hide the fact we are a bot", 0),
                "ignorelist": ("Ignore these nicknames:", []),
                "reply2ignored": ("Reply to ignored people", 0),
                "quitmsg": ("IRC quit message", "Bye :-("),
                "autosaveperiod":
                ("Save every X minutes. Leave at 0 for no saving.", 60),
                "magic_words": ("magic notification words", []),
                "disco_auth": ("Discord authentication creds", [])
            })

        # If autosaveperiod is set, trigger it.
        asp = self.settings.autosaveperiod
        if (asp > 0):
            self.autosave_schedule(asp)

        # Create useful variables.
        self.owners = self.settings.owners[:]
        #self.chans = self.settings.chans[:]
        self.inchans = []
        self.wanted_myname = self.settings.myname
        self.pyborg.bot_name = self.settings.myname
        self.attempting_regain = False
        self.feature_monitor = False
        self.client = discord.Client()

        self.roles = {}
Esempio n. 5
0
	def __init__(self, my_pyborg, args):
		"""
		Args will be sys.argv (command prompt arguments)
		"""
		# PyBorg
		self.pyborg = my_pyborg
		# load settings
		
		self.settings = cfgfile.cfgset()
		self.settings.load("pyborg-msn.cfg",
			{ "myname": ("The bot's nickname", "PyBorg"),
			  "msn_passport": ("Reported passport account", "*****@*****.**"),
			  "msn_password": ("Reported password account", "password"),
			  "owners": ("Owner(s) passport account", [ "*****@*****.**" ]),
			  "password": ("password for control the bot (Edit manually !)", "")
			} )


		self.owners = self.settings.owners[:]
Esempio n. 6
0
    def __init__(self, my_pyborg, args):
        """
        Args will be sys.argv (command prompt arguments)
        """
        # PyBorg
        self.pyborg = my_pyborg
        # load settings

        self.settings = cfgfile.cfgset()
        self.settings.load("pyborg-msn.cfg",
                { "myname": ("The bot's nickname", "PyBorg"),
                  "msn_passport": ("Reported passport account", "*****@*****.**"),
                  "msn_password": ("Reported password account", "password"),
                  "owners": ("Owner(s) passport account", [ "*****@*****.**" ]),
                  "password": ("password for control the bot (Edit manually !)", "")
                })


        self.owners = self.settings.owners[:]
Esempio n. 7
0
    def __init__(self, my_pyborg, args):
        """
        Args will be sys.argv (command prompt arguments)
        """
        # PyBorg
        self.pyborg = my_pyborg
        # load settings

        self.settings = cfgfile.cfgset()
        self.settings.load("pyborg-discord.cfg",
                { "myname": ("The bot's nickname", "PyBorg"),
                  #"realname": ("Reported 'real name'", "Pyborg"),
                  #"localaddress": ("Local IP to bind to", ""),
                  #"ipv6": ("Whether to use IPv6", 0),
                  "owners": ("Owner(s) nickname", [ "OwnerNick" ]),
                  #"servers": ("Discord Server to pay attention to (server name)", [("irc.sucks.net")]),
                  #"chans": ("Channels to pay attention to", ["#cutie578"]),
                  'attentive_channels' : ("Server/channel combos to pay attention to", {}),
                  "speaking": ("Allow the bot to talk on channels", 1),
                  "stealth": ("Hide the fact we are a bot", 0),
                  "ignorelist": ("Ignore these nicknames:", []),
                  "reply2ignored": ("Reply to ignored people", 0),
                  "reply_chance": ("Chance of reply (%) per message", 10),
                  "quitmsg": ("IRC quit message", "Bye :-("),
                  #"password": ("password for control the bot (Edit manually !)", ""),
                  "autosaveperiod": ("Save every X minutes. Leave at 0 for no saving.", 60),
                  "disco_auto": ("username and password for discord", ("", "")),
                  "magic_words" : ("magic notification words", [])
                })

        # If autosaveperiod is set, trigger it.
        asp = self.settings.autosaveperiod
        if(asp > 0) :
            self.autosave_schedule(asp)

        # Create useful variables.
        self.owners = self.settings.owners[:]
        #self.chans = self.settings.chans[:]
        self.inchans = []
        self.wanted_myname = self.settings.myname
        self.attempting_regain = False
        self.feature_monitor = False
        self.client = discord.Client()
Esempio n. 8
0
    def __init__(self, my_pyborg, args):
        """
        Args will be sys.argv (command prompt arguments)
        """
        # PyBorg
        self.pyborg = my_pyborg
        # load settings

        self.settings = cfgfile.cfgset()
        self.settings.load("pyborg-discord.json",
                { "myname": ("The bot's nickname", "PyBorg"),
                  "owners": ("Owner(s) nickname", []),
                  "interaction_settings" : ("Server/channel combos to pay attention to", {}),
                  "interaction_defaults" : ("Server/channel global settings, for when replacements aren't set.", {}),
                  "interaction_private" : ("Settings for private message replies.", {}),
                  "speaking": ("Allow the bot to talk on channels", 1),
                  "stealth": ("Hide the fact we are a bot", 0),
                  "ignorelist": ("Ignore these nicknames:", []),
                  "reply2ignored": ("Reply to ignored people", 0),
                  "quitmsg": ("IRC quit message", "Bye :-("),
                  "autosaveperiod": ("Save every X minutes. Leave at 0 for no saving.", 60),
                  "magic_words" : ("magic notification words", []),
                  "disco_auth" : ("Discord authentication creds", [])
                })

        # If autosaveperiod is set, trigger it.
        asp = self.settings.autosaveperiod
        if(asp > 0) :
            self.autosave_schedule(asp)

        # Create useful variables.
        self.owners = self.settings.owners[:]
        #self.chans = self.settings.chans[:]
        self.inchans = []
        self.wanted_myname = self.settings.myname
        self.pyborg.bot_name = self.settings.myname
        self.attempting_regain = False
        self.feature_monitor = False
        self.client = discord.Client()

        self.roles = {}
Esempio n. 9
0
    def __init__(self, my_pyborg, args):
        """
        Args will be sys.argv (command prompt arguments)
        """
        # PyBorg
        self.pyborg = my_pyborg
        # load settings

        self.settings = cfgfile.cfgset()
        self.settings.load("pyborg-irc.cfg",
                { "myname": ("The bot's nickname", "PyBorg"),
                  "realname": ("Reported 'real name'", "Pyborg"),
                  "localaddress": ("Local IP to bind to", ""),
                  "ipv6": ("Whether to use IPv6", 0),
                  "owners": ("Owner(s) nickname", [ "OwnerNick" ]),
                  "servers": ("IRC Server to connect to (server, port [,password])", [("irc.sucks.net", 6667)]),
                  "chans": ("Channels to auto-join", ["#cutie578"]),
                  "speaking": ("Allow the bot to talk on channels", 1),
                  "stealth": ("Hide the fact we are a bot", 0),
                  "ignorelist": ("Ignore these nicknames:", []),
                  "reply2ignored": ("Reply to ignored people", 0),
                  "reply_chance": ("Chance of reply (%) per message", 33),
                  "quitmsg": ("IRC quit message", "Bye :-("),
                  "password": ("password for control the bot (Edit manually !)", ""),
                  "autosaveperiod": ("Save every X minutes. Leave at 0 for no saving.", 60),
                  "nickserv": ("username and password for nickserv", ("", ""))
                })

        # If autosaveperiod is set, trigger it.
        asp = self.settings.autosaveperiod
        if(asp > 0) :
            self.autosave_schedule(asp)

        # Create useful variables.
        self.owners = self.settings.owners[:]
        self.chans = self.settings.chans[:]
        self.inchans = []
        self.wanted_myname = self.settings.myname
        self.attempting_regain = False
        self.feature_monitor = False

        # Parse command prompt parameters

        for x in xrange(1, len(args)):
            # Specify servers
            if args[x] == "-s":
                self.settings.servers = []
                # Read list of servers
                for y in xrange(x+1, len(args)):
                    if args[y][0] == "-":
                        break
                    server = args[y].split(":")
                    # Default port if none specified
                    if len(server) == 1:
                        server.append("6667")
                    self.settings.servers.append((server[0], int(server[1])))
            # Channels
            if args[x] == "-c":
                self.settings.chans = []
                # Read list of channels
                for y in xrange(x+1, len(args)):
                    if args[y][0] == "-":
                        break
                    self.settings.chans.append("#"+args[y])
            # Nickname
            if args[x] == "-n":
                try:
                    self.settings.myname = args[x+1]
                except IndexError:
                    pass
Esempio n. 10
0
	def __init__(self, my_pyborg, args):
		"""
		Args will be sys.argv (command prompt arguments)
		"""
		# PyBorg
		self.pyborg = my_pyborg
		# load settings
		
		self.settings = cfgfile.cfgset()
		self.settings.load("pyborg-irc.cfg",
			{ "myname": ("The bot's nickname", "PyBorg"),
			  "realname": ("Reported 'real name'", "Pyborg"),
			  "owners": ("Owner(s) nickname", [ "OwnerNick" ]),
			  "servers": ("IRC Server to connect to (server, port [,password])", [("irc.starchat.net", 6667)]),
			  "chans": ("Channels to auto-join", ["#test"]),
			  "rejoin_kick": ("Rejoin channel when kicked out", 0),
			  "logging": ("Enable or disable writing to a logfile", 0),
			  "notify" : ("Enable or disable private message and CTCP notifications to owners", 1),
			  "logfile": ("If logging is enabled, name of logfile", "log.txt"),
			  "speaking": ("Allow the bot to talk on channels", 1),
			  "stealth": ("Hide the fact we are a bot", 0),
			  "ignorelist": ("Ignore these nicknames:", []),
			  "reply2ignored": ("Reply to ignored people", 0),
			  "reply_chance": ("Chance of reply (%) per message", 33),
			  "reply_magic": ("Chance of replying to lines containg magic words (%)", 33),
			  "reply_nick": ("Chance of replying to lines containing our nickname (%)", 33),
			  "magicwords": ("Reply to these magic words with the chance defined in reply_magic, in the format of ['Word1', 'Word2']", []),
			  "quitmsg": ("IRC quit message", "Bye :-("),
			  "password": ("password for control the bot (Edit manually !)", "")
			} )

		self.owners = self.settings.owners[:]
		self.chans = self.settings.chans[:]

		# Parse command prompt parameters
		
		for x in xrange(1, len(args)):
			# Specify servers
			if args[x] == "-s":
				self.settings.servers = []
				# Read list of servers
				for y in xrange(x+1, len(args)):
					if args[y][0] == "-":
						break
					server = args[y].split(":")
					# Default port if none specified
					if len(server) == 1:
						server.append("6667")
					self.settings.servers.append( (server[0], int(server[1])) )
			# Channels
			if args[x] == "-c":
				self.settings.chans = []
				# Read list of channels
				for y in xrange(x+1, len(args)):
					if args[y][0] == "-":
						break
					self.settings.chans.append("#"+args[y])
			# Nickname
			if args[x] == "-n":
				try:
					self.settings.myname = args[x+1]
				except IndexError:
					pass
Esempio n. 11
0
    def __init__(self, my_pyborg, args):
        """
        Args will be sys.argv (command prompt arguments)
        """
        # PyBorg
        self.pyborg = my_pyborg
        # load settings

        self.settings = cfgfile.cfgset()
        self.settings.load("pyborg-irc.cfg",
                { "myname": ("The bot's nickname", "PyBorg"),
                  "realname": ("Reported 'real name'", "Pyborg"),
                  "localaddress": ("Local IP to bind to", ""),
                  "ipv6": ("Whether to use IPv6", 0),
                  "ssl": ("Whether to use SSL", 0),
                  "owners": ("Owner(s) nickname", [ "OwnerNick" ]),
                  "servers": ("IRC Server to connect to (server, port [,password])", [("irc.sucks.net", 6667)]),
                  "chans": ("Channels to auto-join", ["#cutie578"]),
                  "speaking": ("Allow the bot to talk on channels", 1),
                  "stealth": ("Hide the fact we are a bot", 0),
                  "ignorelist": ("Ignore these nicknames:", []),
                  "reply2ignored": ("Reply to ignored people", 0),
                  "reply_chance": ("Chance of reply (%) per message", 33),
                  "quitmsg": ("IRC quit message", "Bye :-("),
                  "password": ("password for control the bot (Edit manually !)", ""),
                  "autosaveperiod": ("Save every X minutes. Leave at 0 for no saving.", 60),
                  "nickserv": ("username and password for nickserv", ("", ""))
                })

        # If autosaveperiod is set, trigger it.
        asp = self.settings.autosaveperiod
        if(asp > 0) :
            self.autosave_schedule(asp)

        # Create useful variables.
        self.owners = self.settings.owners[:]
        self.chans = self.settings.chans[:]
        self.inchans = []
        self.wanted_myname = self.settings.myname
        self.attempting_regain = False
        self.feature_monitor = False

        # Parse command prompt parameters

        for x in xrange(1, len(args)):
            # Specify servers
            if args[x] == "-s":
                self.settings.servers = []
                # Read list of servers
                for y in xrange(x+1, len(args)):
                    if args[y][0] == "-":
                        break
                    server = args[y].split(":")
                    # Default port if none specified
                    if len(server) == 1:
                        server.append("6667")
                    self.settings.servers.append((server[0], int(server[1])))
            # Channels
            if args[x] == "-c":
                self.settings.chans = []
                # Read list of channels
                for y in xrange(x+1, len(args)):
                    if args[y][0] == "-":
                        break
                    self.settings.chans.append("#"+args[y])
            # Nickname
            if args[x] == "-n":
                try:
                    self.settings.myname = args[x+1]
                except IndexError:
                    pass