本文整理汇总了Python中supybot.ircutils.strEqual函数的典型用法代码示例。如果您正苦于以下问题:Python strEqual函数的具体用法?Python strEqual怎么用?Python strEqual使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strEqual函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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])
开发者ID:GLolol,项目名称:Limnoria,代码行数:32,代码来源:plugin.py
示例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))
开发者ID:MrTiggr,项目名称:supybot_fixes,代码行数:7,代码来源:plugin.py
示例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)
开发者ID:Steve-V,项目名称:bot1st-modules,代码行数:25,代码来源:plugin.py
示例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))
开发者ID:SamuelMoraesF,项目名称:AmadorBot,代码行数:31,代码来源:plugin.py
示例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)
开发者ID:MrTiggr,项目名称:supybot_fixes,代码行数:8,代码来源:plugin.py
示例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)
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:35,代码来源:plugin.py
示例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)
开发者ID:C0MPAQ,项目名称:Supybot-Backlog,代码行数:30,代码来源:plugin.py
示例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)
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:25,代码来源:plugin.py
示例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])
)
开发者ID:stepnem,项目名称:supybot-plugins,代码行数:7,代码来源:plugin.py
示例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.'))
开发者ID:frumiousbandersnatch,项目名称:Limnoria,代码行数:33,代码来源:plugin.py
示例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 ")
开发者ID:dfederlein,项目名称:supybot-plugins,代码行数:27,代码来源:plugin.py
示例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()
开发者ID:dfederlein,项目名称:supybot-plugins,代码行数:28,代码来源:plugin.py
示例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)
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:26,代码来源:plugin.py
示例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)
开发者ID:Hoaas,项目名称:Limnoria,代码行数:27,代码来源:plugin.py
示例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))
开发者ID:Affix,项目名称:Fedbot,代码行数:33,代码来源:plugin.py
示例16: doInvite
def doInvite(self, irc, msg):
if ircutils.strEqual(msg.nick, self.registryValue('ChanServ')):
channel = msg.args[1]
on = 'on %s' % irc.network
networkGroup = conf.supybot.networks.get(irc.network)
self.log.info('Joining %s, invited by ChanServ %s.', channel, on)
irc.queueMsg(networkGroup.channels.join(channel))
开发者ID:MrTiggr,项目名称:supybot_fixes,代码行数:7,代码来源:plugin.py
示例17: blame
def blame(self, irc, msg, args, channel, id, text):
"""[<channel>] [<id>] <who|what> [for <reason>]
Blames <who|what> (for <reason>, if given). If <id> is given, uses
that specific blame. <channel> is only necessary if the message isn't
sent in the channel itself.
"""
if " for " in text:
(target, reason) = map(str.strip, text.split(" for ", 1))
else:
(target, reason) = (text, "")
if ircutils.strEqual(target, irc.nick):
target = "itself"
if id is not None:
try:
blame = self.db.get(channel, id)
except KeyError:
irc.error(format("There is no blame with id #%i.", id))
return
else:
blame = self.db.random(channel)
if not blame:
irc.error(format("There are no blames in my database " "for %s.", channel))
return
text = self._replaceFirstPerson(blame.text, msg.nick)
reason = self._replaceFirstPerson(reason, msg.nick)
target = self._replaceFirstPerson(target, msg.nick)
text = text.replace("$who", target).replace("$WHO", target.upper())
if reason:
text += " for " + reason
if self.registryValue("showIds", channel):
text += format(" (#%i)", blame.id)
# changed action to False -- gsf 2007-07-25
irc.reply(text, action=False)
开发者ID:sdellis,项目名称:supybot-plugins,代码行数:35,代码来源:plugin.py
示例18: praise
def praise(self, irc, msg, args, channel, id, text):
"""[<channel>] [<id>] <who|what> [for <reason>]
Praises <who|what> (for <reason>, if given). If <id> is given, uses
that specific praise. <channel> is only necessary if the message isn't
sent in the channel itself.
"""
if ' for ' in text:
(target, reason) = map(str.strip, text.split(' for ', 1))
else:
(target, reason) = (text, '')
if ircutils.strEqual(target, irc.nick):
target = 'itself'
if id is not None:
try:
praise = self.db.get(channel, id)
except KeyError:
irc.error(format('There is no praise with id #%i.', id))
return
else:
praise = self.db.random(channel)
if not praise:
irc.error(format('There are no praises in my database ' \
'for %s.', channel))
return
text = self._replaceFirstPerson(praise.text, msg.nick)
reason = self._replaceFirstPerson(reason, msg.nick)
target = self._replaceFirstPerson(target, msg.nick)
text = text.replace('$who', target)
if reason:
text += ' for ' + reason
if self.registryValue('showIds', channel):
text += format(' (#%i)', praise.id)
# changed action to False -- gsf 2007-07-25
irc.reply(text, action=False, prefixNick=False)
开发者ID:D0MF,项目名称:supybot-plugins,代码行数:35,代码来源:plugin.py
示例19: quiet
def quiet(self, irc, msg, args, channel, nick, expiry):
"""[<channel>] <nick> [<expiry>]
Quietens <nick> from <channel> for <expiry>. If <expiry> isn't given,
the duration is permanent.
<channel> is only necessary if the message isn't sent in the channel
itself.
"""
if irc.isNick(nick):
bannedNick = nick
try:
bannedHostmask = irc.state.nickToHostmask(nick)
except KeyError:
irc.error(format(_('I haven\'t seen %s.'), bannedNick), Raise=True)
else:
bannedNick = ircutils.nickFromHostmask(nick)
bannedHostmask = nick
if not irc.isNick(bannedNick):
self.log.warning('%q tried to quiet a non nick: %q',
msg.prefix, bannedNick)
raise callbacks.ArgumentError
banmaskstyle = conf.supybot.protocols.irc.banmask
banmask = banmaskstyle.makeBanmask(bannedHostmask)
if ircutils.strEqual(nick, irc.nick):
irc.error('I cowardly refuse to quiet myself.', Raise=True)
thismsg=self.registryValue('message')
self._sendMsg(irc, ircmsgs.mode(channel, ("+q", banmask)))
if self.registryValue('SendMsgPvt'):
self._sendMsg(irc, ircmsgs.privmsg(nick,nick+", "+thismsg ))
else:
self._sendMsg(irc, ircmsgs.privmsg(channel,nick+", "+thismsg ))
def f():
irc.queueMsg(ircmsgs.mode(channel, ("-q", banmask)))
if expiry:
schedule.addEvent(f, expiry)
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:35,代码来源:plugin.py
示例20: tell
def tell(self, irc, msg, args, nicks, text):
"""<nick1[,nick2[,...]]> <text>
Tells each <nickX> <text> the next time <nickX> is seen. <nickX> can
contain wildcard characters, and the first matching nick will be
given the note.
"""
self._deleteExpired()
validnicks = []
for nick in nicks:
if ircutils.strEqual(nick, irc.nick):
irc.error(_('I can\'t send notes to myself.'))
return
validnick = self._validateNick(irc, nick)
if validnick is False:
irc.error(_('%s is an invalid IRC nick. Please check your '
'input.' % nick))
return
validnicks.append(validnick)
full_queues = []
for validnick in validnicks:
try:
self._addNote(validnick, msg.nick, text)
except ValueError:
full_queues.append(validnick)
if full_queues:
irc.error(format(
_('These recipients\' message queue are already full: %L'),
full_queues))
else:
irc.replySuccess()
开发者ID:carriercomm,项目名称:Limnoria,代码行数:31,代码来源:plugin.py
注:本文中的supybot.ircutils.strEqual函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论