本文整理汇总了Python中stats.Stats.count方法的典型用法代码示例。如果您正苦于以下问题:Python Stats.count方法的具体用法?Python Stats.count怎么用?Python Stats.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stats.Stats
的用法示例。
在下文中一共展示了Stats.count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Pilot
# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import count [as 别名]
class Pilot():
def __init__(self, config, hq):
self.config = config
self.ident = config.ident
self.hq = hq
self.state = 0
self.perm8_state = 0
self.stats = Stats(config, hq)
def parse(self, line):
response = ""
msg = line.split(':')
if self.state == 0: # Just connected.
if len(msg) > 2 and msg[1].count("376"): # End of MOTD
if self.ident.password and not self.config.bnc: # If we need to identify.
self.state = 1
else:
self.state = 2
elif self.state == 1:
if len(msg) > 2 and msg[2].count("registered and protected"):
response = "PRIVMSG nickserv :identify " + self.ident.password + "\r\n"
self.hq.log("[+] Identifying with NickServ")
if len(msg) > 2 and msg[2].count("recognized"): # Authenticated successfully.
self.state = 2
elif self.state == 2:
if not self.config.bnc:
for chan in self.config.channels:
response += "JOIN " + chan + "\r\n"
self.hq.log("[+] Joining " + chan)
self.state = 3
elif self.state == 3:
if len(msg) > 2:
msg[2] = msg[2].strip("\r")
self.hq.log(msg[1])
m = re.search("^(\w+)!.+ (.+) $", msg[1])
if m:
sender = m.group(1)
chan = m.group(2)
if chan.count(self.ident.nick):
recip = sender
else:
recip = chan
else:
m = re.search("^.+ (.+) $", msg[1])
chan = m.group(1)
if msg[1].count("366"):
self.stats.join(chan)
if msg[2].count("!btc"):
response = "PRIVMSG " + recip + " :" + self.getBTC() + "\r\n"
self.stats.count("!btc")
if msg[2].count("!md5"):
response = "PRIVMSG " + recip + " :" + self.md5hash(msg) + "\r\n"
self.stats.count("!md5")
if msg[2].count("!time"):
response = "PRIVMSG " + recip + " :http://i.imgur.com/CfNS0uY.gif\r\n"
self.stats.count("!time")
if msg[2].count("!stats"):
response = ""
stats = self.stats.getStats()
for stat in stats:
response += "PRIVMSG " + recip + " :" + stat + "\r\n"
self.stats.count("!stats")
if msg[2].count("!insult"):
response = "PRIVMSG " + recip + " :"
m = re.search("!insult (.+)$", msg[2])
if m:
response += m.group(1) + ", " + self.getInsult() + "\r\n"
else:
response += self.getInsult() + "\r\n"
self.stats.count("!insult")
if msg[2].count(self.ident.nick):
huh_message = ""
response = "PRIVMSG " + recip + " :" + huh_message + "\r\n"
# if self.perm8_state:
# response = self.perm8(msg)
# if len(msg) > 2 and msg[2].count("!eject"):
# response = "QUIT :" + self.ident.quit + "\r\n"
# Exit script here.
# elif len(msg) > 2 and msg[2].count("!perm8") and not msg[2].count("!perm8-attack"):
# response = "NOTICE moo :!perm8\r\n"
# self.perm8_state = 1
return response
#.........这里部分代码省略.........
示例2: Pilot
# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import count [as 别名]
class Pilot():
def __init__(self, config, hq):
self.config = config
self.ident = config.ident
self.hq = hq
self.state = 0
self.perm8_state = 0
self.stats = Stats(config, hq)
self.utils = Utilities()
def parse(self, line):
response = ""
msg = line.split(':')
if self.state == 0: # Just connected.
if len(msg) > 2 and msg[1].count("376"): # End of MOTD
if self.ident.password and not self.config.bnc: # If we need to identify.
self.state = 1
else:
self.state = 2
elif self.state == 1:
if len(msg) > 2 and msg[2].count("registered and protected"):
response = "PRIVMSG nickserv :identify " + self.ident.password + "\r\n"
self.hq.log("[+] Identifying with NickServ")
if len(msg) > 2 and msg[2].count("recognized"): # Authenticated successfully.
self.state = 2
elif self.state == 2:
if not self.config.bnc:
for chan in self.config.channels:
response += "JOIN " + chan + "\r\n"
self.hq.log("[+] Joining " + chan)
self.state = 3
elif self.state == 3:
if len(msg) > 2:
msg[2] = msg[2].strip("\r")
self.hq.log(msg[1])
m = re.search("^:(\w+)!(.+) (\w+) (.+) :(.+)$", line)
if m:
nick = m.group(1)
host = m.group(2)
msgtyp = m.group(3)
chan = m.group(4)
message = m.group(5)
if chan.count(self.ident.nick):
recip = nick
else:
recip = chan
response = self.process(nick, host, msgtyp, recip, message)
else:
m = re.search("^.+ (.+) $", msg[1])
chan = m.group(1)
if msg[1].count("366"):
self.stats.join(chan)
elif msg[1].count("KICK"):
self.stats.leave(chan)
response = "JOIN " + chan + "\r\n"
return response
def process(self, nick, host, msgtype, recip, message):
self.hq.log("[~] " + message)
responses = []
response = ""
if message.count(self.ident.nick):
for util in self.utils.functions():
if message.count(util):
print "[*] It's a utility"
responses = self.utils.execute(message)
response = self.privMsg(recip, responses)
self.stats.count(util)
break
if message.count("stats"):
print "[*] Stat!"
stats = self.stats.getStats()
self.stats.count("stats")
response = self.privMsg(recip, stats)
elif message.count("goose"):
response = "QUIT :" + self.ident.quit + "\r\n"
print response
return response
def getState(self):
self.hq.log("Self.state: " + str(self.state))
return
def privMsg(self, recip, msgs):
response = ""
for msg in msgs:
response += "PRIVMSG " + recip + " :" + msg + "\r\n"
return response