-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
32 lines (24 loc) · 920 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import telebot
from decouple import config
from helpers.helpers import get_parameters
from service.Service import Service
API_TOKEN_BOT = config('TOKEN_BOT')
bot = telebot.TeleBot(API_TOKEN_BOT, parse_mode=None)
service = Service()
# /agregar_materia NOMBRE_MATERIA, NUMERO_SEMESTRE
@bot.message_handler(commands=['agregar_materia'])
def add_subject(message):
parameters = get_parameters(message.text)
print(parameters)
if len(parameters) != 2:
bot.reply_to(message,"La cantidad de parametros son 2 con la forma NombreMateria, NumeroSemestre")
return
subject = parameters[0]
semester_number = parameters[1]
ok = service.add_subject(subject, int(semester_number))
if ok:
bot.reply_to(message, f"Agregada la materia {subject}")
else:
bot.reply_to(message, f"La {subject} ya fue agregada previamente")
if __name__ == '__main__':
bot.polling()