当前位置: 首页>>代码示例>>Python>>正文


Python Irc.get_host方法代码示例

本文整理汇总了Python中Irc.get_host方法的典型用法代码示例。如果您正苦于以下问题:Python Irc.get_host方法的具体用法?Python Irc.get_host怎么用?Python Irc.get_host使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Irc的用法示例。


在下文中一共展示了Irc.get_host方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: message

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import get_host [as 别名]
def message(serv, source, target, text):
	host = Irc.get_host(source)
	Commands.Tracking.activity(source,target,serv)
	if target != serv.nick and source == '[email protected]' and 'tipped' in text and 'to dogesoak' in text.lower():
		try:
			usr = text.split()[1]
			req = Request(serv, target, usr)
			val = int(text.split('much ',1)[1][2:].split(' ',1)[0])
			try:
				Commands.soak(req,[str(val)])
			except:
				req.say('An error occurred.')
				#req.serv.send('PRIVMSG','Doger','tip ')
		except:
			print 'soaker error' 
	if Commands.lreq and target == serv.nick and source.split('!',1)[0] == 'Doger':
		Commands.balancerepl(text)
	if text[0] == '!' or target == serv.nick:
		if serv.is_ignored(host):
			print(serv.nick + ": (ignored) <" + Irc.get_nickname(source) + "> " + text)
			return
		print(serv.nick + ": <" + Irc.get_nickname(source) + "> " + text)
		t = time.time()
		score = serv.flood_score.get(host, (t, 0))
		score = max(score[1] + score[0] - t, 0) + 4
		if score > 40 and not serv.is_admin(source):
			serv.ignore(host, 240)
			serv.send("PRIVMSG", Irc.get_nickname(source), "You're sending commands too quickly. Your host is ignored for 240 seconds")
			return
		serv.flood_score[host] = (t, score)
		if text[0] == '!':
			text = text[1:]
		src = Irc.get_nickname(source)
		if target == serv.nick:
			reply = src
		else:
			reply = target
		if text.find(" ") == -1:
			command = text
			args = []
		else:
			command, args = text.split(" ", 1)
			args = args.split(" ")
		if command[0] != '_':
			cmd = Commands.commands.get(command.lower(), None)
			if not cmd.__doc__ or cmd.__doc__.find("admin") == -1 or serv.is_admin(source):
				if cmd:
					req = Request(serv, reply, source)
					try:
						ret = cmd(req, args)
					except Exception as e:
						type, value, tb = sys.exc_info()
						traceback.print_tb(tb)
						req.reply(repr(e))
开发者ID:red-green,项目名称:soaker-doge,代码行数:56,代码来源:Hooks.py

示例2: message

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import get_host [as 别名]
def message(instance, source, target, text):
	host = Irc.get_host(source)
	if text == "\x01VERSION\x01":
		p = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout = subprocess.PIPE)
		hash, _ = p.communicate()
		hash = hash.strip()
		p = subprocess.Popen(["git", "diff", "--quiet"])
		changes = p.wait()
		if changes:
			hash += "[+]"
		version = "Doger by mniip, version " + hash
		Irc.instance_send(instance, ("NOTICE", Irc.get_nickname(source), "\x01VERSION " + version + "\x01"), priority = 20)
	else:
		commandline = None
		if target == instance:
			commandline = text
		if text[0] == Config.config["prefix"]:
			commandline = text[1:]
		if commandline:
			if Irc.is_ignored(host):
				Logger.log("c", instance + ": %s <%s ignored> %s " % (target, Irc.get_nickname(source), text))
				return
			Logger.log("c", instance + ": %s <%s> %s " % (target, Irc.get_nickname(source), text))
			if Config.config.get("ignore", None):
				t = time.time()
				score = Global.flood_score.get(host, (t, 0))
				score = max(score[1] + score[0] - t, 0) + Config.config["ignore"]["cost"]
				if score > Config.config["ignore"]["limit"] and not Irc.is_admin(source):
					Logger.log("c", instance + ": Ignoring " + host)
					Irc.ignore(host, Config.config["ignore"]["timeout"])
					Irc.instance_send(instance, ("PRIVMSG", Irc.get_nickname(source), "You're sending commands too quickly. Your host is ignored for 240 seconds"))
					return
				Global.flood_score[host] = (t, score)
			src = Irc.get_nickname(source)
			if target == instance:
				reply = src
			else:
				reply = target
			commandline = commandline.rstrip(" \t")
			if commandline.find(" ") == -1:
				command = commandline
				args = []
			else:
				command, args = commandline.split(" ", 1)
				args = [a for a in args.split(" ") if len(a) > 0]
			if command[0] != '_':
				cmd = Commands.commands.get(command.lower(), None)
				if not cmd.__doc__ or cmd.__doc__.find("admin") == -1 or Irc.is_admin(source):
					if cmd:
						req = Request(instance, reply, source, commandline)
						t = threading.Thread(target = run_command, args = (cmd, req, args))
						t.start()
开发者ID:digideskio,项目名称:Doger,代码行数:54,代码来源:Hooks.py


注:本文中的Irc.get_host方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。