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


Python Irc.instance_send方法代码示例

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


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

示例1: privmsg

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
	def privmsg(self, targ, text, priority = None):
		Logger.log("c", self.instance + ": %s <- %s " % (targ, text))
		for i in xrange(0, len(text), 350):
			if priority:
				Irc.instance_send(self.instance, ("PRIVMSG", targ, text[i:i+350]), priority = priority)
			else:
				Irc.instance_send(self.instance, ("PRIVMSG", targ, text[i:i+350]))
开发者ID:digideskio,项目名称:Doger,代码行数:9,代码来源:Hooks.py

示例2: tip

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
def tip(req, arg):
	"""%tip <target> <amount> - Sends 'amount' coins to the specified nickname"""
	if len(arg) < 2:
		return req.reply("%tip <target> <amount>")
	to = arg[0]
	acct, toacct = Irc.account_names([req.nick, to])
	if not acct:
		return req.reply_private("You are not identified with freenode services (see /msg NickServ help)")
	if not toacct:
		if toacct == None:
			return req.reply_private(to + " is not online")
		else:
			return req.reply_private(to + " is not identified with freenode services")
	try:
		amount = int(arg[1])
		if amount <= 0:
			raise ValueError()
		amount = min(amount, 1000000000000)
	except ValueError as e:
		req.reply_private(repr(arg[1]) + " - invalid amount")
		return None
	with Logger.token() as token:
		try:
			Transactions.tip(acct, toacct, amount)
			token.log("t", "acct:%s tipped %d to acct:%s(%d)" % (acct, amount, toacct, Transactions.balance(toacct)))
			if Irc.equal_nicks(req.nick, req.target):
				req.reply("Done [%s]" % (token.id))
			else:
				req.say("Such %s tipped much Ɖ%i to %s! (to claim /msg Doger help) [%s]" % (req.nick, amount, to, token.id))
			Irc.instance_send(req.instance, "PRIVMSG", to, "Such %s has tipped you Ɖ%i (to claim /msg Doger help) [%s]" % (req.nick, amount, token.id))
		except Transactions.NotEnoughMoney:
			req.reply_private("You tried to tip Ɖ%i but you only have Ɖ%i" % (amount, Transactions.balance(acct)))
开发者ID:hashfaster,项目名称:Doger,代码行数:34,代码来源:Commands.py

示例3: message

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

示例4: admin

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
def admin(req, arg):
	"""
	admin"""
	if len(arg):
		command = arg[0]
		arg = arg[1:]
		if command == "reload":
			for mod in arg:
				reload(sys.modules[mod])
			req.reply("Reloaded")
		elif command == "exec" and Config.config.get("enable_exec", None):
			exec(" ".join(arg).replace("$", "\n"))
		elif command == "ignore":
			Irc.ignore(arg[0], int(arg[1]))
			req.reply("Ignored")
		elif command == "die":
			for instance in Global.instances:
				Global.manager_queue.put(("Disconnect", instance))
			Global.manager_queue.join()
			Blocknotify.stop()
			Global.manager_queue.put(("Die",))
		elif command == "restart":
			for instance in Global.instances:
				Global.manager_queue.put(("Disconnect", instance))
			Global.manager_queue.join()
			Blocknotify.stop()
			os.execv(sys.executable, [sys.executable] + sys.argv)
		elif command == "manager":
			for cmd in arg:
				Global.manager_queue.put(cmd.split("$"))
			req.reply("Sent")
		elif command == "raw":
			Irc.instance_send(req.instance, eval(" ".join(arg)))
		elif command == "config":
			if arg[0] == "save":
				os.rename("Config.py", "Config.py.bak")
				with open("Config.py", "w") as f:
					f.write("config = " + pprint.pformat(Config.config) + "\n")
				req.reply("Done")
			elif arg[0] == "del":
				exec("del Config.config " + " ".join(arg[1:]))
				req.reply("Done")
			else:
				try:
					req.reply(repr(eval("Config.config " + " ".join(arg))))
				except SyntaxError:
					exec("Config.config " + " ".join(arg))
					req.reply("Done")
		elif command == "join":
			Irc.instance_send(req.instance, ("JOIN", arg[0]), priority = 0.1)
		elif command == "part":
			Irc.instance_send(req.instance, ("PART", arg[0]), priority = 0.1)
		elif command == "caches":
			acsize = 0
			accached = 0
			with Global.account_lock:
				for channel in Global.account_cache:
					for user in Global.account_cache[channel]:
						acsize += 1
						if Global.account_cache[channel][user] != None:
							accached += 1
			acchannels = len(Global.account_cache)
			whois = " OK"
			whoisok = True
			for instance in Global.instances:
				tasks = Global.instances[instance].whois_queue.unfinished_tasks
				if tasks:
					if whoisok:
						whois = ""
						whoisok = False
					whois += " %s:%d!" % (instance, tasks)
			req.reply("Account caches: %d user-channels (%d cached) in %d channels; Whois queues:%s" % (acsize, accached, acchannels, whois))
		elif command == "channels":
			inss = ""
			for instance in Global.instances:
				chans = []
				with Global.account_lock:
					for channel in Global.account_cache:
						if instance in Global.account_cache[channel]:
							chans.append(channel)
				inss += " %s:%s" % (instance, ",".join(chans))
			req.reply("Instances:" + inss)
		elif command == "balances":
			database, dogecoind = Transactions.balances()
			req.reply("Dogecoind: %.8f; Database: %.8f" % (dogecoind, database))
		elif command == "blocks":
			info, hashd = Transactions.get_info()
			hashb = Transactions.lastblock
			req.reply("Best block: " + hashd + ", Last tx block: " + hashb + ", Blocks: " + str(info.blocks) + ", Testnet: " + str(info.testnet))
		elif command == "lock":
			if len(arg) > 1:
				if arg[1] == "on":
					Transactions.lock(arg[0], True)
				elif arg[1] == "off":
					Transactions.lock(arg[0], False)
				req.reply("Done")
			elif len(arg):
				req.reply("locked" if Transactions.lock(arg[0]) else "not locked")
开发者ID:justinvforvendetta,项目名称:Doger,代码行数:100,代码来源:Commands.py

示例5: end_of_motd

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
def end_of_motd(instance, *_):
	Global.instances[instance].can_send.set()
	Logger.log("c", instance + ": End of motd, joining " + " ".join(Config.config["instances"][instance]))
	for channel in Config.config["instances"][instance]:
		Irc.instance_send(instance, ("JOIN", channel))
开发者ID:digideskio,项目名称:Doger,代码行数:7,代码来源:Hooks.py

示例6: sasl_success

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
def sasl_success(instance, _, data, __):
	Logger.log("c", "Finished authentication")
	Irc.instance_send(instance, ("CAP", "END"), lock = False)
	Irc.instance_send(instance, ("CAP", "REQ", "extended-join account-notify"), lock = False)
开发者ID:digideskio,项目名称:Doger,代码行数:6,代码来源:Hooks.py

示例7: authenticate

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
def authenticate(instance, _, data):
	if data == "+":
		load = Config.config["account"] + "\0" + Config.config["account"] + "\0" + Config.config["password"]
		Irc.instance_send(instance, ("AUTHENTICATE", load.encode("base64").rstrip("\n")), lock = False)
开发者ID:digideskio,项目名称:Doger,代码行数:6,代码来源:Hooks.py

示例8: cap

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
def cap(instance, _, __, ___, caps):
	if caps.rstrip(" ") == "sasl":
		Irc.instance_send(instance, ("AUTHENTICATE", "PLAIN"), lock = False)
开发者ID:digideskio,项目名称:Doger,代码行数:5,代码来源:Hooks.py

示例9: ping

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
def ping(instance, source, *args):
	Irc.instance_send(instance, tuple(("PONG",) + args), priority = 0, lock = False)
开发者ID:digideskio,项目名称:Doger,代码行数:4,代码来源:Hooks.py

示例10: irclog

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
def irclog(text):
	if Config.config.get("irclog", None):
		for i in xrange(0, len(text), 350):
			Irc.instance_send(Config.config["irclog"][0], ("PRIVMSG", Config.config["irclog"][1], text[i:i+300]), priority = 0)
开发者ID:justinvforvendetta,项目名称:Doger,代码行数:6,代码来源:Logger.py

示例11: privmsg

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
	def privmsg(self, targ, text):
		Logger.log("c", self.instance + ": %s <- %s " % (targ, text))
		while len(text) > 350:
			Irc.instance_send(self.instance, "PRIVMSG", targ, text[:349])
			text = text[350:]
		Irc.instance_send(self.instance, "PRIVMSG", targ, text)
开发者ID:hashfaster,项目名称:Doger,代码行数:8,代码来源:Hooks.py

示例12: ping

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
def ping(instance, *_):
	Irc.instance_send(instance, "PONG")
开发者ID:hashfaster,项目名称:Doger,代码行数:4,代码来源:Hooks.py

示例13: ping

# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import instance_send [as 别名]
def ping(instance, *_):
	Irc.instance_send(instance, ("PONG",), priority = 0)
开发者ID:justinvforvendetta,项目名称:Doger,代码行数:4,代码来源:Hooks.py


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