def new_member(self): user_first_name = self.msg['new_chat_member']['first_name'] id_user = self.msg['new_chat_member']['id'] get_bot_name = self.bot.getMe() bot_name = get_bot_name['first_name'] if(user_first_name == bot_name): self.bot.sendMessage(self.chat_id, 'Olá, sou o Tycot!') sql.criar_table(self.chat_id) else: try: retorno = sql.inserir(chat, user_first_name, id_user) if(retorno=='erro ao inserir'): print('erro ao inserir') with open('.tmp/welcome' + str(self.chat_id) + '.txt', 'r') as welcome: welcome = welcome.read() welcome = welcome.replace('$name', user_first_name) self.bot.sendMessage(self.chat_id, welcome) except FileNotFoundError: print('Grupo sem um welcome' + str(self.chat_id) + '.txt') except telepot.exception.TelegramError: self.bot.sendMessage(chat_id=self.chat_id, parse_mode='Markdown', text='Seja Bem Vindo(a) [{0}](https://telegram.me/{1}/)'.format(user_first_name,id_user), disable_web_page_preview=True ) return True
def add(self): sql.criar_table(self.chat_id) if sql.procurar(self.chat_id, self.msg['from']['id']) == 'erro ao procurar': sql.inserir(self.chat_id, self.msg['from']['id']) else: pass
def add(self): sql.criar_table(self.chat_id) if sql.procurar(self.chat_id, self.msg['from']['id']) == 'erro ao procurar': sql.inserir(self.chat_id, self.msg['from']['first_name'], self.msg['from']['id']) else: sql.menssagens(self.chat_id, self.msg['from']['id'])