Skip to content

Commit

Permalink
kk指令可自定义天数
Browse files Browse the repository at this point in the history
  • Loading branch information
dddddluo committed Mar 23, 2024
1 parent 6bcbf07 commit 60b8a9b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def save_config():
tz_id = config.tz_id

w_anti_chanel_ids = config.w_anti_chanel_ids
kk_gift_days = config.kk_gift_days
save_config()

LOGGER.info("配置文件加载完毕")
Expand Down
3 changes: 2 additions & 1 deletion bot/func_helper/fix_bottons.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pyrogram.types import InlineKeyboardMarkup
from pyromod.helpers import ikb, array_chunk
from bot import chanel, main_group, bot_name, extra_emby_libs, tz_id, tz_ad, tz_api, _open, user_buy, sakura_b, \
schedall
schedall, config
from bot.func_helper import nezha_res
from bot.func_helper.emby import emby
from bot.func_helper.utils import judge_admins, members_info
Expand Down Expand Up @@ -216,6 +216,7 @@ def config_preparation() -> InlineKeyboardMarkup:
[('💠 emby线路', 'set_line'), ('🎬 显/隐指定库', 'set_block')],
[(f'{code} 注册码续期', 'open_allow_code'), (f'{buy_stat} 开关购买', 'set_buy')],
[(f'{leave_ban} 退群封禁', 'leave_ban'), (f'{uplays} 自动看片结算', 'set_uplays')],
[(f'设置赠送资格天数({config.kk_gift_days}天)', 'set_kk_gift_days')],
[('🔙 返回', 'manage')]])
return keyboard

Expand Down
29 changes: 29 additions & 0 deletions bot/modules/panel/config_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,32 @@ async def open_leave_ban(_, call):
await config_p_re(_, call)
save_config()
LOGGER.info(f"【admin】:管理员 {call.from_user.first_name} 已调整 看片榜结算 True")


@bot.on_callback_query(filters.regex('set_kk_gift_days') & admins_on_filter)
async def set_kk_gift_days(_, call):
await callAnswer(call, '📌 设置赠送资格天数')
send = await editMessage(call,
f"🤝【设置kk赠送资格】\n\n请输入一个数字\n取消点击 /cancel\n\n当前赠送资格天数: {config.kk_gift_days}")
if send is False:
return
txt = await callListen(call, 120, back_set_ikb('set_kk_gift_days'))
if txt is False:
return

elif txt.text == '/cancel':
await txt.delete()
await editMessage(call, '__您已经取消输入__ **会话已结束!**', buttons=back_set_ikb('set_kk_gift_days'))
else:
await txt.delete()
try:
days = int(txt.text)
except ValueError:
await editMessage(call, f"请注意格式! 您的输入如下: \n\n`{txt.text}`", buttons=back_set_ikb('set_kk_gift_days'))
else:
config.kk_gift_days = days
save_config()
await editMessage(call,
f"🤝 【赠送资格天数】\n\n{days}天 **Done!**",
buttons=back_config_p_ikb)
LOGGER.info(f"【admin】:{call.from_user.id} - 更新赠送资格天数完成")
4 changes: 2 additions & 2 deletions bot/modules/panel/kk.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pyrogram
from pyrogram import filters
from pyrogram.errors import BadRequest
from bot import bot, prefixes, owner, bot_photo, admins, LOGGER, extra_emby_libs
from bot import bot, prefixes, owner, bot_photo, admins, LOGGER, extra_emby_libs, config
from bot.func_helper.emby import emby
from bot.func_helper.filters import admins_on_filter
from bot.func_helper.fix_bottons import cr_kk_ikb, gog_rester_ikb
Expand Down Expand Up @@ -171,7 +171,7 @@ async def gift(_, call):
first = await bot.get_chat(b)
e = sql_get_emby(tg=b)
if e.embyid is None:
link = await cr_link_two(tg=call.from_user.id, for_tg=b, days=30)
link = await cr_link_two(tg=call.from_user.id, for_tg=b, days=config.kk_gift_days)
await editMessage(call, f"🌟 好的,管理员 [{call.from_user.first_name}](tg://user?id={call.from_user.id})\n"
f'已为 [{first.first_name}](tg://user?id={b}) 赠予资格。前往bot进行下一步操作:',
buttons=gog_rester_ikb(link))
Expand Down
2 changes: 2 additions & 0 deletions bot/schemas/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class Config(BaseModel):
# w_anti_chanel_ids: Optional[List[str | int]] = []
w_anti_chanel_ids: Optional[List[Union[str, int]]] = []
proxy: Optional[Proxy] = Proxy()
# kk指令中赠送资格的天数
kk_gift_days: int = 30

def __init__(self, **data):
super().__init__(**data)
Expand Down

0 comments on commit 60b8a9b

Please sign in to comment.