Answer the question
In order to leave comments, you need to log in
Write function with variable from user for Telegram bot in Python?
Good afternoon! I've been fighting over the bot in the telegarm for a week now. I want to make a function that writes the user's message to a variable and issues it with a message, an already set variable + a variable that the user sent. So far implemented the function on the echo bot
from typing import Text
import telebot
from telebot import types
import time
bot = telebot.TeleBot('')
link = "http://api.whatsapp.com/send/?phone="
@bot.message_handler(commands=['start'])
def start(message):
bot.send_message(message.chat.id, 'Напиши номер телефона, а я пришлю тебе ссылку в формате:')
bot.send_message(message.chat.id, link + 'НОМЕР')
@bot.message_handler(content_types=['text'])
def txt(message):
bot.send_message(message.chat.id, link + message.text)
bot.polling()
Answer the question
In order to leave comments, you need to log in
import telebot
bot = telebot.TeleBot('TOKEN')
def number(message):
bot.send_message(message.chat.id, f'Вот твоя ссылка: http://api.whatsapp.com/send/?phone={message.text}')
@bot.message_handler(commands=['start'])
def welcom(message):
bot.send_message(message.chat.id, 'Отправь номер телефона')
bot.register_next_step_handler(message, number)
bot.polling()
bot.register_next_step_handler(message, number)
moves to another function
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question