skip to Main Content
import asyncio

from aiogram import Dispatcher, Bot
from aiogram.filters import CommandStart
from aiogram.types import Message

token = 'tokentokentokentokentokentokentoken'
the_bot = Bot(token)
main_handler = Dispatcher()

@main_handler.message(CommandStart())
async def cmd_start(msg: Message) -> None:
    await msg.answer('hi')

async def main():
    await main_handler.start_polling(the_bot)
if __name__ == '__main__':
    asyncio.run(main())

getting this error

Running a Telegram bot off of my own computer. I live in Xi’An China so I can’t get to the API because Telegram is blocked here.
wath do?

2

Answers


  1. Aiogram 3.1.1 didnot natively support proxy configuration, to use proxy for, you typically needed to use external Python libraries like aiosocksy or aiohttp. These libraries can be used to route your bot requests through a proxy server.

    Login or Signup to reply.
  2. you can write like this

    from aiogram import Bot
    from aiogram.client.session.aiohttp import AiohttpSession
    
    session = AiohttpSession(proxy="protocol://host:port/")
    bot = Bot(token="bot token", session=session)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search