mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-18 10:40:03 +08:00
update v0.0.5.0
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
from pathlib import Path
|
||||
from configs.path_config import DATA_PATH
|
||||
import nonebot
|
||||
try:
|
||||
import ujson as json
|
||||
except ModuleNotFoundError:
|
||||
import json
|
||||
|
||||
nonebot.load_plugins("plugins/shop")
|
||||
|
||||
# 修改旧数据
|
||||
|
||||
statistics_group_file = Path(DATA_PATH) / "statistics" / "_prefix_count.json"
|
||||
statistics_user_file = Path(DATA_PATH) / "statistics" / "_prefix_user_count.json"
|
||||
|
||||
for file in [statistics_group_file, statistics_user_file]:
|
||||
if file.exists():
|
||||
with open(file, 'r', encoding='utf8') as f:
|
||||
data = json.load(f)
|
||||
if not (statistics_group_file.parent / f"{file}.bak").exists():
|
||||
with open(f"{file}.bak", 'w', encoding='utf8') as wf:
|
||||
json.dump(data, wf, ensure_ascii=False, indent=4)
|
||||
for x in ['total_statistics', 'day_statistics']:
|
||||
for key in data[x].keys():
|
||||
num = 0
|
||||
if data[x][key].get('我的道具') is not None:
|
||||
num += data[x][key]['我的道具']
|
||||
del data[x][key]['我的道具']
|
||||
if data[x][key].get('使用道具') is not None:
|
||||
num += data[x][key]['使用道具']
|
||||
del data[x][key]['使用道具']
|
||||
if data[x][key].get('我的金币') is not None:
|
||||
num += data[x][key]['我的金币']
|
||||
del data[x][key]['我的金币']
|
||||
if data[x][key].get('购买') is not None:
|
||||
num += data[x][key]['购买']
|
||||
del data[x][key]['购买']
|
||||
if data[x][key].get('商店') is not None:
|
||||
data[x][key]['商店'] += num
|
||||
else:
|
||||
data[x][key]['商店'] = num
|
||||
for x in ['week_statistics', 'month_statistics']:
|
||||
for key in data[x].keys():
|
||||
if key == 'total':
|
||||
if data[x][key].get('我的道具') is not None:
|
||||
num += data[x][key]['我的道具']
|
||||
del data[x][key]['我的道具']
|
||||
if data[x][key].get('使用道具') is not None:
|
||||
num += data[x][key]['使用道具']
|
||||
del data[x][key]['使用道具']
|
||||
if data[x][key].get('我的金币') is not None:
|
||||
num += data[x][key]['我的金币']
|
||||
del data[x][key]['我的金币']
|
||||
if data[x][key].get('购买') is not None:
|
||||
num += data[x][key]['购买']
|
||||
del data[x][key]['购买']
|
||||
if data[x][key].get('商店') is not None:
|
||||
data[x][key]['商店'] += num
|
||||
else:
|
||||
data[x][key]['商店'] = num
|
||||
else:
|
||||
for day in data[x][key].keys():
|
||||
num = 0
|
||||
if data[x][key][day].get('我的道具') is not None:
|
||||
num += data[x][key][day]['我的道具']
|
||||
del data[x][key][day]['我的道具']
|
||||
if data[x][key][day].get('使用道具') is not None:
|
||||
num += data[x][key][day]['使用道具']
|
||||
del data[x][key][day]['使用道具']
|
||||
if data[x][key][day].get('我的金币') is not None:
|
||||
num += data[x][key][day]['我的金币']
|
||||
del data[x][key][day]['我的金币']
|
||||
if data[x][key][day].get('购买') is not None:
|
||||
num += data[x][key][day]['购买']
|
||||
del data[x][key][day]['购买']
|
||||
if data[x][key][day].get('商店') is not None:
|
||||
data[x][key][day]['商店'] += num
|
||||
else:
|
||||
data[x][key][day]['商店'] = num
|
||||
with open(file, 'w', encoding='utf8') as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||
|
||||
|
||||
|
||||
|
||||
+20
-2
@@ -9,8 +9,26 @@ from nonebot.adapters.cqhttp.permission import GROUP
|
||||
from models.goods_info import GoodsInfo
|
||||
|
||||
|
||||
__plugin_name__ = "商店购买"
|
||||
__plugin_usage__ = "格式:购买 [名称或序号] [数量](默认1)\n\t示例:购买 好感双倍加持卡Ⅰ\n\t示例:购买 1 4"
|
||||
__zx_plugin_name__ = "商店 - 购买道具"
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
购买道具
|
||||
指令:
|
||||
购买 [序号或名称] ?[数量=1]
|
||||
示例:购买 好感双倍加持卡Ⅰ
|
||||
示例:购买 1 4
|
||||
""".strip()
|
||||
__plugin_des__ = "商店 - 购买道具"
|
||||
__plugin_cmd__ = ["购买 [序号或名称] ?[数量=1]"]
|
||||
__plugin_type__ = ('商店',)
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = "HibiKier"
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ["商店", "购买道具"],
|
||||
}
|
||||
|
||||
|
||||
buy = on_command("购买", aliases={"购买道具"}, priority=5, block=True, permission=GROUP)
|
||||
|
||||
@@ -5,6 +5,25 @@ from nonebot.adapters.cqhttp.permission import GROUP
|
||||
from utils.data_utils import init_rank
|
||||
from models.bag_user import BagUser
|
||||
|
||||
__zx_plugin_name__ = "商店 - 我的金币"
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
我的金币
|
||||
指令:
|
||||
我的金币
|
||||
""".strip()
|
||||
__plugin_des__ = "商店 - 我的金币"
|
||||
__plugin_cmd__ = ["我的金币"]
|
||||
__plugin_type__ = ('商店',)
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = "HibiKier"
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ["商店", "我的金币"],
|
||||
}
|
||||
|
||||
|
||||
my_gold = on_command("我的金币", priority=5, block=True, permission=GROUP)
|
||||
|
||||
|
||||
@@ -23,21 +23,32 @@ from nonebot.permission import SUPERUSER
|
||||
from nonebot.rule import to_me
|
||||
from datetime import datetime, timedelta
|
||||
from configs.config import NICKNAME
|
||||
from apscheduler.jobstores.base import ConflictingIdError
|
||||
from apscheduler.jobstores.base import JobLookupError
|
||||
import random
|
||||
import time
|
||||
|
||||
|
||||
__plugin_name__ = "金币红包"
|
||||
|
||||
__plugin_usage__ = (
|
||||
"金币红包帮助:\n"
|
||||
"\t塞红包 [金币数] [红包个数](默认5)\n"
|
||||
"示例:\n"
|
||||
"\t塞红包 500 5\n"
|
||||
"抢红包 --> 戳一戳,开\n"
|
||||
"退还剩余红包 --> 退还"
|
||||
)
|
||||
__zx_plugin_name__ = "金币红包"
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
在群内发送指定金额的红包,拼手气项目
|
||||
指令:
|
||||
塞红包 [金币数] ?[红包数=5]: 塞入红包
|
||||
开/抢/*戳一戳*: 打开红包
|
||||
退回: 退回未开完的红包,必须在一分钟后使用
|
||||
示例:塞红包 1000
|
||||
示例:塞红包 1000 10
|
||||
""".strip()
|
||||
__plugin_des__ = "运气项目又来了"
|
||||
__plugin_cmd__ = ["塞红包 [金币数] ?[红包数=5]", "开/抢", "退回"]
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = "HibiKier"
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ["金币红包", "塞红包"],
|
||||
}
|
||||
|
||||
gold_redbag = on_command(
|
||||
"塞红包", aliases={"金币红包"}, priority=5, block=True, permission=GROUP
|
||||
@@ -112,7 +123,7 @@ async def _(bot: Bot, event: GroupMessageEvent, state: T_State):
|
||||
except KeyError:
|
||||
pass
|
||||
msg = get_message_text(event.json())
|
||||
msg = msg.split(" ")
|
||||
msg = msg.split()
|
||||
if len(msg) == 1:
|
||||
flag, amount = await check_gold(event.user_id, event.group_id, msg[0])
|
||||
if not flag:
|
||||
@@ -124,9 +135,13 @@ async def _(bot: Bot, event: GroupMessageEvent, state: T_State):
|
||||
flag, amount = await check_gold(event.user_id, event.group_id, amount)
|
||||
if not flag:
|
||||
await gold_redbag.finish(amount, at_sender=True)
|
||||
if not is_number(num):
|
||||
if not is_number(num) or int(num) < 1:
|
||||
await gold_redbag.finish("红包个数给我输正确啊!", at_sender=True)
|
||||
group_member_num = (await bot.get_group_info(group_id=event.group_id))['member_count']
|
||||
num = int(num)
|
||||
if num > group_member_num:
|
||||
await gold_redbag.send('你发的红包数量也太多了,已经为你修改成与本群人数相同的红包数量...')
|
||||
num = group_member_num
|
||||
nickname = event.sender.card if event.sender.card else event.sender.nickname
|
||||
flag, result = init_redbag(
|
||||
event.user_id, event.group_id, nickname, amount, num, int(bot.self_id)
|
||||
@@ -160,7 +175,7 @@ async def _(bot: Bot, event: GroupMessageEvent, state: T_State):
|
||||
.replace("。", "")
|
||||
)
|
||||
if msg:
|
||||
if msg.find("红包") == -1:
|
||||
if '红包' not in msg:
|
||||
return
|
||||
flag1 = True
|
||||
flag2 = True
|
||||
@@ -280,6 +295,11 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
gl = await bot.get_group_list(self_id=int(bot.self_id))
|
||||
gl = [g["group_id"] for g in gl]
|
||||
for g in gl:
|
||||
try:
|
||||
scheduler.remove_job(f"festive_redbag_{g}")
|
||||
await end_festive_redbag(bot, g)
|
||||
except JobLookupError:
|
||||
pass
|
||||
init_redbag(int(bot.self_id), g, f"{NICKNAME}", amount, num, int(bot.self_id), 1)
|
||||
scheduler.add_job(
|
||||
end_festive_redbag,
|
||||
|
||||
@@ -6,7 +6,24 @@ from models.bag_user import BagUser
|
||||
from nonebot.adapters.cqhttp.permission import GROUP
|
||||
|
||||
|
||||
__plugin_name__ = "商店基础显示"
|
||||
__zx_plugin_name__ = "商店 - 我的道具"
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
我的道具
|
||||
指令:
|
||||
我的道具
|
||||
""".strip()
|
||||
__plugin_des__ = "商店 - 我的道具"
|
||||
__plugin_cmd__ = ["我的道具"]
|
||||
__plugin_type__ = ('商店',)
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = "HibiKier"
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ["商店", "我的道具"],
|
||||
}
|
||||
|
||||
|
||||
my_props = on_command("我的道具", priority=5, block=True, permission=GROUP)
|
||||
|
||||
@@ -3,6 +3,11 @@ from models.bag_user import BagUser
|
||||
from services.log import logger
|
||||
|
||||
|
||||
__zx_plugin_name__ = "每日金币重置 [Hidden]"
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = "HibiKier"
|
||||
|
||||
|
||||
# 重置每日金币
|
||||
@scheduler.scheduled_job(
|
||||
"cron",
|
||||
|
||||
@@ -11,7 +11,41 @@ import os
|
||||
import time
|
||||
|
||||
|
||||
__plugin_name__ = "商店"
|
||||
__zx_plugin_name__ = "商店"
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
商店项目,这可不是奸商
|
||||
指令:
|
||||
商店
|
||||
""".strip()
|
||||
__plugin_superuser_usage__ = """
|
||||
usage:
|
||||
商品操作
|
||||
指令:
|
||||
添加商品 [名称]-[价格]-[描述]-?[折扣](小数)-?[限时时间](分钟)
|
||||
删除商品 [名称或序号]
|
||||
修改商品 -name [名称或序号] -price [价格] -des [描述] -discount [折扣] -time [限时]
|
||||
示例:添加商品-昏睡红茶-300-一杯上好的奇怪红茶-0.9-60
|
||||
示例:删除商品 2
|
||||
示例:修改商品 -name 1 -price 900: 修改序号为1的商品的价格为900
|
||||
* 修改商品只需添加需要值即可 *
|
||||
""".strip()
|
||||
__plugin_des__ = "商店系统[金币回收计划]"
|
||||
__plugin_cmd__ = [
|
||||
"商店",
|
||||
"添加商品 [名称]-[价格]-[描述]-?[折扣](小数)-?[限时时间](分钟) [_superuser]",
|
||||
"删除商品 [名称或序号] [_superuser]",
|
||||
"修改商品 -name [名称或序号] -price [价格] -des [描述] -discount [折扣] -time [限时] [_superuser]",
|
||||
]
|
||||
__plugin_type__ = ('商店',)
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = "HibiKier"
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ["商店"],
|
||||
}
|
||||
|
||||
|
||||
shop_help = on_command("商店", priority=5, block=True)
|
||||
|
||||
@@ -6,14 +6,17 @@ from configs.config import IMPORT_DEFAULT_SHOP_GOODS
|
||||
from nonebot import Driver
|
||||
import nonebot
|
||||
import time
|
||||
import os
|
||||
|
||||
|
||||
driver: Driver = nonebot.get_driver()
|
||||
|
||||
|
||||
# 导入内置商品
|
||||
# 导入内置商品 | 重新生成商店图片
|
||||
@driver.on_startup
|
||||
async def init_default_shop_goods():
|
||||
if os.path.exists(f"{IMAGE_PATH}/shop_help.png"):
|
||||
os.remove(f"{IMAGE_PATH}/shop_help.png")
|
||||
if IMPORT_DEFAULT_SHOP_GOODS:
|
||||
await add_goods(["好感度双倍加持卡Ⅰ", 30, "下次签到双倍好感度概率 + 10%(谁才是真命天子?)(同类商品将覆盖)"])
|
||||
await add_goods(["好感度双倍加持卡Ⅱ", 150, "下次签到双倍好感度概率 + 20%(平平庸庸)(同类商品将覆盖)"])
|
||||
|
||||
@@ -9,9 +9,25 @@ from services.db_context import db
|
||||
from .data_source import effect
|
||||
|
||||
|
||||
__plugin_name__ = "使用道具"
|
||||
__plugin_usage__ = "输入 “使用道具 xxx(序号 或 道具名称)“ 即可使用道具\n【注】序号以我的道具序号为准,更推荐使用道具名称使用道具(怕出错)"
|
||||
|
||||
__zx_plugin_name__ = "商店 - 使用道具"
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
普通的使用道具
|
||||
指令:
|
||||
使用道具 [序号或道具名称]
|
||||
* 序号以 ”我的道具“ 为准 *
|
||||
""".strip()
|
||||
__plugin_des__ = "商店 - 使用道具"
|
||||
__plugin_cmd__ = ["使用道具 [序号或道具名称]"]
|
||||
__plugin_type__ = ('商店',)
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = "HibiKier"
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ["商店", "使用道具"],
|
||||
}
|
||||
|
||||
use_props = on_command("使用道具", priority=5, block=True, permission=GROUP)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user