本文整理汇总了Python中util.answer函数的典型用法代码示例。如果您正苦于以下问题:Python answer函数的具体用法?Python answer怎么用?Python answer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了answer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: lsog
def lsog(bot, args):
excludes = [ k.strip() for k in bot.config.get("module: open_graph", "excludes").split(",") ]
og = "off" if re.match("(no|false|off|0)", bot.config.get("module: open_graph", "enabled")) else "on"
yt = "off" if re.match("(no|false|off|0)", bot.config.get("module: open_graph", "youtube")) else "on"
fmt = "Open Graph scanning: %s, YouTube scanning: %s\nHandlers: %s\nDisabled for: %s" % (og, yt, ", ".join(library['url']), ", ".join(excludes))
util.answer(bot, fmt)
开发者ID:txanatan,项目名称:xbot,代码行数:7,代码来源:open_graph.py
示例2: mishimmie
def mishimmie(bot, args):
if len(args) >= 2:
url = "";
if re.match("id:", args[1]):
terms = re.sub('id:', '', args[1])
url = "http://shimmie.katawa-shoujo.com/post/view/%s" % urllib2.quote(terms)
else:
terms = ' '.join(args[1:])
url = "http://shimmie.katawa-shoujo.com/post/list/%s/1" % urllib2.quote(terms)
rawres = urllib2.urlopen(url, timeout = 5)
result = rawres.read().encode('utf8')
doc = html.document_fromstring(result)
try:
posturl = ""
postdesc = ""
bot._debug('URL: %s' % rawres.geturl())
if re.search('/post/view/', rawres.geturl()):
bot._debug('On a post page.')
posturl = rawres.geturl()
postdesc = doc.get_element_by_id('imgdata').xpath('form')[0].xpath('table')[0].xpath('tr')[0].xpath('td')[1].xpath('input')[0].get('value')
else:
bot._debug('On a search result page.')
posturl = "http://shimmie.katawa-shoujo.com%s" % doc.find_class('thumb')[0].xpath('a')[0].get('href')
postdesc = doc.find_class('thumb')[0].xpath('a')[0].xpath('img')[0].get('alt').partition(' // ')[0]
posturl = re.sub('\?.*', '', posturl)
util.answer(bot, "\x02Mishimmie:\x02 %s // %s" % (postdesc, posturl))
except IndexError:
util.answer(bot, "\x02Mishimmie:\x02 No results.")
else:
util.give_help(bot, args[0], "<query> -- search the Mishimmie for <query>")
开发者ID:Qwertylex,项目名称:xbot,代码行数:30,代码来源:mishimmie.py
示例3: lookup
def lookup(bot, args):
if len(args) in [2, 3]:
addresses = None
if len(args) == 2:
host = args[1]
addresses = lookitup(host, "A")
elif len(args) == 3:
host = args[2]
if args[1] == "-6":
addresses = lookitup(host, "AAAA")
elif args[1] == "-r":
addresses = lookitup(host, "PTR")
else:
util.give_help(bot, args[0], "[-6 (IPv6), -r (rDNS)] <server>")
return None
if addresses != -1:
if addresses:
plural = "others" if len(addresses) > 2 else "other"
others = " (%s %s)" % (len(addresses), plural) if len(addresses) > 1 else ''
util.answer(bot, "Address: %s%s" % (addresses[0] if not str(addresses[0]).endswith(".") else str(addresses[0])[:-1], others))
else:
util.answer(bot, "%s: NXDOMAIN" % host)
else:
answer("Invalid host for this type of lookup.")
else:
util.give_help(bot, args[0], "[-6 (IPv6), -r (rDNS)] <server>")
开发者ID:Qwertylex,项目名称:xbot,代码行数:28,代码来源:dnstools.py
示例4: og_miscan
def og_miscan(bot, url):
res = miscan(bot, url)
if res:
util.answer(bot, "\x02Mishimmie:\x02 %s" % res['desc'])
else:
util.answer(bot, "\x02Mishimmie:\x02 No results.")
开发者ID:txanatan,项目名称:xbot,代码行数:7,代码来源:mishimmie.py
示例5: admin
def admin(bot, args):
diff = lambda l1,l2: filter(lambda x: x not in l2, l1)
if len(args) > 1:
admins = [nick.strip() for nick in bot.config.get(bot.network, 'admin').split(',')]
if args[1] == "list":
util.answer(bot, "Admin%s: %s" % ('' if len(admins) == 1 else 's', ', '.join(admins)))
return None
if args[1] == "add":
if len(args) > 2:
bot._debug("Adding %d admins: %s." % (len(args[2:]), ', '.join(args[2:])))
admins += args[2:]
bot.config.set(bot.network, 'admin', ', '.join(admins))
return None
if args[1] == "remove":
if len(args) > 2:
if bot.admin in args[2:]:
util.answer(bot, "Can't remove root, noob.")
bot._debug("Removing %d admins: %s." % (len(args[2:]), ', '.join(args[2:])))
admins = diff(admins, args[2:])
bot.config.set(bot.network, 'admin', ', '.join(admins))
return None
util.give_help(bot, args[0], "list|add|remove [nick]")
开发者ID:txanatan,项目名称:xbot,代码行数:25,代码来源:_io.py
示例6: write
def write(bot, args):
responses = [
"Only if you do!",
"After you get 100 more words~~~",
"Talk less, write more!"
]
util.answer(bot, __import__('random').choice(responses))
开发者ID:Qwertylex,项目名称:xbot,代码行数:7,代码来源:nanowrimo.py
示例7: clever_scan
def clever_scan(bot):
# someone is talking to the bot
if re.search('^%s(?:\:|,)' % re.escape(bot.nick.lower()), bot.remote['message'].lower()):
if 'cleverbot' not in bot.inv: bot.inv['cleverbot'] = {}
if bot.remote['receiver'] not in bot.inv['cleverbot']:
bot.inv['cleverbot'][bot.remote['receiver']] = CleverBot()
query = bot.remote['message'][len(bot.nick)+2:].decode('ascii', 'ignore')
util.answer(bot, "%s: %s" % (bot.remote['nick'], re.compile('cleverbot', re.IGNORECASE).sub(bot.nick, bot.inv['cleverbot'][bot.remote['receiver']].query(bot, query))))
开发者ID:Qwertylex,项目名称:xbot,代码行数:8,代码来源:cleverbot.py
示例8: join
def join(bot, args):
if len(args) == 2:
if args[1] not in Bot.inv['rooms']:
write(("JOIN", args[1]))
else:
util.answer(bot, "I'm already in that channel, noob.")
else:
util.give_help(bot, args[0], "<channel>")
开发者ID:txanatan,项目名称:xbot,代码行数:8,代码来源:_io.py
示例9: lick
def lick(bot, args):
botresponses = ["L-lewd!", "\x01ACTION blushes\x01", "\x01ACTION licks %s\x01" % bot.remote["nick"]]
if len(args) != 1:
tonick = " ".join(args[1:])
responses = ["%s licks %s" % (bot.remote["nick"], tonick), "%s doesn't lick %s" % (bot.remote["nick"], tonick)]
util.answer(bot, __import__("random").choice(responses))
else:
util.answer(bot, __import__("random").choice(botresponses))
开发者ID:txanatan,项目名称:xbot,代码行数:9,代码来源:imouto.py
示例10: fill
def fill(bot, args):
botresponses = ["B-but jetto will never fill me!", "L-lewd!"]
if len(args) != 1:
tonick = " ".join(args[1:])
responses = ["lolis~", "candy~", "a daki pillow"]
util.answer(bot, "%s fills %s with %s" % (bot.remote["nick"], tonick, __import__("random").choice(responses)))
else:
util.answer(bot, __import__("random").choice(botresponses))
开发者ID:txanatan,项目名称:xbot,代码行数:9,代码来源:imouto.py
示例11: twss
def twss(bot, args):
if len(args) > 1:
quote = ' '.join(args[1:])
if quote.startswith('"') and quote.endswith('"'):
util.answer(bot, "%s <- that's what she said." % quote)
else:
util.give_help(bot, args[0], "<quote>")
else:
util.answer(bot, "That's what she said.")
开发者ID:Qwertylex,项目名称:xbot,代码行数:9,代码来源:fun.py
示例12: og_scan
def og_scan(bot):
# scan for urls, check to see if OpenGraph validity and return site name and page title.
# if OpenGraph not found, tries <title> tag.
for url in re.findall('(?P<url>(https?://|www.)[^\s]+)', bot.remote['message']):
bot._debug("Found a URL: %s" % url[0])
try:
util.answer(bot, open_graph(bot, url[0]).encode('utf8'))
except AttributeError:
pass
开发者ID:knoppies,项目名称:xbot,代码行数:9,代码来源:open_graph.py
示例13: set_prefix
def set_prefix(bot, args):
if len(args) > 1:
if not re.match("^[[email protected]#\\$%^&*()\[\]{}\\\\|:;\"'<>.,?~`\\-_=+]$", args[1]):
return "Invalid prefix."
old = bot.prefix
bot.prefix = args[1]
util.answer(bot, "Prefix set to %s (was %s)." % (args[1], old))
else:
util.give_help(bot, args[0], "<one of: [email protected]#$%^&*()[]{}\\|:;\"'<>.,?~`-_=+>")
开发者ID:txanatan,项目名称:xbot,代码行数:9,代码来源:_io.py
示例14: reset
def reset(bot, args):
if len(args) > 1:
if args[1] in library['reset']:
pub.sendMessage("func.reset.%s" % library['reset'][args[1]], bot=bot, args=args[2:])
return None
if len(library['reset']) > 0:
util.give_help(bot, args[0], '|'.join(library['reset']))
else:
util.answer(bot, "No resets registered.")
开发者ID:txanatan,项目名称:xbot,代码行数:10,代码来源:_io.py
示例15: wiki
def wiki(bot, args):
if len(args) > 1:
result = lookitup('%s.wp.dg.cx' % '_'.join(args[1:]), 'TXT')
if result:
bot._sendq(("NOTICE", bot.remote['nick']), ''.join(str(result[0]).split('"')))
return None
else:
util.answer(bot, "No such article found.")
else:
util.give_help(bot, args[0], "<article>")
开发者ID:Qwertylex,项目名称:xbot,代码行数:10,代码来源:dnstools.py
示例16: m8b
def m8b(bot, args):
if len(args) > 1:
responses = [
"It is certain.", "It is decidedly so.", "Without a doubt.", "Yes - definitely.", "You may rely on it.", "As I see it, yes.", "Most likely.", "Outlook good.", "Signs point to yes.", "Yes.",
"Reply hazy, try again.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.",
"Don't count on it.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Very doubtful."
]
util.answer(bot, __import__('random').choice(responses))
else:
util.give_help(bot, args[0], "<herp>")
开发者ID:Qwertylex,项目名称:xbot,代码行数:10,代码来源:fun.py
示例17: tpb
def tpb(bot, args):
if len(args) >= 2:
terms = " ".join(args[2:])
res = tpb_search(terms)
if res:
util.answer(bot, "%s %s" % (tpb_getinfo(res), res))
else:
util.answer(bot, "\x02TPB:\x0f No results.")
else:
util.give_help(bot, args[0], "<query")
开发者ID:txanatan,项目名称:xbot,代码行数:10,代码来源:thepiratebay.py
示例18: kick
def kick(bot, args):
if len(args) >= 2:
if args[1].lower() == Bot.nick.lower():
reply(Bot.remote['sendee'], ":(")
else:
if Bot.inv['rooms'][Bot.remote['receiver']][Bot.nick]['mode'] == "o":
write(("KICK", Bot.remote['sendee'], args[1]), ' '.join(args[2:]))
else:
util.answer(bot, "No ops lol.")
else:
util.give_help(bot, args[0], "<nick>")
开发者ID:txanatan,项目名称:xbot,代码行数:11,代码来源:_io.py
示例19: get_results
def get_results(bot, args):
tree = lxml.etree.parse('http://www.lottoresults.co.nz/', lxml.etree.HTMLParser())
images = tree.xpath("//td/img[contains(@src, 'img/lotto/')]")
draw = tree.xpath("//input[@name='draw']")[0].get('value')
results = [re.match('img/lotto/([0-9]+)\.gif', result.get('src')).group(1) for result in images]
lotto = results[0:6]
bonus_ball = results[6]
strike = results[7:11]
powerball = results[11]
util.answer(bot, "Weekly draw #%d as follows\nLotto: %s, bonus %d, powerball %d. Strike order: %s." % (int(draw), ', '.join(lotto), int(bonus_ball), int(powerball), ', '.join(strike)))
开发者ID:Qwertylex,项目名称:xbot,代码行数:12,代码来源:lotto.py
示例20: poke
def poke(bot, args):
botresponses = ["B-baka!", "L-lewd!", "\x01ACTION pokes %s\x01" % bot.remote["nick"]]
if len(args) != 1:
tonick = " ".join(args[1:])
responses = [
"%s pokes %s" % (bot.remote["nick"], args[1]),
"%s doesn't poke %s" % (bot.remote["nick"], args[1]),
]
util.answer(bot, __import__("random").choice(responses))
else:
util.answer(bot, __import__("random").choice(botresponses))
开发者ID:txanatan,项目名称:xbot,代码行数:12,代码来源:imouto.py
注:本文中的util.answer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论