Нету ответа от бота, что делать?
Бот начинает свою работу, в терминале пишет "BOT STARTED" без каких либо ошибок, но при отправке команды /start, ничего не происходит
from aiogram import Bot, Dispatcher, types
import asyncio
import requests
PROBIVAPI_KEY = "YOUR_PROBIVAPI_KEY_HERE"
API_TOKEN = "6856201616:*****ZmTPylSaR0p1s4q0BkcKPkti_O4Tbw"
bot = Bot(token=API_TOKEN)
dp = Dispatcher()
print("!BOT STARTED!")
async def get_start(message: types.Message):
await message.answer("Привет, введи айди человека")
async def send_help(message: types.Message):
await message.reply("soon")
async def text(message: types.Message):
nomer = message.text
print(nomer)
url = "https://api.com/info/" + nomer
head = {
"X-Auth": PROBIVAPI_KEY
}
response = requests.get(url, headers=head)
print(response.text)
try:
json_response = response.json()
except Exception:
json_response = {}
try:
truecaller_api_name = str(json_response['truecaller']['data'][0]['name'])
except Exception:
truecaller_api_name = 'Not found'
try:
numbuster_api_name = str(json_response['numbuster']['averageProfile']['firstName']) + \
str(json_response['numbuster']['averageProfile']['lastName'])
except Exception:
numbuster_api_name = 'Not found'
try:
eyecon_api_name = str(json_response['eyecon'])
except Exception:
eyecon_api_name = 'Not found'
try:
viewcaller_name_list = []
for tag in json_response['viewcaller']:
viewcaller_name_list.append(tag['name'])
viewcaller_api_name = ', '.join(viewcaller_name_list)
except Exception:
viewcaller_api_name = 'Not found'
await message.reply(
f"? База: (Numbuster): {numbuster_api_name}\n"
f"? База: (EyeCon): {eyecon_api_name}\n"
f"? База: (ViewCaller): {viewcaller_api_name}\n"
f"? База: (TrueCaller): {truecaller_api_name}"
)
async def main():
dp.register_message_handler(get_start, commands="/start")
dp.register_message_handler(send_help, commands="/help")
bot = Bot(API_TOKEN)
await dp.start_polling(bot)
if __name__ == '__main__':
asyncio.run(main())
Ответы (1 шт):
Автор решения: Rashing
→ Ссылка
Убери / из dp.register_message_handler(get_start, commands="/start")
Должно остаться:
async def main():
dp.register_message_handler(get_start, commands="start")
dp.register_message_handler(send_help, commands="help")
bot = Bot(API_TOKEN)
await dp.start_polling(bot)