Compare commits
3 Commits
5e3cf25cda
...
64cd15908b
Author | SHA1 | Date |
---|---|---|
Stefano Assenzo | 64cd15908b | |
Stefano Assenzo | 2ec9cfcc6d | |
Stefano Assenzo | f3513ac50c |
|
@ -7,3 +7,5 @@ COPY . .
|
|||
RUN pip install -r requirements.txt
|
||||
|
||||
CMD [ "python", "./main.py" ]
|
||||
|
||||
EXPOSE 8080/tcp
|
||||
|
|
10
main.py
10
main.py
|
@ -1,5 +1,6 @@
|
|||
from src.commands import command_soon, command_subscribe, command_start, command_freegame #All commands of the bot are in the folder src.commands
|
||||
from src.events import check_game #All events of the bot are in the folder src.events (ex. check_game = check when Epic Games change the game)
|
||||
from flask import Flask
|
||||
from bson.objectid import ObjectId #Library for MongoDB (read ObjectId)
|
||||
from dotenv import load_dotenv #Library for .env file
|
||||
from telebot import telebot #Libraries for Telegram bot
|
||||
|
@ -10,6 +11,7 @@ import threading #Library for threading (ex. Check game every 10 seconds)
|
|||
|
||||
#Load all variables from .env file
|
||||
load_dotenv() #Load .env file
|
||||
app = Flask(__name__)
|
||||
API_TOKEN = os.getenv('BOT_TOKEN') #Token for Telegram bot
|
||||
USER_MONGO = os.getenv('USER_MONGODB') #User for MongoDB
|
||||
PASSWORD_MONGO = os.getenv('PASSWORD_MONGODB') #Password for MongoDB
|
||||
|
@ -24,6 +26,10 @@ collection_game = database["list-game"] #Collection name (list-game)
|
|||
|
||||
bot = telebot.TeleBot(API_TOKEN) #Connect to Telegram API
|
||||
|
||||
@app.route('/')
|
||||
def homepage():
|
||||
return 'Hello'
|
||||
|
||||
#Command /start
|
||||
@bot.message_handler(commands=['start'])
|
||||
def start(message, bot=bot):
|
||||
|
@ -51,4 +57,6 @@ def event_game(collection_game=collection_game, collection_id=collection_id, bot
|
|||
t1 = threading.Thread(target=event_game, args=())
|
||||
t1.start()
|
||||
|
||||
bot.polling()
|
||||
if __name__ == '__main__':
|
||||
app.run(port=8080)
|
||||
bot.polling()
|
||||
|
|
|
@ -3,3 +3,4 @@ python-dotenv == 0.20.0
|
|||
requests == 2.28.1
|
||||
schedule == 1.1.0
|
||||
pymongo[srv] == 4.1.1
|
||||
Flask==2.2.2
|
||||
|
|
Loading…
Reference in New Issue