Esempio n. 1
0
 async def update(self, telegram_message):
     self.ping
     chat = extract_chat_object(telegram_message)
     user = extract_user_object(telegram_message)
     if (self.chat_exists(chat.chat_id)) == False:
         await self.insert_chat(chat)
     if (self.user_exists(user.telegram_id)) == False:
         await self.insert_user(user)
Esempio n. 2
0
 async def messages_helper(message: types.Message):
     if message.chat.type != "group":
         chat = extract_chat_object(message)
         user = extract_user_object(message)
         response = await self.validation.running_proccess(
             user.telegram_id, chat.chat_id, message)
         if response:
             await bot.send_message(chat.chat_id, response)
     else:
         return
Esempio n. 3
0
    def update(self, telegram_message):
        chat = extract_chat_object(telegram_message)
        user = extract_user_object(telegram_message)

        if not self.find_chat(chat.chat_id):
            self.insert_chat(chat)
        if not self.find_chat(chat.chat_id):
            self.insert_chat(chat)

        if not self.find_user(user.telegram_id):
            self.insert_user(user)
Esempio n. 4
0
 async def ticket_handler(message: types.Message):
     await bot.send_chat_action(message.chat.id, "typing")
     if (len(message.text) > 7):
         ticket_id = message.text.split(' ')[1]
         ticket_status = self.glpi.getTicket(ticket_id)
         await message.reply(ticket_status)
     else:
         chat = extract_chat_object(message)
         user = extract_user_object(message)
         response = await self.validation.ticket_creation_process(
             user.telegram_id, chat.chat_id)
         await message.reply(response)
Esempio n. 5
0
 def get_user(self, message):
     self.ping
     user = extract_user_object(message)
     check_user = self.cursor.execute(
         f"select * from users u where u.telegram_id = {user.telegram_id}")
     if (check_user == 0):
         return False
     check_user = self.cursor.fetchone()
     user.is_admin = bool(check_user[4])
     user.admin_level = check_user[6] if check_user[6] != None else 0
     user.glpi_user = check_user[5]
     user.zabbix_user = check_user[3]
     return user
Esempio n. 6
0
 async def registrate_glpi_user(message: types.Message):
     await bot.send_chat_action(message.chat.id, "typing")
     if self.connections['database'] == False:
         await message.reply(
             "Bot em manutenção. Por favor, contate os administradores."
         )
         return
     else:
         user = self.database.get_user(message)
         if user.glpi_user:
             await message.reply("Usuário já cadastrado")
         else:
             chat = extract_chat_object(message)
             user = extract_user_object(message)
             response = await self.validation.glpi_registration_process(
                 user.telegram_id, chat.chat_id)
             await message.reply(response)
Esempio n. 7
0
 async def return_user_id(message: types.Message):
     await bot.send_chat_action(message.chat.id, "typing")
     msg = extract_user_object(message)
     await message.reply(msg.telegram_id)