Beispiel #1
0
def read(bot):
	global Bot
	Bot = bot
	if bot.remote['nick'] and bot.remote['nick'] != bot.nick:
		if bot.remote['message'].startswith("!"):
			args = bot.remote['message'][1:].rstrip().split(" ")
			command = args[0].lower()
			alibrary = {
				'reload':		lambda: bot._reload(args),
				'voice':		lambda: voice(args),
				'nick':			lambda: cnick(args),
				'release':		lambda: release(args),
				'identify':		lambda: ident(),
				'join':			lambda: join(args),
				'part':			lambda: part(args),
				'kick':			lambda: kick(args),
				'mode':			lambda: mode(args),
				'perms':		lambda: perms(args),
				'eval':			lambda: reply(bot.remote['sendee'], eval.parse(bot, args)),
				'raw':			lambda: raw(args)
			}
			clibrary = {
				'topic':		lambda: topic(bot, args),
				'help':			lambda: "Available commands: %s" % ', '.join(sorted(clibrary.keys())),
				'abort':		lambda: abort(args),
				'time':			lambda: time(bot, args),
				'say':			lambda: say(bot, args),
				'calc':			lambda: wolframalpha.wa(bot, args),
				'go':			lambda: googleapi.search(bot, args),
				'wiki':			lambda: wikipedia.wiki(bot, args),
				'tell':			lambda: tell.answer(bot, args),
				'twss':			lambda: fun.twss(bot, args),
				'cookie':		lambda: fun.cookie(bot, args),
				'choose':		lambda: fun.choose(bot, args),
				'8ball':		lambda: fun.m8b(bot, args),
				'quotes':		lambda: quotes.get_quote(bot, args),
				'js':			lambda: js.execute(bot, args),
				'benis':		lambda: fun.benis(bot, args),
				'tr':			lambda: translate.translate(bot, args),
				'nab':			lambda: fun.nab(bot, args),
				'frites':		lambda: fun.frites(bot, args),
				'etym':			lambda: etymology.etym(bot, args),
				'mrpass':		lambda: fun.monsieurp(bot, args),
				'sysinfo':		lambda: fun.sysinfo(bot, args),
				'ud':			lambda: ud.ud(bot, args)
			}
			if bot.remote['nick'].lower() not in bot.inv['banned']:
				if command in alibrary:
					if bot.remote['host'] in [host.strip() for host in bot.config.get(bot.network, 'admin_hostnames').split(',')]:
						alibrary[command]()
						bot.previous['user'] = bot.remote['sendee']
					else:
						if bot.voice:
							reply(bot.remote['sendee'], "%s: Can't do that, noob." % bot.remote['nick'])
				elif bot.voice and command in clibrary:
					result = execute(command, clibrary[command])
					bot.previous['user'] = bot.remote['sendee']
					if result:
						reply(bot.remote['sendee'], result)
		elif bot.remote['message'].startswith("\x01") and bot.remote['message'].endswith("\x01"):
			type = bot.remote['message'][1:-1].split()[0]
			args = bot.remote['message'][1:-1].split()[1:]
			if type != "ACTION":
				ctcp(type, args)
		elif bot.remote['mid'] == "INVITE" and bot.remote['nick'].lower() not in bot.inv['banned']:
			join(bot.remote['message'])
		else:
			if bot.init['registered'] and not bot.init['identified']:
				if bot.remote['nick'] == "NickServ":
					if "registered" in bot.remote['message']:
						bot._login()
					elif "identified" in bot.remote['message']:
						bot.init['identified'] = True
						__import__('time').sleep(3)
						autojoin()

			if bot.voice:
				# start scanning messages for certain data
				result = execute(None, scanner.scan, bot)
				if result:
					reply(bot.remote['sendee'], result)

	else:
		if (bot.remote['mid'].startswith("4") or bot.remote['mid'].startswith("5")) and bot.remote['mid'] != "462":
			reply(bot.previous.get('user') or bot.admin, "Message from %s: Error #%s: %s" % (bot.remote['server'], bot.remote['mid'], bot.remote['message']))
		if not bot.init['joined'] and not bot.init['registered']:
			autojoin()
Beispiel #2
0
def initCrawlerSeed(theQuery, theLimit):
	urls = googleapi.search(theQuery, theLimit)
	scheduler = crscheduler.Scheduler()
	for url in urls:
		scheduler.put(url, 0)
Beispiel #3
0
Datei: io.py Projekt: ejrh/xbot
def read(bot):
	global Bot
	Bot = bot
	if bot.remote['nick'] and bot.remote['nick'] != bot.nick:
		if bot.remote['message'].startswith("!"):
			args = bot.remote['message'][1:].rstrip().split(" ")
			command = args[0].lower()
			alibrary = {
				'reload':		lambda: bot._reload(args),
				'voice':		lambda: voice(args),
				'nick':			lambda: cnick(args),
				'release':		lambda: release(args),
				'identify':		lambda: ident(),
				'join':			lambda: join(args),
				'part':			lambda: part(args),
				'kick':			lambda: kick(args),
				'mode':			lambda: mode(args),
				'perms':		lambda: perms(args),
				'eval':			lambda: reply(bot.remote['sendee'], eval.parse(bot, args)),
				'raw':			lambda: raw(args)
			}
			clibrary = {
				'topic':		lambda: topic(bot, args),
				'help':			lambda: "Available commands: %s" % ', '.join(sorted(clibrary.keys())),
				'time':			lambda: time(bot, args),
				'say':			lambda: say(bot, args),
				'calc':			lambda: wolframalpha.wa(bot, args),
				'go':			lambda: googleapi.search(bot, args),
				'lookup':		lambda: dnstools.lookup(bot, args),
				'wiki':			lambda: dnstools.wiki(bot, args),
				'tell':			lambda: tell.answer(bot, args),
				'twss':			lambda: fun.twss(bot, args),
				'cookie':		lambda: fun.cookie(bot, args),
				'spin':			lambda: fun.spin(bot, args),
				'man':			lambda: man.man(bot, args),
				'choose':		lambda: fun.choose(bot, args),
				'8ball':		lambda: fun.m8b(bot, args),
				'ghetto':		lambda: fun.ghetto(bot, args),
				'sortinghat': 	lambda: fun.sorting_hat(bot, args),
				'lotto':		lambda: lotto.get_results(bot, args),
				'quotes':		lambda: quotes.get_quote(bot, args),
				'imdb':			lambda: imdb.info(bot, args),
				'usage':		lambda: usage.usage(bot, args),
				'maxx':			lambda: maxx.times(bot, args),
				'js':			lambda: js.execute(bot, args)
			}
			if bot.remote['nick'].lower() not in bot.inv['banned']:
				if command in alibrary:
					if bot.remote['host'] in [host.strip() for host in bot.config.get(bot.network, 'admin_hostnames').split(',')]:
						alibrary[command]()
						bot.previous['user'] = bot.remote['sendee']
					else:
						if bot.voice:
							reply(bot.remote['sendee'], "%s: Can't do that, noob." % bot.remote['nick'])
				elif bot.voice and command in clibrary:
					try: result = clibrary[command]()
					except __import__('urllib2').HTTPError: result = "!%s: derping the herp" % args[0]
					except (__import__('urllib2').URLError, __import__('socket').timeout): result = "!%s: response timeout exceeded." % args[0]
					bot.previous['user'] = bot.remote['sendee']
					if result:
						reply(bot.remote['sendee'], result)
		elif bot.remote['message'].startswith("\x01") and bot.remote['message'].endswith("\x01"):
			type = bot.remote['message'][1:-1].split()[0]
			args = bot.remote['message'][1:-1].split()[1:]
			if type != "ACTION":
				ctcp(type, args)
		else:
			if bot.init['registered'] and not bot.init['identified']:
				if bot.remote['nick'] == "NickServ":
					if "registered" in bot.remote['message']:
						bot._login()
					elif "identified" in bot.remote['message']:
						bot.init['identified'] = True
						__import__('time').sleep(3)
						autojoin()
			
			if bot.voice:
				# start scanning messages for certain data
				try: response = scanner.scan(bot)
				except (__import__('urllib2').URLError, __import__('socket').timeout): response = "fetch: response timeout exceeded."
				if response:
					reply(bot.remote['sendee'], response)

	else:
		if (bot.remote['mid'].startswith("4") or bot.remote['mid'].startswith("5")) and bot.remote['mid'] != "462":
			reply(bot.previous['user'], "Message from %s: Error #%s: %s" % (bot.remote['server'], bot.remote['mid'], bot.remote['message']))
		if not bot.init['joined'] and not bot.init['registered']:
			autojoin()