No command rework for kfet
This commit is contained in:
parent
49221e9553
commit
26b974fa15
2 changed files with 19 additions and 12 deletions
|
@ -14,6 +14,7 @@
|
||||||
"kfet_list": "\uD83D\uDDD2Kfet commands ready:\n",
|
"kfet_list": "\uD83D\uDDD2Kfet commands ready:\n",
|
||||||
"kfet_close": "\uD83D\uDEABKfet close, sorry",
|
"kfet_close": "\uD83D\uDEABKfet close, sorry",
|
||||||
"kfet_set": "Your command is set ! \u2705",
|
"kfet_set": "Your command is set ! \u2705",
|
||||||
|
"kfet_set_await": "Send your command number !",
|
||||||
"notif_set": "Notifications set on `{}` ! \u2705",
|
"notif_set": "Notifications set on `{}` ! \u2705",
|
||||||
"err_num": "Invalid number ! \u274C",
|
"err_num": "Invalid number ! \u274C",
|
||||||
"notif_time_cooldown": "Notification `{}` set to `{}` ! \u2705",
|
"notif_time_cooldown": "Notification `{}` set to `{}` ! \u2705",
|
||||||
|
|
30
bot.py
30
bot.py
|
@ -41,7 +41,6 @@ if not isfile("token.ini"):
|
||||||
API_TOKEN = open("token.ini").readline().replace("\n", "")
|
API_TOKEN = open("token.ini").readline().replace("\n", "")
|
||||||
ADMIN_ID = 148441652
|
ADMIN_ID = 148441652
|
||||||
TIMES = ["", "day", "next", "week", "next week"]
|
TIMES = ["", "day", "next", "week", "next week"]
|
||||||
NOTIF_CMD = ["notif", "notif toggle", "notif time", "notif cooldown"]
|
|
||||||
|
|
||||||
bot = Bot(token=API_TOKEN)
|
bot = Bot(token=API_TOKEN)
|
||||||
posts_cb = CallbackData("post", "id", "action")
|
posts_cb = CallbackData("post", "id", "action")
|
||||||
|
@ -130,6 +129,8 @@ async def start(message: types.Message):
|
||||||
user = db[user_id]
|
user = db[user_id]
|
||||||
key = reply_keyboard.ReplyKeyboardMarkup()
|
key = reply_keyboard.ReplyKeyboardMarkup()
|
||||||
key.add(reply_keyboard.KeyboardButton("Edt"))
|
key.add(reply_keyboard.KeyboardButton("Edt"))
|
||||||
|
key.add(reply_keyboard.KeyboardButton("Kfet"))
|
||||||
|
key.add(reply_keyboard.KeyboardButton("Setkfet"))
|
||||||
key.add(reply_keyboard.KeyboardButton("Setedt"))
|
key.add(reply_keyboard.KeyboardButton("Setedt"))
|
||||||
key.add(reply_keyboard.KeyboardButton("Notif"))
|
key.add(reply_keyboard.KeyboardButton("Notif"))
|
||||||
await message.reply(lang(user, "welcome"), parse_mode=ParseMode.MARKDOWN, reply_markup=key)
|
await message.reply(lang(user, "welcome"), parse_mode=ParseMode.MARKDOWN, reply_markup=key)
|
||||||
|
@ -159,11 +160,11 @@ async def edt_query(query: types.CallbackQuery, callback_data: dict):
|
||||||
await query.message.reply(calendar(callback_data["action"], query.from_user.id), parse_mode=ParseMode.MARKDOWN, reply_markup=edt_key())
|
await query.message.reply(calendar(callback_data["action"], query.from_user.id), parse_mode=ParseMode.MARKDOWN, reply_markup=edt_key())
|
||||||
|
|
||||||
|
|
||||||
@dp.message_handler(commands="kfet")
|
@dp.message_handler(lambda msg: msg.text.lower() == "kfet")
|
||||||
async def kfet(message: types.Message):
|
async def kfet(message: types.Message):
|
||||||
user_id = str(message.from_user.id)
|
user_id = str(message.from_user.id)
|
||||||
await message.chat.do(types.ChatActions.TYPING)
|
await message.chat.do(types.ChatActions.TYPING)
|
||||||
logger.info(f"{message.from_user.username} do kfet command: {message.text}")
|
logger.info(f"{message.from_user.username} do kfet command")
|
||||||
with dbL:
|
with dbL:
|
||||||
with shelve.open("edt", writeback=True) as db:
|
with shelve.open("edt", writeback=True) as db:
|
||||||
if not 9 < get_now().hour < 14 or not get_now().isoweekday() < 6:
|
if not 9 < get_now().hour < 14 or not get_now().isoweekday() < 6:
|
||||||
|
@ -177,23 +178,19 @@ async def kfet(message: types.Message):
|
||||||
await message.reply(msg, parse_mode=ParseMode.MARKDOWN)
|
await message.reply(msg, parse_mode=ParseMode.MARKDOWN)
|
||||||
|
|
||||||
|
|
||||||
@dp.message_handler(commands="setkfet")
|
@dp.message_handler(lambda msg: msg.text.lower() == "setkfet")
|
||||||
async def kfet_set(message: types.Message):
|
async def kfet_set(message: types.Message):
|
||||||
user_id = str(message.from_user.id)
|
user_id = str(message.from_user.id)
|
||||||
await message.chat.do(types.ChatActions.TYPING)
|
await message.chat.do(types.ChatActions.TYPING)
|
||||||
logger.info(f"{message.from_user.username} do setkfet command: {message.text}")
|
logger.info(f"{message.from_user.username} do setkfet command")
|
||||||
with dbL:
|
with dbL:
|
||||||
with shelve.open("edt", writeback=True) as db:
|
with shelve.open("edt", writeback=True) as db:
|
||||||
if not 9 < get_now().hour < 14 or not get_now().isoweekday() < 5:
|
if not 9 < get_now().hour < 14 or not get_now().isoweekday() < 5:
|
||||||
msg = lang(db[user_id], "kfet_close")
|
msg = lang(db[user_id], "kfet_close")
|
||||||
else:
|
else:
|
||||||
try:
|
db[user_id].await_cmd = "setkfet"
|
||||||
int(message.text[9:])
|
msg = lang(db[user_id], "kfet_set_await")
|
||||||
except ValueError:
|
|
||||||
msg = lang(db[user_id], "err_num")
|
|
||||||
else:
|
|
||||||
db[user_id].kfet = int(message.text[9:])
|
|
||||||
msg = lang(db[user_id], "kfet_set")
|
|
||||||
await message.reply(msg, parse_mode=ParseMode.MARKDOWN)
|
await message.reply(msg, parse_mode=ParseMode.MARKDOWN)
|
||||||
|
|
||||||
|
|
||||||
|
@ -293,6 +290,15 @@ async def await_cmd(message: types.message):
|
||||||
db[user_id].resources = int(resources)
|
db[user_id].resources = int(resources)
|
||||||
msg = lang(db[user_id], "setedt")
|
msg = lang(db[user_id], "setedt")
|
||||||
|
|
||||||
|
elif db[user_id].await_cmd == "setkfet":
|
||||||
|
try:
|
||||||
|
int(message.text)
|
||||||
|
except ValueError:
|
||||||
|
msg = lang(db[user_id], "err_num")
|
||||||
|
else:
|
||||||
|
db[user_id].kfet = int(message.text)
|
||||||
|
msg = lang(db[user_id], "kfet_set")
|
||||||
|
|
||||||
elif db[user_id].await_cmd in ["time", "cooldown"]:
|
elif db[user_id].await_cmd in ["time", "cooldown"]:
|
||||||
try:
|
try:
|
||||||
value = int(message.text)
|
value = int(message.text)
|
||||||
|
|
Reference in a new issue