()
| 157 | |
| 158 | private static normalize() { |
| 159 | const data = this.db?.data as any; |
| 160 | if (!data) return; |
| 161 | // 兼容旧版 monitoredChats: (string|number)[] -> MonitoredChat[] |
| 162 | if (Array.isArray(data.monitoredChats)) { |
| 163 | const first = data.monitoredChats[0]; |
| 164 | if (first && (typeof first === 'string' || typeof first === 'number')) { |
| 165 | data.monitoredChats = (data.monitoredChats as (string|number)[]).map((id) => ({ id: String(id), name: String(id) })); |
| 166 | } |
| 167 | } else { |
| 168 | data.monitoredChats = []; |
| 169 | } |
| 170 | // 确保 bannedStickerIds 存在 |
| 171 | if (!data.bannedStickerIds || typeof data.bannedStickerIds !== 'object') { |
| 172 | data.bannedStickerIds = {}; |
| 173 | } |
| 174 | // 确保 defaultAction 存在 |
| 175 | if (data.defaultAction !== 'delete' && data.defaultAction !== 'ban') { |
| 176 | data.defaultAction = 'delete'; |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | // ==================== 主插件类 ==================== |
| 182 | class ImageMonitorPlugin extends Plugin { |
no outgoing calls
no test coverage detected