L
L
Lucas Petrov2020-05-12 11:26:07
Python
Lucas Petrov, 2020-05-12 11:26:07

I'm trying to create a simple echo-telegram bot. Gives an error message. What to do?

I tried to create a simple telegram bot through Python. I know that Telegram was blocked in Russia. I even used a proxy, but it still didn't help. Writes at the end: AttributeError: 'set' object has no attribute 'get'.

The program itself:

import telebot
from telebot import apihelper
apihelper. proxy = {'https://85.132.71.82:3128'}
bot = telebot. TeleBot( ' мой токен') 
@bot.message_handler(content_types=["text"])
def repeat_all_messages(message) :
       bot.send_message(message.chat.id, message. text) 
if__name__== '__main__' :

bot. polling(none_stop=True)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2020-05-12
@hottabxp

You are not specifying the proxy correctly.
Need like this:

apihelper.proxy = {'https':'45.77.101.237:8080'}
#apihelper.proxy = {'https':'IP:PORT'}

Wangyu, with your proxy there will be such an error:
.ConnectTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /

The solution is simple - use a working proxy.

R
Robur, 2020-05-12
@Robur

Gives an error message. What to do?

Learn python.
In between - learn to google, exactly the same question with exactly the same code (apparently the author copy-pasted from the same place as you) was asked on the toaster, and there is an answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question