Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init #3

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
# Notion Assistant Telegram Bot
<h1>Notion Assistant Telegram Bot</h1>
Telegram assistant bot for Notion.

<h1>Bot Features</h1>
<ul>
<li>Automatically saves your reposted to our bot materials in Notion</li>
<li>Currently languages: Ukrainian and English</li>
</ul>

<h2>Building on your locale mashine</h2>
<ol>
<li>Clone repository</li>
<li>Install all requirements from <code>requirements.txt</code></li>
<li>Rename <code>.env.example</code> to <code>.env</code></li>
<li>Add Telegram Bot Token</li>
<li>Run <code>__init__.py</code></li>
</ol>

<div>Made by Yishachock.io</div>
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
python-dotenv~=0.21.1
certifi==2022.12.7
charset-normalizer==3.0.1
idna==3.4
Expand Down
3 changes: 3 additions & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from bot import startTelegramBot

startTelegramBot()
6 changes: 6 additions & 0 deletions src/bot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from bot.controller import Controller
from dotenv import load_dotenv

def startTelegramBot():
load_dotenv("res/config/.env")
controller = Controller()
28 changes: 28 additions & 0 deletions src/bot/controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os

import i18n
import telebot


class Controller:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зроби статичні методи, і можна не створювати об'єкт

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а це точно ООП?


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()
2 changes: 2 additions & 0 deletions src/res/config/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Get it from FatherBot in Telegram
Prosta4okua marked this conversation as resolved.
Show resolved Hide resolved
TELEGRAM_BOT_TOKEN=
5 changes: 5 additions & 0 deletions src/res/translations/tr.en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"en": {
"start_help": "Hello!\nYou can repost your materials to our bot to auto-save them in Notion."
}
}
6 changes: 6 additions & 0 deletions src/res/translations/tr.uk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"uk": {
"start_help": "Вітаю!\nВи можете пересилати сюди свої матеріали, щоби зберегти їх в Notion!",
"test": "Ця команда наразі тестується!"
}
}
9 changes: 9 additions & 0 deletions src/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# import os


import i18n
from dotenv import load_dotenv, find_dotenv


def setup():
load_dotenv("res/config/.env")
13 changes: 13 additions & 0 deletions src/setup.py
Original file line number Diff line number Diff line change
@@ -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=''
)