S
S
Serge X2021-02-11 03:36:56
Python
Serge X, 2021-02-11 03:36:56

Why does it give an error when uploading the bot to the server?

If you run it on a computer, then the bot works fine. As soon as you upload the bot to the server and run it there, it gives the following error:

ec14784a58df4192364caeb624494875.png

import telebot
import config
import requests
import json

bot = telebot.TeleBot(config.TOKEN)

markdown = """
    *bold text*
    _italic text_
    [text](URL)
    """

namebot = bot.get_me().username
while namebot == 'upcpatickets_bot':
    with open('/opt/upcpatickets_bot/id.txt', 'r') as f:
        last = f.read()
    url = 'https://api-upcpa.affise.com/3.0/admin/ticket/' + str(last) + '?API-Key=' + config.APIKey
    answer = requests.get(url)
    parsed_string = json.loads(answer.text)
    print(parsed_string)
    if parsed_string['status'] != 2:
        if int(parsed_string['ticket']['id']) >= int(last):
            id_web = parsed_string['ticket']['partner']['id']
            type_t = parsed_string['ticket']['type']
            title_t = parsed_string['ticket']['title']
            description_t = parsed_string['ticket']['description']
            message_out = '*Получен новый тикет* \n*ID веба:* ' + str(id_web) + '\n' + '*Тип:* ' + str(type_t) + '\n' + \
                          '*Тема:* ' + title_t + '\n' + '*Описание:* ' + description_t + '\n '
            answer = bot.send_message(chat_id='-1001243762925', text=message_out, parse_mode="Markdown")
            last2 = int(last)+1
            new_data = last.replace(last, str(last2))
            with open('/opt/upcpatickets_bot/id.txt', 'w') as f:
                f.write(new_data)
    else:
        continue

bot.polling(none_stop=True)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-02-11
@bacon

you obviously write in the error that there is no json in answer.text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question