From 9a5c0d585c2ad4b71ab6c026af909c23bfe779e2 Mon Sep 17 00:00:00 2001 From: urlbot Date: Thu, 5 Feb 2015 01:04:52 +0100 Subject: [PATCH] command_wp: add language selection --- plugins.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins.py b/plugins.py index 71f8ce0..fa5ab91 100644 --- a/plugins.py +++ b/plugins.py @@ -667,8 +667,8 @@ def command_wp(args): if 'register' == args: return { 'name': 'wp', - 'desc': 'crawl the Wikipedia', - 'args': ('argv0', 'argv1', 'reply_user'), + 'desc': 'crawl the Wikipedia, language via argv2=en,de[default]', + 'args': ('argv0', 'argv1', 'argv2', 'reply_user'), 'is_enabled': True, 'ratelimit_class': RATE_GLOBAL } @@ -679,10 +679,13 @@ def command_wp(args): logger('plugin', 'wp plugin called') query = args['argv1'] + lang = 'de' if not 'en' == args['argv2'] else 'en' # FIXME: escaping. probably. - api = 'https://de.wikipedia.org/w/api.php?action=query&prop=extracts&' + \ - 'explaintext&exsentences=2&rawcontinue=1&format=json&titles=' + query - link = 'https://de.wikipedia.org/wiki/' + query + api = ('https://%s.wikipedia.org/w/api.php?action=query&prop=extracts&' + \ + 'explaintext&exsentences=2&rawcontinue=1&format=json&titles=%s') % ( + lang, query + ) + link = 'https://%s.wikipedia.org/wiki/%s' % (lang, query) (j, short) = (None, None) failed = False