diff --git a/README.md b/README.md index ab0a8be..98576bb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,19 @@ -# Notion Assistant Telegram Bot +

Notion Assistant Telegram Bot

Telegram assistant bot for Notion. + +

Bot Features

+ + +

Building on your locale mashine

+
    +
  1. Clone repository
  2. +
  3. Install all requirements from requirements.txt
  4. +
  5. Rename .env.example to .env
  6. +
  7. Add Telegram Bot Token
  8. +
  9. Run __init__.py
  10. +
+ +
Made by Yishachock.io
\ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 46d49ed..ae63cd3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +python-dotenv~=0.21.1 certifi==2022.12.7 charset-normalizer==3.0.1 idna==3.4 diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..8caee45 --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,3 @@ +from bot import startTelegramBot + +startTelegramBot() diff --git a/src/bot/__init__.py b/src/bot/__init__.py index e69de29..74804d3 100644 --- a/src/bot/__init__.py +++ b/src/bot/__init__.py @@ -0,0 +1,6 @@ +from bot.controller import Controller +from dotenv import load_dotenv + +def startTelegramBot(): + load_dotenv("res/config/.env") + controller = Controller() diff --git a/src/bot/controller.py b/src/bot/controller.py index e69de29..bdd7a52 100644 --- a/src/bot/controller.py +++ b/src/bot/controller.py @@ -0,0 +1,28 @@ +import os + +import i18n +import telebot + + +class Controller: + + def __init__(self): + # setting up translation + i18n.set('file_format', 'json') + i18n.set('locale', 'en') + i18n.load_path.append("res/translations") + + TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN") + bot = telebot.TeleBot(TOKEN) + + @bot.message_handler(commands=['start', 'help']) + def command_help(message): + bot.reply_to(message, i18n.t("tr.start_help")) + + @bot.message_handler(func=lambda message: True, + content_types=['audio', 'video', 'document', 'text', 'location', 'contact', 'sticker']) + def default_command(message): + bot.reply_to(message, "tr.test") + + print("Bot has started!") + bot.infinity_polling() \ No newline at end of file diff --git a/src/res/config/.env.example b/src/res/config/.env.example new file mode 100644 index 0000000..70382e2 --- /dev/null +++ b/src/res/config/.env.example @@ -0,0 +1,2 @@ +# Get it from FatherBot in Telegram +TELEGRAM_BOT_TOKEN= \ No newline at end of file diff --git a/src/res/translations/tr.en.json b/src/res/translations/tr.en.json new file mode 100644 index 0000000..688af38 --- /dev/null +++ b/src/res/translations/tr.en.json @@ -0,0 +1,5 @@ +{ + "en": { + "start_help": "Hello!\nYou can repost your materials to our bot to auto-save them in Notion." + } +} \ No newline at end of file diff --git a/src/res/translations/tr.uk.json b/src/res/translations/tr.uk.json new file mode 100644 index 0000000..6235cd8 --- /dev/null +++ b/src/res/translations/tr.uk.json @@ -0,0 +1,6 @@ +{ + "uk": { + "start_help": "Вітаю!\nВи можете пересилати сюди свої матеріали, щоби зберегти їх в Notion!", + "test": "Ця команда наразі тестується!" + } +} \ No newline at end of file diff --git a/src/settings.py b/src/settings.py new file mode 100644 index 0000000..fda440f --- /dev/null +++ b/src/settings.py @@ -0,0 +1,9 @@ +# import os + + +import i18n +from dotenv import load_dotenv, find_dotenv + + +def setup(): + load_dotenv("res/config/.env") \ No newline at end of file diff --git a/src/setup.py b/src/setup.py new file mode 100644 index 0000000..94a2d05 --- /dev/null +++ b/src/setup.py @@ -0,0 +1,13 @@ +from distutils.core import setup +# IDK why i've created this +setup( + name='notion-assistant-telegram-bot', + version='', + packages=['bot', 'notion'], + package_dir={'': 'src'}, + url='', + license='', + author='Yishachok.io', + author_email='', + description='' +)