axtbot-plugin-remake 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.1
2
+ Name: axtbot-plugin-remake
3
+ Version: 1.0.0
4
+ Summary: 官方插件包之一,通过'/remake'开启你的重开人生
5
+ Author-Email: AxT-Team <shanshui@shanshui.site>
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: datetime
8
+ Description-Content-Type: text/markdown
9
+
10
+ <div align="center">
11
+
12
+ # axtbot-plugin-remake
13
+
14
+ _✨ 官方插件包之一,通过'/remake'开启你的重开人生 ✨_
15
+
16
+ </div>
17
+
18
+ ## 介绍
19
+
20
+ 本插件为官方插件包之一,通过 `/remake` 随机生成你「重开」后的出生地点与身份(物品 / 人物)。每天每位用户仅可重开一次。
21
+
22
+ ## 安装方法
23
+
24
+ <details>
25
+ <summary>使用包管理器安装</summary>
26
+ 在项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
27
+
28
+ <details>
29
+ <summary>pip</summary>
30
+
31
+ pip install axtbot-plugin-remake
32
+ </details>
33
+ <details>
34
+ <summary>pdm</summary>
35
+
36
+ pdm add axtbot-plugin-remake
37
+ </details>
38
+ <details>
39
+ <summary>poetry</summary>
40
+
41
+ poetry add axtbot-plugin-remake
42
+ </details>
43
+ </details>
44
+
45
+ <details>
46
+ <summary>使用源码安装</summary>
47
+ 在项目的插件目录下,打开命令行,输入以下内容
48
+ ```bash
49
+ git clone https://github.com/AxT-Team/axtbot-plugin-remake
50
+ ```
51
+
52
+ 把本文件夹拷贝至插件目录下即可。
53
+
54
+ </details>
55
+
56
+ ## 配置
57
+
58
+ 本插件需要在 `.env` 中补充以下配置(不填则使用默认值,可直接运行):
59
+
60
+ ```bash
61
+ REMAKE_CUSTOM=false # 是否启用自定义模式
62
+ REMAKE_CUSTOM_LOCATION="上海·AxT社区" # 自定义重开地点
63
+ REMAKE_CUSTOM_OBJECTS="Darf" # 自定义重开身份(物品/人物)
64
+ REMAKE_DEFAULT_DATABASE="./data/remake.db" # 存储重开记录的数据库文件
65
+ ```
66
+
67
+ > 默认地点 / 身份池位于插件内 `remake_default_set`,首次运行时会自动写入 `./data/remake.json`,可自行修改该文件以自定义随机池(需关闭 `REMAKE_CUSTOM`)。
@@ -0,0 +1,58 @@
1
+ <div align="center">
2
+
3
+ # axtbot-plugin-remake
4
+
5
+ _✨ 官方插件包之一,通过'/remake'开启你的重开人生 ✨_
6
+
7
+ </div>
8
+
9
+ ## 介绍
10
+
11
+ 本插件为官方插件包之一,通过 `/remake` 随机生成你「重开」后的出生地点与身份(物品 / 人物)。每天每位用户仅可重开一次。
12
+
13
+ ## 安装方法
14
+
15
+ <details>
16
+ <summary>使用包管理器安装</summary>
17
+ 在项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
18
+
19
+ <details>
20
+ <summary>pip</summary>
21
+
22
+ pip install axtbot-plugin-remake
23
+ </details>
24
+ <details>
25
+ <summary>pdm</summary>
26
+
27
+ pdm add axtbot-plugin-remake
28
+ </details>
29
+ <details>
30
+ <summary>poetry</summary>
31
+
32
+ poetry add axtbot-plugin-remake
33
+ </details>
34
+ </details>
35
+
36
+ <details>
37
+ <summary>使用源码安装</summary>
38
+ 在项目的插件目录下,打开命令行,输入以下内容
39
+ ```bash
40
+ git clone https://github.com/AxT-Team/axtbot-plugin-remake
41
+ ```
42
+
43
+ 把本文件夹拷贝至插件目录下即可。
44
+
45
+ </details>
46
+
47
+ ## 配置
48
+
49
+ 本插件需要在 `.env` 中补充以下配置(不填则使用默认值,可直接运行):
50
+
51
+ ```bash
52
+ REMAKE_CUSTOM=false # 是否启用自定义模式
53
+ REMAKE_CUSTOM_LOCATION="上海·AxT社区" # 自定义重开地点
54
+ REMAKE_CUSTOM_OBJECTS="Darf" # 自定义重开身份(物品/人物)
55
+ REMAKE_DEFAULT_DATABASE="./data/remake.db" # 存储重开记录的数据库文件
56
+ ```
57
+
58
+ > 默认地点 / 身份池位于插件内 `remake_default_set`,首次运行时会自动写入 `./data/remake.json`,可自行修改该文件以自定义随机池(需关闭 `REMAKE_CUSTOM`)。
@@ -0,0 +1,73 @@
1
+ [project]
2
+ name = "axtbot-plugin-remake"
3
+ version = "1.0.0"
4
+ description = "官方插件包之一,通过'/remake'开启你的重开人生"
5
+ authors = [
6
+ { name = "AxT-Team", email = "shanshui@shanshui.site" },
7
+ ]
8
+ dependencies = [
9
+ "datetime",
10
+ ]
11
+ requires-python = ">=3.11"
12
+ readme = "README.md"
13
+
14
+ [project.entry-points."axtbot.plugins"]
15
+ example = "axtbot_plugin_remake:__meta__"
16
+
17
+ [build-system]
18
+ requires = [
19
+ "pdm-backend",
20
+ ]
21
+ build-backend = "pdm.backend"
22
+
23
+ [tool.pdm]
24
+ distribution = true
25
+
26
+ [tool.pdm.build]
27
+ includes = [
28
+ "src",
29
+ ]
30
+
31
+ [tool.pdm.dev-dependencies]
32
+ dev = [
33
+ "black>=24.4.2",
34
+ "isort>=5.13.2",
35
+ ]
36
+
37
+ [tool.pdm.scripts]
38
+ test = "python -c 'print(\">>> Just \\\"pytest -W ignore -s\\\" when you complete your testsuite\")'"
39
+
40
+ [tool.pdm.scripts.format]
41
+ composite = [
42
+ "isort . ",
43
+ "black . ",
44
+ ]
45
+
46
+ [tool.black]
47
+ line-length = 90
48
+ target-version = [
49
+ "py39",
50
+ "py310",
51
+ "py311",
52
+ "py312",
53
+ ]
54
+ include = "\\.pyi?$"
55
+
56
+ [tool.isort]
57
+ profile = "black"
58
+ line_length = 90
59
+ length_sort = true
60
+ skip_gitignore = true
61
+ force_sort_within_sections = true
62
+ extra_standard_library = [
63
+ "typing_extensions",
64
+ ]
65
+
66
+ [tool.pyright]
67
+ pythonVersion = "3.9"
68
+ pythonPlatform = "All"
69
+ typeCheckingMode = "basic"
70
+ plugin_dirs = [
71
+ ".",
72
+ ]
73
+ builtin_plugins = []
@@ -0,0 +1,119 @@
1
+ import datetime, random, sqlite3, os, json
2
+
3
+ from app import on_command
4
+ from app.classes import Message, Markdown, Keyboard, PluginMetadata
5
+ from app.modules import logger, get_plugin_config
6
+
7
+ from .config import RemakeConfig
8
+ from .keyboard import kb
9
+
10
+ __meta__ = PluginMetadata(
11
+ name="重开模拟器",
12
+ version="1.0.0",
13
+ author="AxT-Team",
14
+ description="你要重开吗(",
15
+ official=True,
16
+ )
17
+
18
+ config = get_plugin_config(RemakeConfig, prefix="REMAKE_")
19
+
20
+ # ----------------------------预设值---------------------------- 开始
21
+
22
+ remake_default_set = {
23
+ "locations": [
24
+ "东京,日本", "巴黎,法国", "纽约,美国", "伦敦,英国", "北京,中国", "悉尼,澳大利亚",
25
+ "洛杉矶,美国", "上海,中国", "巴西", "开罗,埃及", "马德里,西班牙", "墨尔本,澳大利亚",
26
+ "阿姆斯特丹,荷兰", "柏林,德国", "莫斯科,俄罗斯", "新德里,印度", "曼谷,泰国", "伊斯坦布尔,土耳其",
27
+ "雅加达,印度尼西亚", "罗马,意大利", "香港,中国", "台北,台湾", "吉隆坡,马来西亚", "迪拜,阿联酋",
28
+ "拉斯维加斯,美国", "开普敦,南非", "布宜诺斯艾利斯,阿根廷", "墨西哥城,墨西哥", "圣保罗,巴西",
29
+ "圣彼得堡,俄罗斯", "曼谷,泰国", "吉达,沙特阿拉伯", "卡萨布兰卡,摩洛哥", "卡尔加里,加拿大",
30
+ "新加坡,新加坡", "巴黎岛,印尼", "巴黎的近郊(如凡尔赛),法国", "孟买,印度", "温哥华,加拿大"
31
+ ],
32
+ "objects": [
33
+ "沙子", "玻璃", "电线", "电池", "油漆", "砖块", "橡胶", "铁矿", "黄金", "钻石", "煤炭", "塑料", "木板",
34
+ "石灰石", "水桶", "木雕", "陶器", "皮革", "绸缎", "银器", "玻璃瓶", "钢铁", "木箱", "塑料袋", "镜子",
35
+ "手电筒", "书本", "背包", "手表", "手机", "钥匙", "鞋子", "帽子", "腰带", "手套", "眼镜", "雨伞", "钓鱼竿",
36
+ "狮子", "老虎", "大象", "长颈鹿", "袋鼠", "熊猫", "海豚", "鲨鱼", "鲸鱼", "狼", "狐狸", "兔子", "鹿", "野猪",
37
+ "猴子", "大猩猩", "鹦鹉", "鹰", "鸽子", "蛇", "鳄鱼", "蜥蜴", "乌龟", "海龟", "蚂蚁", "蜜蜂", "蝴蝶", "苍蝇",
38
+ "蜻蜓", "蚊子", "螳螂", "章鱼", "螃蟹", "海星", "海胆", "鲸鲨", "珊瑚", "虾", "鳗鱼", "鳍足动物", "斑马",
39
+ "阿尔伯特·爱因斯坦", "玛丽·居里", "李白", "莎士比亚", "达芬奇", "达芬", "爱迪生", "丘吉尔", "比尔·盖茨",
40
+ "史蒂夫·乔布斯", "林肯·佩里", "贝多芬", "巴赫", "齐白石", "尼尔·阿姆斯特朗", "奥黛丽·赫本", "马云",
41
+ "唐纳德·特朗普", "弗朗茨·卡夫卡", "迈克尔·杰克逊", "李光耀", "彭博", "卡尔·马克思"
42
+ ]
43
+ }
44
+
45
+ # ----------------------------预设值---------------------------- 结束
46
+
47
+
48
+ @on_command("remake")
49
+ async def remake_handler(event: Message):
50
+ user_id = event.author.member_openid or event.author.union_openid
51
+ result = await remake(user_id)
52
+ result = "## AxTBot | 重开模拟器\n" + result
53
+ await event.reply(markdown=Markdown(content=result), keyboard=Keyboard(content=kb), quote=False)
54
+
55
+
56
+ # ----------------------------主代码---------------------------- 开始
57
+ async def remake(member_id):
58
+ await update_database() # 更新数据表
59
+ return await update_db(member_id) # 写数据库
60
+
61
+
62
+ async def get_remake_data():
63
+ if config.custom:
64
+ location, objects = config.custom_location, config.custom_objects
65
+ else:
66
+ if not os.path.exists("./data/remake.json"):
67
+ os.makedirs("./data", exist_ok=True)
68
+ with open('./data/remake.json', 'w', encoding='utf-8') as file:
69
+ json.dump(remake_default_set, file, ensure_ascii=False, indent=4)
70
+ with open('./data/remake.json', 'r', encoding='utf-8') as file:
71
+ data = json.load(file)
72
+ location = random.choice(data["locations"])
73
+ objects = random.choice(data["objects"])
74
+ return location, objects
75
+
76
+
77
+ async def update_db(memid): # 写数据库信息
78
+ current_date = datetime.datetime.now().strftime("%Y%m%d") # 获取系统时间
79
+ conn = sqlite3.connect(config.default_database) # 链接db
80
+ cursor = conn.cursor() # 指针选中
81
+ table_name = f"重开表_{current_date}" # 切换表头到当日时间
82
+ cursor.execute(
83
+ f"CREATE TABLE IF NOT EXISTS {table_name} (id TEXT PRIMARY KEY, location TEXT, objects TEXT)"
84
+ ) # 创建表
85
+
86
+ # 查询是否存在此人的信息记录
87
+ result = cursor.execute(
88
+ f"SELECT location, objects FROM {table_name} WHERE id = ?", (memid,)
89
+ ).fetchone()
90
+
91
+ if result: # 如果已经有记录
92
+ location, objects = result
93
+ conn.close() # 关闭数据库
94
+ return f"""> 您今天已经重开过啦!再重开的话天堂就要过载啦!
95
+ > 您今天重开的地点是: **{location}**,是 **{objects}**"""
96
+ else: # 此人不在数据库中有记录
97
+ location, objects = await get_remake_data()
98
+ cursor.execute(
99
+ f"INSERT INTO {table_name} (id, location, objects) VALUES (?, ?, ?)", (memid, location, objects)
100
+ ) # 插入信息
101
+ conn.commit() # 提交
102
+ conn.close() # 关闭
103
+ return f"""> 重开成功!祝您重开愉快!
104
+ > 您重开的地点是:**{location}**,是:**{objects}**"""
105
+
106
+
107
+ # 更新数据库
108
+ async def update_database():
109
+ current_date = datetime.datetime.now().strftime("%Y%m%d") # 当日时间
110
+ conn = sqlite3.connect(config.default_database) # 链接remake.db
111
+ cursor = conn.cursor() # 指针
112
+ table_name = f"重开表_{current_date}" # 列表
113
+ cursor.execute(
114
+ f"CREATE TABLE IF NOT EXISTS {table_name} (id TEXT PRIMARY KEY, location TEXT, objects TEXT)"
115
+ ) # 创建表
116
+ conn.commit() # 提交
117
+ conn.close() # 关闭
118
+
119
+ # ----------------------------主代码---------------------------- 结束
@@ -0,0 +1,13 @@
1
+ from pydantic import BaseModel
2
+
3
+
4
+ class RemakeConfig(BaseModel):
5
+ """重开模拟器插件配置,可通过 .env 中 REMAKE_ 前缀的环境变量覆盖"""
6
+
7
+ # 自定义开关(打开时,custom_location / custom_objects 生效)
8
+ custom: bool = False
9
+ custom_location: str = "上海·AxT社区"
10
+ custom_objects: str = "Darf"
11
+
12
+ # 数据库名称
13
+ default_database: str = "./data/remake.db"
@@ -0,0 +1,39 @@
1
+ kb = {
2
+ "rows": [
3
+ {
4
+ "buttons": [
5
+ {
6
+ "id": "remake:roll",
7
+ "render_data": {
8
+ "label": "我要重开",
9
+ "style": 0
10
+ },
11
+ "action": {
12
+ "type": 2,
13
+ "data": "/remake",
14
+ "reply": False,
15
+ "enter": True,
16
+ "permission": {
17
+ "type": 2
18
+ }
19
+ }
20
+ },
21
+ {
22
+ "id": "remake:list",
23
+ "render_data": {
24
+ "label": "命令列表",
25
+ "visited_label": "命令列表",
26
+ "style": 1
27
+ },
28
+ "action": {
29
+ "type": 0,
30
+ "data": "https://m.q.qq.com/a/5cf068a222ca245be83fc91a03de03be",
31
+ "permission": {
32
+ "type": 2
33
+ }
34
+ }
35
+ }
36
+ ]
37
+ }
38
+ ]
39
+ }