本文整理汇总了Python中Irc.is_ignored方法的典型用法代码示例。如果您正苦于以下问题:Python Irc.is_ignored方法的具体用法?Python Irc.is_ignored怎么用?Python Irc.is_ignored使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Irc
的用法示例。
在下文中一共展示了Irc.is_ignored方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: message
# 需要导入模块: import Irc [as 别名]
# 或者: from Irc import is_ignored [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()