S
S
siganiga2020-09-07 17:12:33
Python
siganiga, 2020-09-07 17:12:33

How to combine form submission into 1 message?

Hello, I made a bot.
But submitting the form doesn't work for me.
They are shipped separately.

Script:

import telebot
import config
import random
from telebot import types # кнопки
from string import Template

 
bot = telebot.TeleBot('XXXXX20083:AAEWRdJyH6H_XXXXXXX_65O2KXXXXXQ0')
 
@bot.message_handler(commands=['start'])
def welcome(message):
    sti = open('1/welcome.webp', 'rb')
    bot.send_sticker(message.chat.id, sti)
 
    # keyboard
    markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
    item1 = types.KeyboardButton(" Отправка Номера", request_contact = True)
    item2 = types.KeyboardButton(" Отправить Местоположение", request_location = True)

 
    markup.add(item1, item2)
 
    bot.send_message(message.chat.id, "Добро пожаловать, {0.first_name}!\nЯ - <b>{1.first_name}</b>, бот Сиги для изучения создания ботов.\nДля начала пройди регистрацию!".format(message.from_user, bot.get_me()),
        parse_mode='html', reply_markup=markup)
 
@bot.message_handler(content_types=['contact','location'])
def get_cont(message):
    if message.content_type == 'contact':
        bot.send_message(message.chat.id,("Вы прошли регистрацию\nОтправьте ваше местоположение."))
        bot.send_message(-45XXXXX81,("Имя: "+str(message.from_user.first_name)))
        bot.send_message(-45XXXXX81,("Nick: "+str(message.from_user.username)))
        bot.send_message(-45XXXXX81,("Номер: "+str(message.contact.phone_number)))
    else:
        bot.send_message(message.chat.id,("❤️Вы отправили ваше местоположение {0.first_name}❤️\nДавайте дальше.".format(message.from_user)))
        bot.send_message(-45XXXXX81,("Долгота: "+str(message.location.latitude)))
        bot.send_message(-45XXXXX81,("Широта: "+str(message.location.longitude)))

 
# RUN
bot.polling(none_stop=True)


They come to the Group something like this .
5f563f9c93485502956066.jpeg

I would like Nick - Nickname - Number to come in One message
Also with Longitude and Latitude

I can't do it at all. Help me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zexer, 2020-09-07
@siganiga

What's the problem with adding all this to two text variables and outputting them separately?

name = 'siga'
nick = 'siga_idk'
number = '23132313'
lon = '55'
lat = '45'

a = f"""
Имя: {name}
Nick: {nick}
Номер: {number}"""

b = f"""
Lon: {lon}
Lat: {lat}"""

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question