本文整理汇总了Python中supybot.ircutils.standardSubstitute函数的典型用法代码示例。如果您正苦于以下问题:Python standardSubstitute函数的具体用法?Python standardSubstitute怎么用?Python standardSubstitute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了standardSubstitute函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: part
def part(self, irc, msg, args, channel, reason):
"""[<channel>] [<reason>]
Tells the bot to part the list of channels you give it. <channel> is
only necessary if you want the bot to part a channel other than the
current channel. If <reason> is specified, use it as the part
message. Otherwise, the default part message specified in
supybot.plugins.Channel.partMsg will be used. No part message will be
used if no default is configured.
"""
if channel is None:
if irc.isChannel(msg.args[0]):
channel = msg.args[0]
else:
irc.error(Raise=True)
capability = ircdb.makeChannelCapability(channel, 'op')
hostmask = irc.state.nickToHostmask(msg.nick)
if not ircdb.checkCapabilities(hostmask, [capability, 'admin']):
irc.errorNoCapability(capability, Raise=True)
try:
network = conf.supybot.networks.get(irc.network)
network.channels().remove(channel)
except KeyError:
pass
if channel not in irc.state.channels:
irc.error(_('I\'m not in %s.') % channel, Raise=True)
reason = (reason or self.registryValue("partMsg", channel))
reason = ircutils.standardSubstitute(irc, msg, reason)
irc.queueMsg(ircmsgs.part(channel, reason))
if msg.nick in irc.state.channels[channel].users:
irc.noReply()
else:
irc.replySuccess()
开发者ID:Ban3,项目名称:Limnoria,代码行数:33,代码来源:plugin.py
示例2: doJoin
def doJoin(self, irc, msg):
if ircutils.strEqual(irc.nick, msg.nick):
return # It's us.
if msg.nick in self.splitters:
self.log.debug('Not heralding %s, recent split.', msg.nick)
return # Recently split.
channel = msg.args[0]
irc = callbacks.SimpleProxy(irc, msg)
if self.registryValue('heralding', channel):
try:
id = ircdb.users.getUserId(msg.prefix)
heraldAll = self.db['#ALL', id]
except KeyError:
heraldAll = ""
try:
id = ircdb.users.getUserId(msg.prefix)
if id in self.splitters:
self.log.debug('Not heralding id #%s, recent split.', id)
return
herald = self.db[channel, id]
except KeyError:
if heraldAll == "":
default = self.registryValue('default', channel)
if default:
default = ircutils.standardSubstitute(irc, msg, default)
msgmaker = ircmsgs.privmsg
if self.registryValue('default.notice', channel):
msgmaker = ircmsgs.notice
target = msg.nick
if self.registryValue('default.public', channel):
target = channel
irc.queueMsg(msgmaker(target, default))
return
else:
herald = heraldAll
now = time.time()
throttle = self.registryValue('throttle', channel)
if now - self.lastHerald.get((channel, id), 0) > throttle:
if (channel, id) in self.lastParts:
i = self.registryValue('throttle.afterPart', channel)
if now - self.lastParts[channel, id] < i:
return
self.lastHerald[channel, id] = now
herald = ircutils.standardSubstitute(irc, msg, herald)
irc.reply(herald, prefixNick=False)
开发者ID:EnderBlue,项目名称:supybot,代码行数:47,代码来源:plugin.py
示例3: jira
def jira(self, irc, msg, args, text):
"""<text>
Returns the arguments given it. Uses our standard substitute on the
string(s) given to it; $nick (or $who), $randomNick, $randomInt,
$botnick, $channel, $user, $host, $today, $now, and $randomDate are all
handled appropriately.
"""
text = ircutils.standardSubstitute(irc, msg, text)
result = []
self.log.info('Looking up: ' + text)
self._auth()
cachekey = msg.args[0] + "_" + text # todo: show channel
if(cachekey in self.recent):
last = self.recent[cachekey]
now = datetime.now()
self.log.info('last seen ' + cachekey + ' at ' + str(last) + ' now is ' + str(now) + ' ' + str(now-last))
if ((now - last) < timedelta (seconds = self.registryValue('duplicate_graceperiod'))):
irc.noReply()
return
else:
self.log.info('new lookup')
self.recent[cachekey] = datetime.now()
try:
issue = self.s.jira1.getIssue(self.auth, text)
#for k,v in sorted(issue.items()):
# irc.reply(k, prefixNick=True)
#irc.reply(issue['description'], prefixNick=True)
result.append(getName(issue['type'], self.jiradata['types']) + ": ")
result.append("[" + issue['key'] + "]")
result.append(" " + issue['summary'])
result.append(" [")
result.append(getName(issue['status'], self.jiradata['statuses']) + ", ")
result.append(getName(issue['priority'], self.jiradata['priorities']) + ", ")
if('components' in issue):
components = []
for f in issue['components']:
components.append(encode(f['name']))
if(components):
result.append("(")
result.append(", ".join(str(x) for x in components))
result.append("), ")
if('assignee' in issue):
result.append(issue['assignee']) #should be username ?
else:
result.append("Unassigned")
result.append("] ")
result.append(self.registryValue('browseurl') + issue['key'])
irc.reply("".join(result), prefixNick=False)
except Fault, f:
self.log.exception("Error when looking up " + text)
irc.noReply()
开发者ID:maxandersen,项目名称:jbott,代码行数:59,代码来源:plugin.py
示例4: invalidCommand
def invalidCommand(self, irc, msg, tokens):
channel = msg.args[0]
if irc.isChannel(channel):
dunno = self.db.random(channel)
if dunno is not None:
dunno = dunno.text
prefixNick = self.registryValue('prefixNick', channel)
env = {'command': tokens[0]}
dunno = ircutils.standardSubstitute(irc, msg, dunno, env=env)
irc.reply(dunno, prefixNick=prefixNick)
开发者ID:Chalks,项目名称:Supybot,代码行数:10,代码来源:plugin.py
示例5: getTopic
def getTopic(irc, msg, args, state, format=True):
separator = state.cb.registryValue("separator", state.channel)
if separator in args[0]:
state.errorInvalid("topic", args[0], format(_("The topic must not include %q."), separator))
topic = args.pop(0)
if format:
env = {"topic": topic}
formatter = state.cb.registryValue("format", state.channel)
topic = ircutils.standardSubstitute(irc, msg, formatter, env)
state.args.append(topic)
开发者ID:Athemis,项目名称:Limnoria,代码行数:10,代码来源:plugin.py
示例6: echo
def echo(self, irc, msg, args, text):
"""<text>
Returns the arguments given it. Uses our standard substitute on the
string(s) given to it; $nick (or $who), $randomNick, $randomInt,
$botnick, $channel, $user, $host, $today, $now, and $randomDate are all
handled appropriately.
"""
text = ircutils.standardSubstitute(irc, msg, text)
irc.reply(text, prefixNick=False)
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:10,代码来源:plugin.py
示例7: getTopic
def getTopic(irc, msg, args, state, format=True):
separator = state.cb.registryValue('separator', state.channel)
if separator in args[0]:
state.errorInvalid('topic', args[0],
format('The topic must not include %q.', separator))
topic = args.pop(0)
if format:
env = {'topic': topic}
formatter = state.cb.registryValue('format', state.channel)
topic = ircutils.standardSubstitute(irc, msg, formatter, env)
state.args.append(topic)
开发者ID:Elwell,项目名称:supybot,代码行数:11,代码来源:plugin.py
示例8: doJoin
def doJoin(self, irc, msg):
if ircutils.strEqual(irc.nick, msg.nick):
return # It's us.
if msg.nick in self.splitters:
self.log.debug('Not greeting %s, recent split.', msg.nick)
return # Recently split.
channel = msg.args[0]
irc = callbacks.SimpleProxy(irc, msg)
if self.registryValue('greeting', channel):
try:
id = ircdb.users.getUserId(msg.prefix)
if id in self.splitters:
self.log.debug('Not greeting id #%s, recent split.', id)
return
greet = self.db[channel, id]
except KeyError:
default = self.registryValue('default', channel)
if default:
default = ircutils.standardSubstitute(irc, msg, default)
msgmaker = ircmsgs.privmsg
if self.registryValue('default.notice', channel):
msgmaker = ircmsgs.notice
target = msg.nick
if self.registryValue('default.public', channel):
target = channel
irc.queueMsg(msgmaker(target, default))
return
now = time.time()
throttle = self.registryValue('throttle', channel)
if now - self.lastGreet.get((channel, id), 0) > throttle:
if (channel, id) in self.lastParts:
i = self.registryValue('throttle.afterPart', channel)
if now - self.lastParts[channel, id] < i:
return
self.lastGreet[channel, id] = now
greet = ircutils.standardSubstitute(irc, msg, greet)
if re.search(r"/me ", greet, re.I):
greet = greet.replace("/me ","")
irc.reply(greet, prefixNick=False, action=True)
else:
irc.reply(greet, prefixNick=True)
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:41,代码来源:plugin.py
示例9: reply
def reply(self, s, irc=None, msg=None, action=False, substitute=True):
if irc is None:
assert self.irc is not None
irc = self.irc
if msg is None:
assert self.msg is not None
msg = self.msg
if msg.repliedTo:
self.log.debug('Already replied, not replying again.')
return
if substitute:
s = ircutils.standardSubstitute(irc, msg, s)
irc.reply(s, prefixNick=False, action=action, msg=msg)
开发者ID:D0MF,项目名称:supybot-plugins,代码行数:13,代码来源:plugin.py
示例10: _parseFactoid
def _parseFactoid(self, irc, msg, fact):
type = 'define' # Default is to just spit the factoid back as a
# definition of what the key is (i.e., "foo is bar")
newfact = pickOptions(fact)
if newfact.startswith(self._replyTag):
newfact = newfact[len(self._replyTag):]
type = 'reply'
elif newfact.startswith(self._actionTag):
newfact = newfact[len(self._actionTag):]
type = 'action'
newfact = newfact.strip()
newfact = ircutils.standardSubstitute(irc, msg, newfact)
return (type, newfact)
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:13,代码来源:plugin.py
示例11: send
def send(self, irc, msg, args, address, text):
"""<address> <text>
Sends an email to <address> with contents <text>.
"""
now = time.strftime(conf.supybot.reply.format.time(), time.localtime())
subjectFormat = self.registryValue('subject')
subject = ircutils.standardSubstitute(irc, msg, subjectFormat)
mail = popen2.Popen4(['mail', '-s', subject, address])
introFormat = self.registryValue('introduction')
intro = ircutils.standardSubstitute(irc, msg, introFormat)
mail.tochild.write(intro)
mail.tochild.write('\n\n')
mail.tochild.write(text)
mail.tochild.close()
status = mail.wait()
if not status:
irc.replySuccess(format('Email sent to %s.', address))
else:
errorLines = mail.fromchild.readlines()
errorMsg = utils.str.normalizeWhitespace(' '.join(errorLines))
irc.error(format('Mail returned %s: %s', status, errorMsg))
开发者ID:D0MF,项目名称:supybot-plugins-1,代码行数:22,代码来源:plugin.py
示例12: cycle
def cycle(self, irc, msg, args, channel, reason):
"""[<channel>]
If you have the #channel,op capability, this will cause the bot to
"cycle", or PART and then JOIN the channel. <channel> is only necessary
if the message isn't sent in the channel itself. If <reason> is not
specified, the default part message specified in
supybot.plugins.Channel.partMsg will be used. No part message will be
used if neither a cycle reason nor a default part message is given.
"""
reason = (reason or self.registryValue("partMsg", channel))
reason = ircutils.standardSubstitute(irc, msg, reason)
self._sendMsg(irc, ircmsgs.part(channel, reason))
networkGroup = conf.supybot.networks.get(irc.network)
self._sendMsg(irc, networkGroup.channels.join(channel))
开发者ID:Ban3,项目名称:Limnoria,代码行数:15,代码来源:plugin.py
示例13: ctcp
def ctcp(self, irc, msg, match):
"^\x01(.*?)\x01$"
payload = match.group(1)
if payload:
payload = payload.split()[0].upper()
if payload in ('PING', 'ACTION'):
return
try:
response = self.db[payload]
response = ircutils.standardSubstitute(irc, msg, response)
self._reply(irc, msg, payload, response)
self.log.info('CtcpNext: Received CTCP %s from %s', payload,
msg.prefix)
except KeyError:
self.log.info('CtcpNext: Received unhandled CTCP %s from %s',
payload, msg.prefix)
开发者ID:GLolol,项目名称:SupyPlugins,代码行数:16,代码来源:plugin.py
示例14: quit
def quit(self, irc, msg, args, text):
"""[<text>]
Exits the bot with the QUIT message <text>. If <text> is not given,
the default quit message (supybot.plugins.Owner.quitMsg) will be used.
If there is no default quitMsg set, your nick will be used. The standard
substitutions ($version, $nick, etc.) are all handled appropriately.
"""
text = text or self.registryValue('quitMsg') or msg.nick
text = ircutils.standardSubstitute(irc, msg, text)
irc.noReply()
m = ircmsgs.quit(text)
world.upkeep()
for irc in world.ircs[:]:
irc.queueMsg(m)
irc.die()
开发者ID:Hoaas,项目名称:Limnoria,代码行数:16,代码来源:plugin.py
示例15: disconnect
def disconnect(self, irc, msg, args, otherIrc, quitMsg):
"""[<network>] [<quit message>]
Disconnects from the network represented by the network <network>.
If <quit message> is given, quits the network with the given quit
message. <network> is only necessary if the network is different
from the network the command is sent on.
"""
standard_msg = conf.supybot.plugins.Owner.quitMsg()
if standard_msg:
standard_msg = ircutils.standardSubstitute(irc, msg, standard_msg)
quitMsg = quitMsg or standard_msg or msg.nick
otherIrc.queueMsg(ircmsgs.quit(quitMsg))
otherIrc.die()
conf.supybot.networks().discard(otherIrc.network)
if otherIrc != irc:
irc.replySuccess(_("Disconnection to %s initiated.") % otherIrc.network)
开发者ID:carriercomm,项目名称:Limnoria,代码行数:17,代码来源:plugin.py
示例16: reconnect
def reconnect(self, irc, msg, args, otherIrc, quitMsg):
"""[<network>] [<quit message>]
Disconnects and then reconnects to <network>. If no network is given,
disconnects and then reconnects to the network the command was given
on. If no quit message is given, uses the configured one
(supybot.plugins.Owner.quitMsg) or the nick of the person giving the
command.
"""
standard_msg = conf.supybot.plugins.Owner.quitMsg()
if standard_msg:
standard_msg = ircutils.standardSubstitute(irc, msg, standard_msg)
quitMsg = quitMsg or standard_msg or msg.nick
otherIrc.queueMsg(ircmsgs.quit(quitMsg))
if otherIrc != irc:
# No need to reply if we're reconnecting ourselves.
irc.replySuccess()
开发者ID:carriercomm,项目名称:Limnoria,代码行数:17,代码来源:plugin.py
示例17: announce
def announce(self, irc, msg, args, text):
"""<text>
Sends <text> to all channels the bot is currently on and not
lobotomized in.
"""
u = ircdb.users.getUser(msg.prefix)
template = self.registryValue('announceFormat')
text = ircutils.standardSubstitute(
irc, msg, template, env={'owner': u.name, 'text': text})
for channel in irc.state.channels:
c = ircdb.channels.getChannel(channel)
if not c.lobotomized:
irc.queueMsg(ircmsgs.privmsg(channel, text))
irc.noReply()
开发者ID:Hoaas,项目名称:Limnoria,代码行数:19,代码来源:plugin.py
示例18: prefixer
def prefixer(v):
env['value'] = v
formatter = self.registryValue('format', msg.args[0])
return ircutils.standardSubstitute(irc, msg,
formatter, env)
开发者ID:gerdesas,项目名称:Limnoria,代码行数:5,代码来源:plugin.py
示例19: format_fact
def format_fact(text):
if raw:
return text
else:
return ircutils.standardSubstitute(irc, msg, text)
开发者ID:gerdesas,项目名称:Limnoria,代码行数:5,代码来源:plugin.py
注:本文中的supybot.ircutils.standardSubstitute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论