本文整理汇总了Python中Utils.WebUtils.pasteEE方法的典型用法代码示例。如果您正苦于以下问题:Python WebUtils.pasteEE方法的具体用法?Python WebUtils.pasteEE怎么用?Python WebUtils.pasteEE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils.WebUtils
的用法示例。
在下文中一共展示了WebUtils.pasteEE方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from Utils import WebUtils [as 别名]
# 或者: from Utils.WebUtils import pasteEE [as 别名]
def execute(self, response):
"""
@type response: IRCResponse
"""
limit = 700 # chars
expire = 10 # minutes
if len(response.Response) > limit:
replaced = WebUtils.pasteEE(response.Response,
u'Response longer than {0} chars intended for {1}'.format(limit,
response.Target),
expire)
response.Response = u'Response too long, pasted here instead: {0} (Expires in {1} minutes)'.format(replaced,
expire)
return response
示例2: _export
# 需要导入模块: from Utils import WebUtils [as 别名]
# 或者: from Utils.WebUtils import pasteEE [as 别名]
def _export(self, message):
"""export [<alias name(s)] - exports all aliases - or the specified aliases - to paste.ee, \
and returns a link"""
if len(message.ParameterList) > 1:
# filter the alias dictionary by the listed aliases
params = [alias.lower() for alias in message.ParameterList[1:]]
aliases = {alias: self.aliases[alias]
for alias in self.aliases
if alias in params}
aliasHelp = {alias: self.aliasHelpDict[alias]
for alias in self.aliasHelpDict
if alias in params}
if len(aliases) == 0:
return IRCResponse(ResponseType.Say,
u"I don't have any of the aliases listed for export",
message.ReplyTo)
else:
aliases = self.aliases
aliasHelp = self.aliasHelpDict
if len(aliases) == 0:
return IRCResponse(ResponseType.Say,
u"There are no aliases for me to export!",
message.ReplyTo)
addCommands = [u"{}alias add {} {}".format(self.bot.commandChar,
name, u" ".join(command))
for name, command in aliases.iteritems()]
helpCommands = [u"{}alias help {} {}".format(self.bot.commandChar,
name, helpText)
for name, helpText in aliasHelp.iteritems()]
export = u"{}\n\n{}".format(u"\n".join(sorted(addCommands)),
u"\n".join(sorted(helpCommands)))
url = WebUtils.pasteEE(export,
u"Exported {} aliases for {}".format(self.bot.nickname, cmdArgs.server),
60)
return IRCResponse(ResponseType.Say,
u"Exported {} aliases and {} help texts to {}".format(len(addCommands),
len(helpCommands),
url),
message.ReplyTo)