本文整理汇总了Python中supybot.ircutils.nickEqual函数的典型用法代码示例。如果您正苦于以下问题:Python nickEqual函数的具体用法?Python nickEqual怎么用?Python nickEqual使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nickEqual函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTopUsers
def getTopUsers(self, channel, word, n):
L = [(id, d[word]) for ((chan, id), d) in self.iteritems()
if ircutils.nickEqual(channel, chan) and word in d]
utils.sortBy(lambda (_, i): i, L)
L = L[-n:]
L.reverse()
return L
示例2: delWord
def delWord(self, channel, word):
if word in self.channelWords[channel]:
del self.channelWords[channel][word]
for ((chan, id), d) in self.iteritems():
if ircutils.nickEqual(chan, channel):
if word in d:
del d[word]
示例3: combine
def combine(msgs, reverse=True, stamps=False, nicks=True, compact=True,
joiner=r' \ ', nocolor=False):
"""
Formats and returns a list of IrcMsg objects (<msgs>) as a string.
<reverse>, if True, prints messages from last to first.
<stamps>, if True, appends timestamps to messages.
<reverse>, if True, orders messages by earliest to most recent.
<compact>, if False, append nicks to consecutive messages
<joiner>, the character joining lines together (default: ' \ ').
<nocolor>, if True, strips color from messages.
Sample output:
<bigman> DUNK \ <bigbitch> \ bluh \ bluh
"""
output = []
lastnick = ''
for msg in reversed(msgs) if reverse else msgs:
isaction = ircmsgs.isAction(msg)
if isaction:
text = '[%s %s]' % (msg.nick, ircmsgs.unAction(msg))
else:
if compact and ircutils.nickEqual(msg.nick, lastnick) or not nicks:
text = msg.args[1]
else:
lastnick = msg.nick
text = '<%s> %s' % (msg.nick, msg.args[1])
if stamps:
stampfmt = '%d-%m-%y %H:%M:%S'
stamp = time.strftime(stampfmt, time.localtime(msg.receivedAt))
text = '[{0}] {1}'.format(stamp, text)
output.append(ircutils.stripFormatting(text))
return joiner.join(output)
示例4: tell
def tell(self, irc, msg, args, target, text):
"""<nick> <text>
Tells the <nick> whatever <text> is. Use nested commands to your
benefit here.
"""
if target.lower() == 'me':
target = msg.nick
if ircutils.isChannel(target):
irc.error('Dude, just give the command. No need for the tell.')
return
if not ircutils.isNick(target):
irc.errorInvalid('nick', target)
if ircutils.nickEqual(target, irc.nick):
irc.error('You just told me, why should I tell myself?',Raise=True)
if target not in irc.state.nicksToHostmasks and \
not ircdb.checkCapability(msg.prefix, 'owner'):
# We'll let owners do this.
s = 'I haven\'t seen %s, I\'ll let you do the telling.' % target
irc.error(s, Raise=True)
if irc.action:
irc.action = False
text = '* %s %s' % (irc.nick, text)
s = '%s wants me to tell you: %s' % (msg.nick, text)
irc.reply(s, to=target, private=True)
示例5: cutwire
def cutwire(self, irc, msg, args, channel, cutWire):
"""<colored wire>
Will cut the given wire if you've been timebombed."""
channel = ircutils.toLower(channel)
try:
if not self.bombs[channel].active:
return
if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick):
irc.reply('You can\'t cut the wire on someone else\'s bomb!')
return
else:
self.responded = True
spellCheck = False
for item in self.bombs[channel].wires :
if item.lower() == cutWire.lower():
spellCheck = True
if spellCheck == False :
irc.reply("That doesn't appear to be one of the options.")
return
self.bombs[channel].cutwire(irc, cutWire)
except KeyError:
pass
irc.noReply()
示例6: tell
def tell(self, irc, msg, args, target, text):
"""<nick> <text>
Tells the <nick> whatever <text> is. Use nested commands to your
benefit here.
"""
if irc.nested:
irc.error("This command cannot be nested.", Raise=True)
if target.lower() == "me":
target = msg.nick
if ircutils.isChannel(target):
irc.error("Dude, just give the command. No need for the tell.")
return
if not ircutils.isNick(target):
irc.errorInvalid("nick", target)
if ircutils.nickEqual(target, irc.nick):
irc.error("You just told me, why should I tell myself?", Raise=True)
if target not in irc.state.nicksToHostmasks and not ircdb.checkCapability(msg.prefix, "owner"):
# We'll let owners do this.
s = "I haven't seen %s, I'll let you do the telling." % target
irc.error(s, Raise=True)
if irc.action:
irc.action = False
text = "* %s %s" % (irc.nick, text)
s = "%s wants me to tell you: %s" % (msg.nick, text)
irc.replySuccess()
irc.reply(s, to=target, private=True)
示例7: defuse
def defuse(self, irc, msg, args, channel):
"""Takes no arguments
Defuses the active bomb (channel ops only)"""
channel = ircutils.toLower(channel)
try:
if self.bombs[channel].active:
if ircutils.nickEqual(self.bombs[channel].victim, msg.nick) and not (ircutils.nickEqual(self.bombs[channel].victim, self.bombs[channel].sender) or ircdb.checkCapability(msg.prefix, 'admin')):
irc.reply('You can\'t defuse a bomb that\'s in your own pants, you\'ll just have to cut a wire and hope for the best.')
return
self.bombs[channel].defuse()
irc.reply('Bomb defused')
else:
irc.error('There is no active bomb')
except KeyError:
pass
irc.error('There is no active bomb')
示例8: addWord
def addWord(self, channel, word):
if channel not in self.channelWords:
self.channelWords[channel] = {}
self.channelWords[channel][word] = 0
for ((chan, id), d) in self.iteritems():
if ircutils.nickEqual(chan, channel):
if word not in d:
d[word] = 0
示例9: doForce
def doForce(self, irc, msg, match):
r'^no,\s+(\w+,\s+)?(.+?)\s+(?<!\\)(was|is|am|were|are)\s+(.+?[?!. ]*)$'
(nick, key, isAre, value) = match.groups()
value = value.rstrip()
key.rstrip('?')
if not msg.addressed:
if nick is None:
self.log.debug('Not forcing because we weren\'t addressed and '
'payload wasn\'t of the form: no, irc.nick, ..')
return
nick = nick.rstrip(' \t,')
if not ircutils.nickEqual(nick, irc.nick):
self.log.debug('Not forcing because the regexp nick didn\'t '
'match our nick.')
return
else:
if nick is not None:
stripped = nick.rstrip(' \t,')
if not ircutils.nickEqual(stripped, irc.nick):
key = nick + key
isAre = isAre.lower()
if self.added:
return
channel = dynamic.channel
if isAre in ('was', 'is', 'am'):
if self.db.hasIs(channel, key):
oldValue = self.db.getIs(channel, key)
if oldValue.lower() == value.lower():
self.reply(format('I already had it that way, %s.',
msg.nick))
return
self.log.debug('Forcing %q to %q.', key, value)
self.added = True
self.db.setIs(channel, key, value)
else:
if self.db.hasAre(channel, key):
oldValue = self.db.getAre(channel, key)
if oldValue.lower() == value.lower():
self.reply(format('I already had it that way, %s.',
msg.nick))
return
self.log.debug('Forcing %q to %q.', key, value)
self.added = True
self.db.setAre(channel, key, value)
self.confirm()
示例10: duck
def duck(self, irc, ducker):
if self.thrown and ircutils.nickEqual(self.victim, ducker):
self.irc.queueMsg(
ircmsgs.privmsg(
self.channel,
"{} ducks! The bomb misses, and explodes harmlessly a few meters away.".format(self.victim),
)
)
self.defuse()
示例11: duck
def duck(self, irc, ducker):
if self.thrown and ircutils.nickEqual(self.victim, ducker):
self.irc.queueMsg(
ircmsgs.privmsg(
self.channel,
"%s ducks! The bomb misses, and explodes harmlessly a few meters away." % self.victim,
)
)
self.active = False
self.thrown = False
schedule.removeEvent("%s_bomb" % self.channel)
示例12: grab
def grab(self, irc, msg, args, channel, nick):
"""[<channel>] <nick>
Grabs a quote from <channel> by <nick> for the quotegrabs table.
<channel> is only necessary if the message isn't sent in the channel
itself.
"""
# chan is used to make sure we know where to grab the quote from, as
# opposed to channel which is used to determine which db to store the
# quote in
chan = msg.args[0]
if chan is None:
raise callbacks.ArgumentError
if ircutils.nickEqual(nick, msg.nick):
irc.error(_("You can't quote grab yourself."), Raise=True)
for m in reversed(irc.state.history):
if m.command == "PRIVMSG" and ircutils.nickEqual(m.nick, nick) and ircutils.strEqual(m.args[0], chan):
self._grab(channel, irc, m, msg.prefix)
irc.replySuccess()
return
irc.error(_("I couldn't find a proper message to grab."))
示例13: cutwire
def cutwire(self, irc, msg, args, channel, cutWire):
"""<colored wire>
Will cut the given wire if you've been timebombed."""
channel = ircutils.toLower(channel)
try:
if not self.bombs[channel].active:
return
if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick) and not ircdb.checkCapability(msg.prefix, 'admin'):
irc.reply('You can\'t cut the wire on someone else\'s bomb!')
return
self.bombs[channel].cutwire(irc, cutWire)
except KeyError:
pass
irc.noReply()
示例14: cutwire
def cutwire(self, irc, msg, args, channel, cutWire):
"""<colored wire>
Will cut the given wire if you've been timebombed."""
channel = ircutils.toLower(channel)
try:
if not self.bombs[channel].active:
return
if not ircutils.nickEqual(self.bombs[channel].victim, msg.nick):
irc.reply("You can't cut the wire on someone else's bomb!")
return
self.bombs[channel].cutwire(irc, cutWire)
except KeyError:
pass
irc.noReply()
示例15: ungrab
def ungrab(self, irc, msg, args, channel, grab):
"""[<channel>] <number>
Removes the grab <number> (the last by default) on <channel>.
<channel> is only necessary if the message isn't sent in the channel
itself. You may only ungrab quotes you made or grabbed.
"""
try:
original = self.db.get(channel, grab)
if ircutils.nickEqual(ircutils.nickFromHostmask(original.grabber), msg.nick) or ircutils.nickEqual(original.by, msg.nick):
self.db.remove(channel, grab)
irc.replySuccess()
else:
irc.error('Can only ungrab quotes made or grabbed by you.')
except dbi.NoRecordError:
if grab is None:
irc.error('Nothing to ungrab.')
else:
irc.error('Invalid grab number.')