Reputation: 153
I use pytelegrambotapi library to make my bot in telegram.
Here is my code:
import config
import telebot
bot = telebot.TeleBot(config.token)
@bot.message_handler(commands=['start'])
def handle_start_message(message):
bot.send_message(message.chat.id, "Hello. I'm your bot")
print(message.text)
What I want to do is to return the message text in my command line. It returns nothing, however, the bot is working since it answers me in telegram.
Upvotes: 1
Views: 2290
Reputation: 1
This one works but it will simply spit out the entire content.
@bot.message_handler(func=lambda message: True)
def echo_message(message):
print(message)
bot.reply_to(message, message.text)
I am trying to find a better alternative hope I will make this process simple.
##updated
print(message.text)
I have tested it.
Upvotes: 0
Reputation: 2963
Most probably, the code is running in separate Tread/Process, which does not have access to the console, and hence, not able to print something in it.
Use logging to file instead of print.
Here is a useful link - https://github.com/python-telegram-bot/python-telegram-bot#logging
Upvotes: 2