Skip to content
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
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM python:3.12.0a4-bullseye
WORKDIR /app
COPY . .
#CMD ["sh", "./python_setup.sh"]
RUN pip install -r requirements.txt
CMD ["python","./bot.py"]
7 changes: 7 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler, MessageHandler, filters

public_bot=True;

logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO
Expand Down Expand Up @@ -44,6 +46,11 @@ async def donate(update, context: ContextTypes.DEFAULT_TYPE):


async def chat(update, context: ContextTypes.DEFAULT_TYPE):
user_id = update.message.from_user.id
if public_bot and str(user_id) != config['TelegramUserId']:
# Do something here
context.bot.send_message(chat_id=update.message.chat_id, text="Sorry, you are not authorized to use this bot.")
return
# Check if message is not None
if update.message and update.message.text:
# Get user's message
Expand Down
5 changes: 3 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"OpenAItoken": "your OpenAI token",
"TelegramBotToken": "your telegram bot token"
}
"TelegramBotToken": "your telegram bot token",
"TelegramUserId": "your user id"
}
2 changes: 1 addition & 1 deletion python_setup.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pip install openai python-telegram-bot
pip install openai python-telegram-bot pandas
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
openai
python-telegram-bot
python-telegram-bot
pandas