command_wp: add language selection
This commit is contained in:
13
plugins.py
13
plugins.py
@@ -667,8 +667,8 @@ def command_wp(args):
|
|||||||
if 'register' == args:
|
if 'register' == args:
|
||||||
return {
|
return {
|
||||||
'name': 'wp',
|
'name': 'wp',
|
||||||
'desc': 'crawl the Wikipedia',
|
'desc': 'crawl the Wikipedia, language via argv2=en,de[default]',
|
||||||
'args': ('argv0', 'argv1', 'reply_user'),
|
'args': ('argv0', 'argv1', 'argv2', 'reply_user'),
|
||||||
'is_enabled': True,
|
'is_enabled': True,
|
||||||
'ratelimit_class': RATE_GLOBAL
|
'ratelimit_class': RATE_GLOBAL
|
||||||
}
|
}
|
||||||
@@ -679,10 +679,13 @@ def command_wp(args):
|
|||||||
logger('plugin', 'wp plugin called')
|
logger('plugin', 'wp plugin called')
|
||||||
|
|
||||||
query = args['argv1']
|
query = args['argv1']
|
||||||
|
lang = 'de' if not 'en' == args['argv2'] else 'en'
|
||||||
# FIXME: escaping. probably.
|
# FIXME: escaping. probably.
|
||||||
api = 'https://de.wikipedia.org/w/api.php?action=query&prop=extracts&' + \
|
api = ('https://%s.wikipedia.org/w/api.php?action=query&prop=extracts&' + \
|
||||||
'explaintext&exsentences=2&rawcontinue=1&format=json&titles=' + query
|
'explaintext&exsentences=2&rawcontinue=1&format=json&titles=%s') % (
|
||||||
link = 'https://de.wikipedia.org/wiki/' + query
|
lang, query
|
||||||
|
)
|
||||||
|
link = 'https://%s.wikipedia.org/wiki/%s' % (lang, query)
|
||||||
|
|
||||||
(j, short) = (None, None)
|
(j, short) = (None, None)
|
||||||
failed = False
|
failed = False
|
||||||
|
|||||||
Reference in New Issue
Block a user