if 'Session_Id' in answer1: #Session_id у вас является строкой, а не переменной...
import telebot
from telebot import types
import requests
import uuid
bot = telebot.TeleBot("MY_TOKEN")
url="MY_LINK"
headers = {'content-type': 'text/xml'}
session_id = uuid.uuid4() # session_id1
request1 = f"""<typ:simple>
<typ:attributeName>Session_Id</typ:attributeName>
<typ:value>{session_id}</typ:value>
</typ:simple>"""
session_id = uuid.uuid4() # session_id2
request2 = f"""<typ:simple>
<typ:attributeName>Session_Id</typ:attributeName>
<typ:value>{session_id}</typ:value>
</typ:simple>"""
@bot.message_handler(commands=['start'])
def send_welcome(message):
bot.send_message(
message.chat.id,
"""Тестовое сообщение""",
reply_markup=keyboard())
def keyboard():
markup = types.ReplyKeyboardMarkup(one_time_keyboard=False, resize_keyboard=True)
markup.add('запрос1')
return markup
@bot.message_handler(content_types=['text'])
def send_text(message):
if message.text.lower() == 'запрос1':
response1 = requests.post(url,data=request1.encode('utf-8'),headers=headers)
answer1 = response1.content.decode('UTF-8')
status_code1 = response1.status_code
bot.send_message(message.chat.id, answer1, status_code1)
if 'Session_Id' in answer1:
response2 = requests.post(url,data=request2.encode('utf-8'),headers=headers)
answer2 = response2.content.decode('UTF-8')
status_code2 = response2.status_code
bot.send_message(message.chat.id, answer2, status_code2)
bot.polling(none_stop = True)