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


Python Irc.get_nickname方法代码示例

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


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

示例1: message

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import get_nickname [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_nickname [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

示例3: _nick

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import get_nickname [as 别名]
def _nick(instance, source, newnick):
	nick = Irc.get_nickname(source)
	for channel in Global.account_cache:
		if nick in Global.account_cache[channel]:
			Global.account_cache[channel][newnick] = Global.account_cache[channel][nick]
			Logger.log("w", "%s -> %s in %s" % (nick, newnick, channel))
			del Global.account_cache[channel][nick]
开发者ID:hashfaster,项目名称:Doger,代码行数:9,代码来源:Hooks.py

示例4: account

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import get_nickname [as 别名]
def account(instance, source, account):
	if account == "*":
		account = False
	nick = Irc.get_nickname(source)
	for channel in Global.account_cache:
		if nick in Global.account_cache[channel]:
			Global.account_cache[channel][nick] = account
			Logger.log("w", "Propagating %s=%s into %s" % (nick, account, channel))
开发者ID:hashfaster,项目名称:Doger,代码行数:10,代码来源:Hooks.py

示例5: part

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import get_nickname [as 别名]
def part(instance, source, channel, *_):
	nick = Irc.get_nickname(source)
	if nick == instance:
		del Global.account_cache[channel]
		Logger.log("w", "Removing cache for " + channel)
		return
	if nick in Global.account_cache[channel]:
		del Global.account_cache[channel][nick]
		Logger.log("w", "Removing %s from %s" % (nick, channel))
开发者ID:hashfaster,项目名称:Doger,代码行数:11,代码来源:Hooks.py

示例6: join

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import get_nickname [as 别名]
def join(instance, source, channel, account, _):
	if account == "*":
		account = False
	nick = Irc.get_nickname(source)
	with Global.account_lock:
		if nick  == instance:
			Global.account_cache[channel] = {}
		Global.account_cache[channel][nick] = account
		for channel in Global.account_cache:
			if nick in Global.account_cache[channel]:
				Global.account_cache[channel][nick] = account
				Logger.log("w", "Propagating %s=%s into %s" % (nick, account, channel))
开发者ID:digideskio,项目名称:Doger,代码行数:14,代码来源:Hooks.py

示例7: quit

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import get_nickname [as 别名]
def quit(instance, source, _):
	nick = Irc.get_nickname(source)
	if nick == instance:
		chans = []
		for channel in Global.account_cache:
			if nick in Global.account_cache[channel]:
				chans.append(channel)
		for channel in chans:
				del Global.account_cache[channel]
				Logger.log("w", "Removing cache for " + channel)
		return
	for channel in Global.account_cache:
		if nick in Global.account_cache[channel]:
			del Global.account_cache[channel][nick]
			Logger.log("w", "Removing %s from %s" % (nick, channel))
开发者ID:hashfaster,项目名称:Doger,代码行数:17,代码来源:Hooks.py

示例8: __init__

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import get_nickname [as 别名]
	def __init__(self, serv, target, source):
		self.serv = serv
		self.target = target
		self.source = source
		self.nick = Irc.get_nickname(source)
开发者ID:red-green,项目名称:python-irc-framework,代码行数:7,代码来源:Hooks.py

示例9: __init__

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import get_nickname [as 别名]
	def __init__(self, instance, target, source, text):
		self.instance = instance
		self.target = target
		self.source = source
		self.nick = Irc.get_nickname(source)
		self.text = text
开发者ID:digideskio,项目名称:Doger,代码行数:8,代码来源:Hooks.py


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