This commit is contained in:
Andreas Stephanides
2017-01-14 14:47:14 +01:00
parent 96cc97a13f
commit c22d9325ec

View File

@@ -94,7 +94,13 @@ def handle(handler,msg):
if msg.has_key('data'): if msg.has_key('data'):
lg.debug(msg['data']) lg.debug(msg['data'])
def make_article_json(art):
res={"type":"article", "title":art.title, "id": str(art.id), "url": art.url, "message_text": art.title + " " + art.url}
if art.image != None:
lg.debug("http://crawler.fachschaften.at/"+str(art.image))
res["thumb_url"]="http://crawler.fachschaften.at/"+str(art.image)
return res
class InlineHandler(telepot.helper.InlineUserHandler, telepot.helper.AnswererMixin): class InlineHandler(telepot.helper.InlineUserHandler, telepot.helper.AnswererMixin):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(InlineHandler, self).__init__(*args, **kwargs) super(InlineHandler, self).__init__(*args, **kwargs)
@@ -103,9 +109,11 @@ class InlineHandler(telepot.helper.InlineUserHandler, telepot.helper.AnswererMix
def compute_answer(): def compute_answer():
query_id, from_id, query_string = telepot.glance(msg, flavor='inline_query') query_id, from_id, query_string = telepot.glance(msg, flavor='inline_query')
print(self.id, ':', 'Inline Query:', query_id, from_id, query_string) print(self.id, ':', 'Inline Query:', query_id, from_id, query_string)
articles1=articles_controller.search(query_string)
articles = [{'type': 'article', articles = [{'type': 'article',
'id': 'abc', 'title': query_string, 'message_text': query_string}] 'id': 'abc', 'title': query_string, 'message_text': query_string}]
articles=map(make_article_json,articles1)
return articles return articles