Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def wikipedia_search(query):
- query = query.replace('!', '')
- query = web.quote(query)
- uri = 'https://en.wikipedia.org/w/api.php?action=query&list=search&continue=&srsearch=%s&format=json' % query
- base_url = "https://en.wikipedia.org/wiki/"+query
- bytes = web.get(uri)
- m = r_wikipedia.search(bytes)
- if m: return web.decode(m.group(1))
- def wikipedia(phenny, input):
- query = input.group(2)
- if not query: return phenny.reply('.w what?')
- uri = wikipedia_search(query)
- if uri:
- phenny.reply(uri)
- if not hasattr(phenny.bot, 'last_seen_uri'):
- phenny.bot.last_seen_uri = {}
- phenny.bot.last_seen_uri[input.sender] = uri
- else: phenny.reply("No results found for '%s'." % query)
- wikipedia.commands = ['wikipedia', 'w']
Advertisement
Add Comment
Please, Sign In to add comment