M
M
Muck Runout2022-03-07 19:15:32
Python
Muck Runout, 2022-03-07 19:15:32

How to call the command correctly?

import telebot
from telebot import types
import time
import random
from random import randint
from datetime import datetime, date
bot = telebot.TeleBot('токен')
x = 0
counter = 0
@bot.message_handler(content_types=['text'])
def get_text_messages(message):
  def schet():
  	global counter
  	counter == 0
  	schet.config()
  	while 1:
  	   x = random.randint(0, 15)
  	   counter = counter + x
  	   bot.send_message(message.chat.id,"Тебе выпало " + x + " теперь у тебя " + counter + " счёт")
  	   time.sleep(86400)
  if message.text == "/schet":
  	 schet(command == schet)
  if message.text == "/start":
  	bot.reply_to(message, "Привет! Я отчим бот\nМоя суть заключается именно в развлекательных целях\nпропиши команду /schet\n что бы рандомно выбить число от 0 до 15\nэто число ваш счёт!")
bot.remove_webhook()
if __name__ == "__main__":
    bot.polling(none_stop=True)

Complains about the line schet (command == schet) in principle, it is expected, just tell me please how to call the schet () command, otherwise I was so desperate that I want to do it through tkinter

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Elvis, 2022-03-07
@Dr_Elvis

if message.text == "/schet":
    schet()

D
defriz, 2022-03-07
@defriz

async def schet():
  	global counter
  	counter == 0
  	schet.config()
  	while 1:
  	   x = random.randint(0, 15)
  	   counter = counter + x
  	   bot.send_message(message.chat.id,"Тебе выпало " + x + " теперь у тебя " + counter + " счёт")
  	   time.sleep(86400)
  if message.text == "/schet":
  	 await schet()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question