1
- # -*- coding: utf-8 -*-
2
- # @Author : 辉夜sama
3
-
4
- # @Github : https://github.com/Kaguya233qwq
5
- import datetime
1
+ from .src import nonebot_plugin_sky as nonebot_plugin_sky
6
2
7
- from nonebot import logger , on_command
8
- from nonebot .plugin import PluginMetadata
9
- from nonebot .params import CommandArg
10
- from nonebot .adapters .onebot .v11 import (
11
- Message ,
12
- )
13
- from nonebot .permission import SUPERUSER
14
-
15
- from .config .command import *
16
- from .config .msg_forward import *
17
- from .utils .bot_loader import Config
18
- from .utils import clear_cache
19
- from .utils .check_update import *
20
- from .utils .data_pack import *
21
- from .utils .notice_board import *
22
- from .config .travelling_cache import *
23
- from .tools .scheduler import *
24
-
25
- RemainCN = on_command ("remain -cn" , aliases = get_cmd_alias ("remain_cn" ))
26
- RemainIN = on_command ("remain -in" , aliases = get_cmd_alias ("remain_in" ))
27
- Clear = on_command (
28
- "sky_clear_cache" , aliases = get_cmd_alias ("sky_clear_cache" ), permission = SUPERUSER
29
- )
30
-
31
- from .handler import Handler
32
-
33
- # 国服每日任务
34
- on_command (
35
- "sky -cn" ,
36
- aliases = get_cmd_alias ("sky_cn" ),
37
- handlers = [Handler .chinese_server_daily_handler ],
38
- )
39
-
40
- # 国际服每日任务
41
- on_command (
42
- "sky -in" ,
43
- aliases = get_cmd_alias ("sky_in" ),
44
- handlers = [Handler .international_server_daily_handler ],
45
- )
46
-
47
- # 国服旅行先祖
48
- on_command (
49
- "tss -cn" ,
50
- aliases = get_cmd_alias ("travel_cn" ),
51
- handlers = [Handler .chinese_server_travelling_spirit_handler ],
52
- )
53
-
54
- # 游戏公告
55
- on_command (
56
- "notice" ,
57
- aliases = get_cmd_alias ("sky_notice" ),
58
- handlers = [Handler .get_public_notice_handler ],
59
- )
60
-
61
- # 排队
62
- on_command (
63
- "queue" ,
64
- aliases = get_cmd_alias ("sky_queue" ),
65
- handlers = [Handler .get_queue_state_handler ],
66
- )
67
-
68
- # 菜单
69
- on_command ("Sky" , aliases = get_cmd_alias ("sky_menu" ), handlers = [Handler .menu_handler ])
70
-
71
-
72
- def remain (
73
- season_name : str ,
74
- year : int ,
75
- month : int ,
76
- day : int ,
77
- hour : int ,
78
- minute : int ,
79
- second : int ,
80
- ) -> str :
81
- """
82
- 通用季节倒计时
83
- """
84
-
85
- # @Author : ZQDesigned
86
-
87
- # @Github : ZQDesigned
88
- # @Software: IDEA Ultimate 2022.3.1
89
-
90
- # 定义剩余时间
91
- deadline = datetime (year , month , day , hour , minute , second )
92
- # 获取当前时间
93
- now = datetime .now ()
94
- # 判断当前时间是否大于截止时间
95
- if now > deadline :
96
- return "季节已经过去了,下一个季节还有一段时间呢"
97
- else :
98
- # 计算剩余时间
99
- remain_time = deadline - now
100
- # 获取天数
101
- days = remain_time .days
102
- # 获取小时
103
- hours = remain_time .seconds // 3600
104
- # 获取分钟
105
- minutes = remain_time .seconds % 3600 // 60
106
- # 获取秒
107
- seconds = remain_time .seconds % 3600 % 60
108
- # 发送剩余时间
109
- return f"距离{ season_name } 结束还有{ days } 天{ hours } 小时{ minutes } 分钟{ seconds } 秒"
110
-
111
-
112
- @RemainCN .handle ()
113
- async def remain_cn ():
114
- results = remain ("夜行季国服" , 2023 , 7 , 19 , 00 , 00 , 00 )
115
- await RemainIN .send (results )
116
-
117
-
118
- @RemainIN .handle ()
119
- async def remain_in ():
120
- results = remain ("夜行季国际服" , 2023 , 6 , 25 , 15 , 00 , 00 )
121
- await RemainIN .send (results )
122
-
123
-
124
- @Clear .handle ()
125
- async def _ (args : Message = CommandArg ()):
126
- """
127
- 清理缓存
128
-
129
- - 指令名: 清理缓存
130
- - 可用参数:
131
- - day: 指定清理缓存时间段x天前,默认为30
132
- - f: 忽略上次清理时间间隔,强制执行清理
133
- - 传参方式:http params形式
134
- - 示例:day=30&force
135
- """
136
- plain_text = args .extract_plain_text ().strip ()
137
- day = 30
138
- f = False
139
- if plain_text :
140
- try :
141
- plain_text = plain_text .lower ()
142
- arg_list = plain_text .split ("&" )
143
- for arg in arg_list :
144
- if arg .startswith ("day=" ):
145
- day = int (arg .strip ()[4 :])
146
- elif arg == "f" or arg == "force" :
147
- f = True
148
- except Exception as exp :
149
- logger .error (plain_text , Exception = exp )
150
- await Clear .finish ("参数解析错误" )
151
- return
152
- if f :
153
- msg = f"开始强制清理{ day } 天前的数据"
154
- else :
155
- msg = f"开始清理{ day } 天前的数据"
156
- await Clear .send (msg )
157
- num = clear_cache (day , f )
158
- await Clear .finish (f"清理{ day } 天前的缓存数据,共{ num } 条完成" )
159
-
160
-
161
- # nonebot的插件元数据标准
162
- __plugin_meta__ = PluginMetadata (
163
- name = "Sky光遇" ,
164
- description = "光遇的每日任务及活动相关查询插件" ,
165
- usage = """
166
- 基本命令:
167
- 光遇菜单 -> 查看插件菜单图
168
- 今日国服 -> 查看今日国服任务
169
- 今日国际服 -> 查看今日国际服任务
170
- 国服复刻 -> 查询国服复刻先祖信息
171
- 国际服复刻 -> 查询国际服复刻先祖信息
172
-
173
- 数据包命令:
174
- 安装数据包 -> 从gitee拉取可用的静态攻略资源包
175
- 菜单v2 -> 查看所有数据包命令
176
- [命令起始符]-[命令] -> 执行数据包命令
177
- """ ,
178
- config = Config ,
179
- type = "application" ,
180
- extra = {"author" : "Kaguya姬辉夜" , "version" : "3.0.0" },
181
- homepage = "https://github.com/Kaguya233qwq/nonebot_plugin_sky" ,
182
- supported_adapters = {"~onebot.v11" },
183
- )
3
+ # 这是为了本地更好的开发和导入
0 commit comments