S
S
Studentka19962021-06-18 15:04:18
Python
Studentka1996, 2021-06-18 15:04:18

How to fix ssl error in (multipocessing) Telegram bot?

token = ''
URL = f'https://api.telegram.org/bot{token}' # URL на который отправляется запрос
print(requests.get(URL + '/getUpdates', verify=False).json()) #GET запрос к API Telegram для получение словаря данных
bot = telebot.TeleBot(token)

  def send_annul(sec, id_order, date_order, sum_order):
        print('Заказ №' + id_order)
        time.sleep(sec) # через 15 сек отправляю сообщение # если время не прошло, жду
        conn_DB.upd_statusOrders('Аннулирован', int(id_order))

        # bot = telebot.TeleBot(token, threaded=False)
        bot.send_message(message.chat.id, text = f'*\u3030ЗАКАЗ №1 АННУЛИРОВАН* от 1 на сумму 1 руб.',
                parse_mode = "Markdown", reply_markup = send_keyb_order(buttons.ls_keybs_orders(message.chat.id)[2]))

    def worker():
        global proc
        # proc = multiprocessing.Process(target=worker(f"{conn_DB.id_Zakaz()}", f"{zakaz[2]}", f"{zakaz[4]}"))
        proc = multiprocessing.Process(target=send_annul, args=(10, f"{conn_DB.id_Zakaz()}", 1, 1))
        print(proc)
        proc.start()
        # proc.terminate()

worker()


Error while calling the send_message() method:
60cc8bb043d52901577496.png

How can I fix it?

Error text:
File "/usr/lib/python3.8/site-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'ssl3_get_record ', 'decryption failed or bad record mac')]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Studentka1996, 2021-06-18
@Studentka1996

Decision:

def post_annulOrder(id_order, date_order):
    print('Отправка сообщения об аннулировании заказа')
    requests.post(f'{URL}/sendMessage', data = {'chat_id': 454752968, 'text': f'*\u3030ЗАКАЗ № {id_order}* от {date_order} на сумму 1 руб.- АННУЛИРОВАН!',
                'parse_mode': 'Markdown'})

I was underestimating http requests (in a bot)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question