本文整理汇总了Python中supybot.ircutils.strEqual函数的典型用法代码示例。如果您正苦于以下问题:Python strEqual函数的具体用法?Python strEqual怎么用?Python strEqual使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strEqual函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _doKarma
def _doKarma(self, irc, msg, channel, thing):
inc = self.registryValue('incrementChars', channel)
dec = self.registryValue('decrementChars', channel)
onlynicks = self.registryValue('onlyNicks', channel)
karma = ''
for s in inc:
if thing.endswith(s):
thing = thing[:-len(s)]
# Don't reply if the target isn't a nick
if onlynicks and thing.lower() not in map(ircutils.toLower,
irc.state.channels[channel].users):
return
if ircutils.strEqual(thing, msg.nick) and \
not self.registryValue('allowSelfRating', channel):
irc.error(_('You\'re not allowed to adjust your own karma.'))
return
self.db.increment(channel, self._normalizeThing(thing))
karma = self.db.get(channel, self._normalizeThing(thing))
for s in dec:
if thing.endswith(s):
thing = thing[:-len(s)]
if onlynicks and thing.lower() not in map(ircutils.toLower,
irc.state.channels[channel].users):
return
if ircutils.strEqual(thing, msg.nick) and \
not self.registryValue('allowSelfRating', channel):
irc.error(_('You\'re not allowed to adjust your own karma.'))
return
self.db.decrement(channel, self._normalizeThing(thing))
karma = self.db.get(channel, self._normalizeThing(thing))
if karma:
self._respond(irc, channel, thing, karma[0]-karma[1])
示例2: doNick
def doNick(self, irc, msg):
nick = self._getNick()
if ircutils.strEqual(msg.args[0], irc.nick) and \
ircutils.strEqual(irc.nick, nick):
self._doIdentify(irc)
elif ircutils.strEqual(msg.nick, nick):
irc.sendMsg(ircmsgs.nick(nick))
示例3: shutup
def shutup(self, irc, msg, args, text):
"""<who> [for <reason>]
Tells <who> to shutup.
"""
def _firstWord(s):
return s.split()[0]
if ' for ' in text:
(target, reason) = map(str.strip, text.split(' for ', 1))
else:
(target, reason) = (text, '')
msgtext = "duct tapes $who"
text = self._replaceFirstPerson(msgtext, msg.nick)
if ircutils.strEqual(target, irc.nick) or ircutils.strEqual(_firstWord(target), irc.nick):
target = msg.nick
reason = self._replaceFirstPerson('trying to dis me', irc.nick)
else:
target = self._replaceFirstPerson(target, msg.nick)
reason = self._replaceFirstPerson(reason, msg.nick)
if target.endswith('.'):
target = target.rstrip('.')
text = text.replace('$who', target)
if reason:
text += ' for ' + reason
irc.reply(text, action=True)
示例4: _doKarma
def _doKarma(self, irc, channel, thing):
assert thing[-2:] in ('++', '--')
if thing.endswith('C++'):
c = 2
elif thing.endswith('c++'):
c = 2
elif thing.endswith('++'):
thing = thing[:-2]
if ircutils.strEqual(thing, irc.msg.nick) and \
not self.registryValue('allowSelfRating', channel):
irc.error('Voc\xc3\xaa n\xc3\xa3o pode dar cervejas para voc\xc3\xaa mesmo')
elif thing:
self.db.increment(channel, self._normalizeThing(thing))
self._respond(irc, channel)
else:
thing = thing[:-2]
if ircutils.strEqual(thing, irc.msg.nick) and \
not self.registryValue('allowSelfRating', channel):
irc.error('Voc\xc3\xaa n\xc3\xa3o pode dar cervejas para voc\xc3\xaa mesmo')
elif thing:
self.db.decrement(channel, self._normalizeThing(thing))
self._respond(irc, channel)
t = self.db.get(channel, thing)
(added, subtracted) = t
total = added - subtracted
if thing.endswith('C++'):
c = 2
elif thing.endswith('c++'):
c = 2
else:
irc.reply('%s tem %s00Ml de cerveja' % (thing, total))
示例5: doNotice
def doNotice(self, irc, msg):
if irc.afterConnect:
nickserv = self.registryValue('NickServ')
chanserv = self.registryValue('ChanServ')
if nickserv and ircutils.strEqual(msg.nick, nickserv):
self.doNickservNotice(irc, msg)
elif chanserv and ircutils.strEqual(msg.nick, chanserv):
self.doChanservNotice(irc, msg)
示例6: doMode
def doMode(self, irc, msg):
channel = msg.args[0]
chanOp = ircdb.makeChannelCapability(channel, 'op')
chanVoice = ircdb.makeChannelCapability(channel, 'voice')
chanHalfOp = ircdb.makeChannelCapability(channel, 'halfop')
if not ircdb.checkCapability(msg.prefix, chanOp):
irc.sendMsg(ircmsgs.deop(channel, msg.nick))
for (mode, value) in ircutils.separateModes(msg.args[1:]):
if not value:
continue
if ircutils.strEqual(value, msg.nick):
# We allow someone to mode themselves to oblivion.
continue
if irc.isNick(value):
hostmask = irc.state.nickToHostmask(value)
if mode == '+o':
if not self.isOp(irc, channel, hostmask):
irc.queueMsg(ircmsgs.deop(channel, value))
elif mode == '+h':
if not ircdb.checkCapability(hostmask, chanHalfOp):
irc.queueMsg(ircmsgs.dehalfop(channel, value))
elif mode == '+v':
if not ircdb.checkCapability(hostmask, chanVoice):
irc.queueMsg(ircmsgs.devoice(channel, value))
elif mode == '-o':
if ircdb.checkCapability(hostmask, chanOp):
irc.queueMsg(ircmsgs.op(channel, value))
elif mode == '-h':
if ircdb.checkCapability(hostmask, chanOp):
irc.queueMsg(ircmsgs.halfop(channel, value))
elif mode == '-v':
if ircdb.checkCapability(hostmask, chanOp):
irc.queueMsg(ircmsgs.voice(channel, value))
else:
assert ircutils.isUserHostmask(value)
示例7: doJoin
def doJoin(self, irc, msg):
channel = msg.args[0]
if self.registryValue('enabled', channel):
if not ircutils.strEqual(irc.nick, msg.nick):
irc = callbacks.SimpleProxy(irc, msg)
now = time.time()
throttle = self.registryValue('throttle', channel)
if now - self.lastBacklog.get((channel, msg.nick), now-1-throttle) < throttle:
return
else:
self.lastBacklog[channel, msg.nick] = now
try:
lines = int(self.db["1337allthechannels1337", msg.nick])
except:
lines = int(self.registryValue('lines'))
if lines != 0:
irc.queueMsg(ircmsgs.notice(msg.nick, "Hello "+msg.nick+". I will now show you up to "+str(lines)+" messages from "+channel+", before you joined. To change this behavior, write me: @setbackloglines [0-25]. Setting it to zero disables this feature. Time is GMT."))
logg = self.logck.get(channel, lines)
for i in range(0, lines):
if len(logg) <= 0:
break;
else:
irc.queueMsg(ircmsgs.notice(msg.nick,str((logg[:1]).pop())))
logg = logg[1:]
self.doLog(irc, channel, '*** %s <%s> has joined %s', msg.nick, msg.prefix, channel)
示例8: any
def any(self, irc, msg, args, channel, optlist, name):
"""[<channel>] [--user <name>] [<nick>]
Returns the last time <nick> was seen and what <nick> was last seen
doing. This includes any form of activity, instead of just PRIVMSGs.
If <nick> isn't specified, returns the last activity seen in
<channel>. If --user is specified, looks up name in the user database
and returns the last time user was active in <channel>. <channel> is
only necessary if the message isn't sent on the channel itself.
"""
if name and ircutils.strEqual(name, irc.nick):
irc.reply(_("You've found me!"))
return
self._checkChannelPresence(irc, channel, msg.nick, True)
if name and optlist:
raise callbacks.ArgumentError
elif name:
self._seen(irc, channel, name, any=True)
elif optlist:
for (option, arg) in optlist:
if option == 'user':
user = arg
self._user(irc, channel, user, any=True)
else:
self._last(irc, channel, any=True)
示例9: _validLastMsg
def _validLastMsg(self, irc, msg, chan):
return (
msg.prefix
and msg.command == "PRIVMSG"
and irc.isChannel(msg.args[0])
and ircutils.strEqual(chan, msg.args[0])
)
示例10: add
def add(self, irc, msg, args, user, capability):
"""<name|hostmask> <capability>
Gives the user specified by <name> (or the user to whom <hostmask>
currently maps) the specified capability <capability>
"""
# Ok, the concepts that are important with capabilities:
#
### 1) No user should be able to elevate their privilege to owner.
### 2) Admin users are *not* superior to #channel.ops, and don't
### have God-like powers over channels.
### 3) We assume that Admin users are two things: non-malicious and
### and greedy for power. So they'll try to elevate their
### privilege to owner, but they won't try to crash the bot for
### no reason.
# Thus, the owner capability can't be given in the bot. Admin
# users can only give out capabilities they have themselves (which
# will depend on supybot.capabilities and its child default) but
# generally means they can't mess with channel capabilities.
if ircutils.strEqual(capability, 'owner'):
irc.error(_('The "owner" capability can\'t be added in the '
'bot. Use the supybot-adduser program (or edit the '
'users.conf file yourself) to add an owner '
'capability.'))
return
if ircdb.isAntiCapability(capability) or \
ircdb.checkCapability(msg.prefix, capability):
user.addCapability(capability)
ircdb.users.setUser(user)
irc.replySuccess()
else:
irc.error(_('You can\'t add capabilities you don\'t have.'))
示例11: greeter
def greeter(self, irc, msg, args):
""" (add|remove) nick1 [nick2 nick3...]
This plugin will issue a greeting via privmsg for the first time
someone joins a channel. Doing greeter add foobar causes that nick
to be added to the list of nicks to ignore. Remove command removes
them from the list of nicks to ignore.
If called without arguments, will send the caller the introduction
message via privmsg, regardless of whether they've already been
greeted. """
channel = msg.args[0]
# apparently having remove and add in their own defs
# makes then "available" as their own plugins. IE
# @remove and @add, don't want that, so having the
# @greeter part do the add/remove via private methods
if len(args) == 0:
if ircutils.strEqual(irc.nick, msg.nick):
return # It's us
irc.queueMsg(ircmsgs.privmsg(msg.nick, joinmsg % ( irc.nick ) ))
irc.noReply()
else:
# should see if there's a way to trigger help message
irc.reply(" I don't understand what you are asking ")
示例12: doJoin
def doJoin(self, irc, msg):
#irc.reply("hello")
if ircutils.strEqual(irc.nick, msg.nick):
return # It's us
channel = msg.args[0]
if channel != "#code4lib" and channel not in test_channels:
return
#if self.db[channel, msg.nick] is None:
try:
self.db.get(channel, msg.nick)
except KeyError:
# The except means that we only message people not yet in the db.
irc.queueMsg(ircmsgs.privmsg(msg.nick, joinmsg % ( irc.nick ) ))
irc.noReply()
#self.db.add(channel, msg.nick)
self.db.add(channel, msg.nick)
# Also notify the helpers privately if a potential newbie shows up,
# so that we can roll out the welcome mat human-style.
for helper in self._get_helpers(channel):
# Sometimes the helpers db stores blank lines, which we should
# ignore.
if helper:
irc.queueMsg(ircmsgs.privmsg(helper, helpermsg % ( msg.nick ) ))
irc.noReply()
示例13: doJoin
def doJoin(self, irc, msg):
channel = msg.args[0]
sender = msg.nick
if (ircutils.strEqual(msg.nick, irc.nick)):
### Put the per-channel values into the channel's config
# get the graph
graph = self.instances[irc.network].getGraph(channel)
# pull out the config and copy it
channelConfig = graph.config.copy()
# put in the values
channelConfig.update(
outputWidth=self.registryValue('image.outputWidth', channel),
outputHeight=self.registryValue('image.outputHeight', channel),
backgroundColor=pyPie.getcolor(self.registryValue('color.backgroundColor', channel)),
channelColor=pyPie.getcolor(self.registryValue('color.channelColor', channel)),
labelColor=pyPie.getcolor(self.registryValue('color.labelColor', channel)),
titleColor=pyPie.getcolor(self.registryValue('color.titleColor', channel)),
nodeColor=pyPie.getcolor(self.registryValue('color.nodeColor', channel)),
edgeColor=pyPie.getcolor(self.registryValue('color.edgeColor', channel)),
borderColor=pyPie.getcolor(self.registryValue('color.borderColor', channel)),
ignoreSet=self.registryValue('ignore.ignoreSet', channel),
)
# put the config in the graph
graph.config = channelConfig
self.instances[irc.network].onJoin(channel, sender)
示例14: unload
def unload(self, irc, msg, args, name):
"""<plugin>
Unloads the callback by name; use the 'list' command to see a list
of the currently loaded plugins. Obviously, the Owner plugin can't
be unloaded.
"""
if ircutils.strEqual(name, self.name()):
irc.error('You can\'t unload the %s plugin.' % name)
return
# Let's do this so even if the plugin isn't currently loaded, it doesn't
# stay attempting to load.
old_callback = irc.getCallback(name)
if old_callback:
# Normalize the plugin case to prevent duplicate registration
# entries, https://github.com/ProgVal/Limnoria/issues/1295
name = old_callback.name()
conf.registerPlugin(name, False)
callbacks = irc.removeCallback(name)
if callbacks:
for callback in callbacks:
callback.die()
del callback
gc.collect()
irc.replySuccess()
return
irc.error('There was no plugin %s.' % name)
示例15: rank
def rank(self, irc, msg, args, channel, expr):
"""[<channel>] <stat expression>
Returns the ranking of users according to the given stat expression.
Valid variables in the stat expression include 'msgs', 'chars',
'words', 'smileys', 'frowns', 'actions', 'joins', 'parts', 'quits',
'kicks', 'kicked', 'topics', and 'modes'. Any simple mathematical
expression involving those variables is permitted.
"""
# XXX I could do this the right way, and abstract out a safe eval,
# or I could just copy/paste from the Math plugin.
if expr != expr.translate(utils.str.chars, '_[]'):
irc.error('There\'s really no reason why you should have '
'underscores or brackets in your mathematical '
'expression. Please remove them.', Raise=True)
if 'lambda' in expr:
irc.error('You can\'t use lambda in this command.', Raise=True)
expr = expr.lower()
users = []
for ((c, id), stats) in self.db.items():
if ircutils.strEqual(c, channel) and ircdb.users.hasUser(id):
e = self._env.copy()
for attr in stats._values:
e[attr] = float(getattr(stats, attr))
try:
v = eval(expr, e, e)
except ZeroDivisionError:
v = float('inf')
except NameError, e:
irc.errorInvalid('stat variable', str(e).split()[1])
except Exception, e:
irc.error(utils.exnToString(e), Raise=True)
users.append((v, ircdb.users.getUser(id).name))