Python Bot Telegram - Проблема с командой, вызванной извне - PullRequest
0 голосов
/ 07 июля 2019

Я создал бота Telegram с пользовательской командой с именем «command1».

Команда отлично выполняется через интерфейс Telegram: working-command Но, если я хочу вызватькоманда из внешнего сервиса команда не работает: ошибка-команда

Здесь код бота:

import telebot
from telebot import types

import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                    level=logging.INFO)
logger = logging.getLogger(__name__)

API_TOKEN = '12345'

bot = telebot.TeleBot(API_TOKEN)


# Handle '/start' and '/help'
@bot.message_handler(commands=['help', 'start'])
def send_welcome(message):
    logger.info('send_welcome')
    msg = bot.reply_to(message, "Hi there, I am Example bot.")


# Handle '/command1'
@bot.message_handler(commands=['command1'])
def command1(message):
    msg = bot.reply_to(message, 'command1 executed!')
    logger.info('command1')

bot.polling()

Это «внешний сервис»:

import requests

def telegram_bot_sendtext(bot_message):

    bot_token = '12345'
    bot_chatID = '8200000001'
    send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&text=' + bot_message

    response = requests.get(send_text)

    return response.json()


test = telegram_bot_sendtext("/command1") # tested also with "command1" sintax
print(test)

Почему команда не выполняется, когда она вызывается извне?

Любая помощь приветствуется.

...