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']
|
query = args['argv1']
|
||||||
# FIXME: escaping. probably.
|
# FIXME: escaping. probably.
|
||||||
api = 'https://de.wikipedia.org/w/api.php?action=query&prop=extracts&' + \
|
api = 'https://de.wikipedia.org/w/api.php?action=query&prop=extracts&' + \
|
||||||
'exsentences=2&rawcontinue=1&format=json&titles=' + query
|
'explaintext&exsentences=2&rawcontinue=1&format=json&titles=' + query
|
||||||
link = 'https://en.wikipedia.org/wiki/' + query
|
link = 'https://de.wikipedia.org/wiki/' + query
|
||||||
|
|
||||||
(j, short) = (None, None)
|
(j, short) = (None, None)
|
||||||
failed = False
|
failed = False
|
||||||
@@ -709,7 +709,6 @@ def command_wp(args):
|
|||||||
j = j['pages']
|
j = j['pages']
|
||||||
flag = True
|
flag = True
|
||||||
for stuff in j:
|
for stuff in j:
|
||||||
print((stuff, j[stuff]))
|
|
||||||
if 'extract' in j[stuff]:
|
if 'extract' in j[stuff]:
|
||||||
flag = False
|
flag = False
|
||||||
j = j[stuff]['extract']
|
j = j[stuff]['extract']
|
||||||
@@ -724,7 +723,9 @@ def command_wp(args):
|
|||||||
short = str(j)
|
short = str(j)
|
||||||
|
|
||||||
return {
|
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):
|
#def command_dummy(args):
|
||||||
|
|||||||
Reference in New Issue
Block a user