Ask coding questions

← Back to all posts
"AttributeError: 'TelegramBOT' object has no attribute 'Iniciar' " But is everything ok to me
fabricioply

bot.Iniciar is returning an error, " AttributeError: 'TelegramBOT' object has no attribute 'Iniciar'"

import requests
import time
import json

class TelegramBOT:
def init(self):
token = '2082057436:AAHf80BLilZql218pGEap9n3lzCkW68d4HE'
url_base = f'api.telegram.org/bot2082057436:AAHf80BLilZql218pGEap9n3lzCkW68d4HE/'

##############Iniciar o bot
def Iniciar(self):
update_id = None
while True:
atuallizacao = self.obter_mensagens(update_id)
mensagens = atualizacao['result']
if mensagens:
for mensagem in mensagens:
update_id = mensagem['update_id']
chat_id = mensagem['message']['id']
resposta = self.criar_resposta()
self.responder(resposta,chat_id)

def criar_resposta(self):
return 'Olá, qual a pergunta?'

def responder(self,resposta,chat_id):

bot = TelegramBOT()
bot.Iniciar

Can you guys help me?
I'm just a student trying to make something cool on telegram, so I'm using this code to learn the basics about telegram bot before webscraping

Voters
fabricioply
Comments
hotnewtop
CosmicBear

You need to fix the indenting. The function Iniciar is in the function __init__.