diff --git a/bot/bot.py b/bot/bot.py index 3f78b2b..33d505a 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -94,7 +94,13 @@ def handle(handler,msg): if msg.has_key('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): def __init__(self, *args, **kwargs): super(InlineHandler, self).__init__(*args, **kwargs) @@ -103,9 +109,11 @@ class InlineHandler(telepot.helper.InlineUserHandler, telepot.helper.AnswererMix def compute_answer(): query_id, from_id, query_string = telepot.glance(msg, flavor='inline_query') print(self.id, ':', 'Inline Query:', query_id, from_id, query_string) + articles1=articles_controller.search(query_string) articles = [{'type': 'article', 'id': 'abc', 'title': query_string, 'message_text': query_string}] + articles=map(make_article_json,articles1) return articles