Skip to content

Commit

Permalink
Merge pull request #1 from monkrobot/inline-bot
Browse files Browse the repository at this point in the history
Inline bot
  • Loading branch information
nonamenix authored Dec 3, 2020
2 parents 28b4d91 + f7ac960 commit 99d2aea
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bot/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@
"Unless it is started by a link to Habrahabr.",
],
],
[[], ["Politeness counts."]], # from this import politeness
[["politeness"], ["Politeness counts."]], # from this import politeness
[
[], # from this import bad_mood
["mood"], # from this import bad_mood
["Bad mood is not a good reason to break the rules."],
],
[["ask"], ["Don't ask to ask just ask."]], # from this import ask
[
[], # from this import voice
["voice"], # from this import voice
[
"Text message is better than voice message.",
"Unless it is voice conference.",
],
],
[[], ["Git repos are one honking great idea — let's do more of those!"]],
[["git"], ["Git repos are one honking great idea — let's do more of those!"]],
]

help_test = """
Expand Down
29 changes: 29 additions & 0 deletions bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
from datetime import timedelta, datetime
from urllib.parse import quote
from uuid import uuid4

from aiotg import Chat, aiohttp

Expand Down Expand Up @@ -209,6 +210,34 @@ async def chats(chat: Chat, matched):
)


functions = ['/version', 'import __hello__',
'import this', 'zen', '/about',
'from this import hi', 'from this import gist',
'from this import long_better', 'from this import correct',
'from this import offtopic', 'from this import politeness',
'from this import ask', 'from this import mood',
'from this import voice', 'from this import git']


@bot.inline
async def inline_query(query):
"""Find autocomplite for inline query"""

results = []

for func in functions:
if query.query in func:
results.append({
"type": "article",
"title": func,
"id": "{}".format(uuid4()),
"input_message_content": {"message_text": func},
}
)
return query.answer(results)


if __name__ == "__main__":
logger.info("Running...")
bot.run(debug=DEBUG)

0 comments on commit 99d2aea

Please sign in to comment.