Skip to content

Commit

Permalink
Comentário Inicial
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorgamer58 committed Aug 4, 2020
1 parent 0a165e8 commit a64fe47
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 0 deletions.
Binary file added requirements.txt
Binary file not shown.
Empty file added src/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions src/conf/.env
@@ -0,0 +1,2 @@
TELEGRAM_TOKEN=
BASE_API_URL=https://http.cat/
Empty file added src/conf/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions src/conf/settings.py
@@ -0,0 +1,8 @@
import os

from dotenv import load_dotenv

load_dotenv()

TELEGRAM_TOKEN = os.getenv("TELEGRAM_TOKEN")
BASE_API_URL = os.getenv("BASE_API_URL")
52 changes: 52 additions & 0 deletions src/core.py
@@ -0,0 +1,52 @@

from telegram.ext import CommandHandler, Filters, MessageHandler, Updater

from conf.settings import BASE_API_URL, TELEGRAM_TOKEN


def start(bot, update):
response_message = "=^._.^="
bot.send_message(
chat_id=update.message.chat_id,
text=response_message
)


def http_cats(bot, update, args):
bot.sendPhoto(
chat_id=update.message.chat_id,
photo=BASE_API_URL + args[0]
)


def unknown(bot, update):
response_message = "Meow? =^._.^="
bot.send_message(
chat_id=update.message.chat_id,
text=response_message
)


def main():
updater = Updater(token=TELEGRAM_TOKEN)

dispatcher = updater.dispatcher

dispatcher.add_handler(
CommandHandler('start', start)
)
dispatcher.add_handler(
CommandHandler('http', http_cats, pass_args=True)
)
dispatcher.add_handler(
MessageHandler(Filters.command, unknown)
)

updater.start_polling()

updater.idle()


if __name__ == '__main__':
print("press CTRL + C to cancel.")
main()

0 comments on commit a64fe47

Please sign in to comment.