#Import all libraries
import telebot
import time
import random
#Text string length
def str_counter(message):
mes = "Write plz your text:"
bot.send_message(message.from_user.id, text=mes)
text_len = bot.send_message(message.from_user.id, "Text:")
bot.register_next_step_handler(text_len, quantity_counter)
def quantity_counter(message):
#Получаем длину строки
global length_allchars
global length_withoutspace
global quantity_words
text = message.text
length_allchars = len(message.text)
length_withoutspace = length_allchars
for i in range(text):
if (i = " "):
length_withoutspace -= 1
quantity_words = 0
for i in range(text):
if (i = " "):
quantity_words += 1
return bot.send_message(message.from_user.id, length_allchars, length_withoutspace, quantity_words)
#Bot token
bot = telebot.TeleBot('')
#Bot commands and their processing
@bot.message_handler(commands = ['start', 'help', 'info', 'time', 'quantity_words'])
def get_text_messages(message):
if message.text == "/info":
bot.send_message(message.from_user.id, "")
if message.text == "/time":
bot.send_message(message.from_user.id, time.asctime())
if message.text == "/password":
bot.send_message(message.from_user.id, password_generator(message))
if message.text == "/quantity_words":
bot.send_message(message.from_user.id, str_counter(message))
bot.polling(none_stop=True, interval=0)