mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
command_wp: cleanup; fix empty string, de.|en., &explaintext
This commit is contained in:
@@ -681,8 +681,8 @@ def command_wp(args):
|
||||
query = args['argv1']
|
||||
# FIXME: escaping. probably.
|
||||
api = 'https://de.wikipedia.org/w/api.php?action=query&prop=extracts&' + \
|
||||
'exsentences=2&rawcontinue=1&format=json&titles=' + query
|
||||
link = 'https://en.wikipedia.org/wiki/' + query
|
||||
'explaintext&exsentences=2&rawcontinue=1&format=json&titles=' + query
|
||||
link = 'https://de.wikipedia.org/wiki/' + query
|
||||
|
||||
(j, short) = (None, None)
|
||||
failed = False
|
||||
@@ -709,7 +709,6 @@ def command_wp(args):
|
||||
j = j['pages']
|
||||
flag = True
|
||||
for stuff in j:
|
||||
print((stuff, j[stuff]))
|
||||
if 'extract' in j[stuff]:
|
||||
flag = False
|
||||
j = j[stuff]['extract']
|
||||
@@ -724,7 +723,9 @@ def command_wp(args):
|
||||
short = str(j)
|
||||
|
||||
return {
|
||||
'msg': args['reply_user'] + ': %s (<%s>)' % (short, link)
|
||||
'msg': args['reply_user'] + ': %s (<%s>)' % (
|
||||
'(nix)' if 0 == len(short.strip()) else short, link
|
||||
)
|
||||
}
|
||||
|
||||
#def command_dummy(args):
|
||||
|
||||
Reference in New Issue
Block a user