1
0
mirror of http://aero2k.de/t/repos/urlbot-native.git synced 2017-09-06 15:25:38 +02:00

command_wp: add language selection

This commit is contained in:
urlbot
2015-02-05 01:04:52 +01:00
parent 403bcec68f
commit 9a5c0d585c

View File

@@ -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