I
I
Ilya Bugaets2020-02-13 17:15:44
Python
Ilya Bugaets, 2020-02-13 17:15:44

From the first time does not go to glmenu?

When you click on the "My Creator" button, it should redirect to the menuCreator the first time, but it doesn't work the first time. What to do?
Here is the code

import telebot
import config
import random
import time
import pyowm
import datetime
import calendar

from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton
from random import choice
from telebot import types

School = ["Физ-ра\nРусский\nАнглийский\nИстория\nФизика\nАлгебра\nГеометрия","Иформатика\nГеография\nФиз-ра\nМузыка\nРусский\nЛитература\nОБЖ", 
"Физ-ра\nХимия\nАлгебра\nРусский\nРусский\nГеография", "Биология\nИстория\nТруд\nОбщество\nЛитература\nАнглийский", 
"Химия\n Английский\nАлгеьра\nГеометрия\nФизика\nБиология\nАлгебра", "Выходной"]

today = datetime.datetime.today()

mydate = today.strftime("%d.%m.%Y")

workdate = datetime.datetime.strptime(mydate, "%d.%m.%Y")
day = calendar.day_abbr[workdate.date().weekday()]

abcd = False
testpy = False

schedule = "1. с 8.00 до 8.45\n2. с 8.50 до 9.35\n3. с 9.40 до 10.25\n4. с 10.40 до 11.25\n5. с 11.30 до 12.15\n6. с 12.20 до 13.05\n7. с 13.25 до 14.10 "

owm = pyowm.OWM(config.owmm, language = "ru")

observation = owm.weather_at_place(config.place)
w = observation.get_weather()

temp = w.get_temperature('celsius')["temp"] 

adv = ['В разработке']
Creator = "Меня создал Илья Бугаец"
groups = ['Создатель', 'Модер', 'Помощник', 'Смертный']

bot = telebot.TeleBot(config.TOKEN)

@bot.message_handler(commands=['start'])
def welcome(message):
  markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  item1 = types.KeyboardButton("☁️Погода☁️")
  item2 = types.KeyboardButton("Мой Создатель")
  item3 = types.KeyboardButton("Уроки")
  item4 = types.KeyboardButton("Расписание Звонков")
  item5 = types.KeyboardButton("Время")

  markup.add(item1, item2, item3, item4, item5)

  bot.send_message(message.chat.id, "Привет",reply_markup=markup)

@bot.message_handler(commands=['help'])
def welcome_help(message):
    bot.send_message(message.chat.id, Creator)

@bot.message_handler(commands=['groups'])
def welcome_help(message):
    bot.send_message(message.chat.id, groups)

@bot.message_handler(content_types=['text'])
def lalka(message):
  if message.text == "Время":
      timeH = datetime.datetime.now().time()
      bot.send_message(message.chat.id, timeH)
  elif message.text == "☁️Погода☁️":
      bot.send_message(message.chat.id, "В судаке сейчас " + w.get_detailed_status() + "\n" + "Температура в районе " + str(temp))
  elif message.text == "Мой Создатель":
    bot.register_next_step_handler(message, menuCreator)
  elif message.text == "Уроки":
      if day == "Mon":
          bot.send_message(message.chat.id, School[0])
      elif day == "Tue":
          bot.send_message(message.chat.id, School[1])
      elif day == "Wed":
          bot.send_message(message.chat.id, School[2])
      elif day == "Thu":
          bot.send_message(message.chat.id, School[3])
      elif day == "Fri":
          bot.send_message(message.chat.id, School[4])
      elif day == "Sun":
          bot.send_message(message.chat.id, School[5])
      elif day == "Sat":
          bot.send_message(message.chat.id, School[5])
  elif message.chat.type == 'private' and message.text == "Расписание Звонков":
      bot.send_message(message.chat.id, schedule)
  elif message.text == "Назад":
    bot.register_next_step_handler(message, glmenu)

def glmenu (message):
  markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  item1 = types.KeyboardButton("☁️Погода☁️")
  item2 = types.KeyboardButton("Мой Создатель")
  item3 = types.KeyboardButton("Уроки")
  item4 = types.KeyboardButton("Расписание Звонков")
  item5 = types.KeyboardButton("Время")

  markup.add(item1, item2, item3, item4, item5)

  bot.send_message(message.chat.id, "Выбери",reply_markup=markup)

def menuCreator(message):
  markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
  item1 = types.KeyboardButton("Вк")
  item2 = types.KeyboardButton("Телеграм")
  item3 = types.KeyboardButton("Назад")

  markup.add(item1, item2, item3)

  bot.send_message(message.chat.id, "Выбери",reply_markup=markup)

bot.polling(none_stop=True)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d4c4237abc, 2020-02-13
@ilyabugaets

fix message.chat.id
bot.register_next_step_handler(message.chat.id, menuCreator)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question