105 lines
3.5 KiB
Python
105 lines
3.5 KiB
Python
|
import logging
|
||
|
|
||
|
from convopyro import listen_message
|
||
|
from libbot import i18n
|
||
|
from pykeyboard import ReplyButton, ReplyKeyboard
|
||
|
from pyrogram import filters
|
||
|
from pyrogram.types import Message, ReplyKeyboardRemove
|
||
|
|
||
|
from classes.pyroclient import PyroClient
|
||
|
|
||
|
logger = logging.getLogger(__name__)
|
||
|
|
||
|
|
||
|
@PyroClient.on_message(
|
||
|
~filters.scheduled & filters.private & filters.command(["setup"] + i18n.sync.in_all_locales("configure", "buttons"), prefixes=["/", ""]) # type: ignore
|
||
|
)
|
||
|
async def command_setup(app: PyroClient, message: Message):
|
||
|
user = await app.find_user(message.from_user)
|
||
|
|
||
|
await message.reply_text(
|
||
|
"Holy... This one is still WIP...", reply_markup=ReplyKeyboardRemove()
|
||
|
)
|
||
|
|
||
|
# # City selection
|
||
|
# city_names = [city_iter.name for city_iter in await app.get_cities()]
|
||
|
# keyboard_cities = ReplyKeyboard(resize_keyboard=True, row_width=2)
|
||
|
# keyboard_cities.add(*[ReplyButton(name) for name in city_names])
|
||
|
|
||
|
# await message.reply_text(
|
||
|
# "Alright. Please, use the keyboard provided to choose your town.",
|
||
|
# reply_markup=keyboard_cities,
|
||
|
# )
|
||
|
|
||
|
# while True:
|
||
|
# answer_city = await listen_message(app, message.chat.id, 300)
|
||
|
|
||
|
# if answer_city is None or answer_city.text == "/cancel":
|
||
|
# await message.reply_text("Cancelled.")
|
||
|
# return
|
||
|
|
||
|
# if answer_city.text not in city_names:
|
||
|
# await answer_city.reply_text(
|
||
|
# "Please, select a valid town using keyboard provided. Use /cancel if you want to cancel this operation."
|
||
|
# )
|
||
|
# continue
|
||
|
|
||
|
# break
|
||
|
|
||
|
# # City recognition
|
||
|
# city = await app.find_city(name=answer_city.text)
|
||
|
|
||
|
# # District selection
|
||
|
# district_names = [district_iter.name for district_iter in city.districts]
|
||
|
# keyboard_districts = ReplyKeyboard(resize_keyboard=True, row_width=2)
|
||
|
# keyboard_districts.add(*[ReplyButton(name) for name in district_names])
|
||
|
|
||
|
# await message.reply_text(
|
||
|
# "Alright. Please, use the keyboard provided to choose your district.",
|
||
|
# reply_markup=keyboard_districts,
|
||
|
# )
|
||
|
|
||
|
# while True:
|
||
|
# answer_district = await listen_message(app, message.chat.id, 300)
|
||
|
|
||
|
# if answer_district is None or answer_district.text == "/cancel":
|
||
|
# await message.reply_text("Cancelled.")
|
||
|
# return
|
||
|
|
||
|
# if answer_district.text not in district_names:
|
||
|
# await answer_district.reply_text(
|
||
|
# "Please, select a valid district using keyboard provided. Use /cancel if you want to cancel this operation."
|
||
|
# )
|
||
|
# continue
|
||
|
|
||
|
# break
|
||
|
|
||
|
# # District recognition
|
||
|
# district_results = city.find_district(answer_district.text)
|
||
|
|
||
|
# if len(district_results) == 0:
|
||
|
# await answer_district.reply_text(
|
||
|
# "Something went wrong. Could not find this district in the database.",
|
||
|
# reply_markup=ReplyKeyboardRemove(),
|
||
|
# )
|
||
|
# return
|
||
|
|
||
|
# district = district_results[0]
|
||
|
|
||
|
# await user.update_city(city.id)
|
||
|
# await user.update_district(district.id)
|
||
|
|
||
|
# logger.info(
|
||
|
# "User %s has finished the location set up with city %s and district %s selected",
|
||
|
# user.id,
|
||
|
# city.id,
|
||
|
# district.id,
|
||
|
# )
|
||
|
|
||
|
# notice = "" if user.enabled else "Execute /toggle to enable notifications."
|
||
|
|
||
|
# await answer_district.reply_text(
|
||
|
# f"All set! You will now receive notification about garbage collection in district **{district.name}** of the town **{city.name}**. {notice}",
|
||
|
# reply_markup=ReplyKeyboardRemove(),
|
||
|
# )
|