├── .gitignore ├── LICENSE ├── README.md ├── apps ├── Group.js ├── Install.js ├── List.js ├── Manager.js ├── help.js ├── regTest.js └── update.js ├── config └── .keep ├── defSet ├── auth │ └── set.yaml ├── exclude │ └── set.yaml ├── group │ └── set.yaml ├── help │ └── set.yaml ├── js │ └── set.yaml ├── lexicon │ └── set.yaml └── version │ └── set.yaml ├── guoba.support.js ├── index.js ├── module ├── base.js ├── config.js ├── help.js ├── install.js ├── list.js ├── loader.js ├── uninstall.js └── version.js ├── package.json └── resources ├── font ├── HYWenHei-55W.ttf └── tttgbnumber.ttf ├── html ├── help │ ├── help.css │ └── help.html ├── list │ ├── list.css │ └── list.html └── version │ ├── version.css │ └── version.html └── img ├── bg.jpg ├── head.jpg ├── icon.png ├── icon ├── batch.png ├── clear.png ├── command.png ├── create.png ├── debug.png ├── delete.png ├── disable.png ├── enable.png ├── find.png ├── fuldelete.png ├── gplist.png ├── help.png ├── install.png ├── list.png ├── log.png ├── look.png ├── remove.png ├── rename.png ├── restore.png ├── set.png ├── sync.png ├── update.png ├── upload.png └── version.png ├── list ├── body.jpg └── head.jpg └── suffix ├── bak.png ├── folder.png ├── js.png └── unknown.png /.gitignore: -------------------------------------------------------------------------------- 1 | config/ 2 | node_modules/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![logo](resources/img/head.jpg) 2 |
3 | 4 | 5 | 6 | 7 |
8 | 9 | # 插件管理器xitian-plugin 10 | 11 | 仅支持js类插件管理,~~不支持喵喵插件等大型插件管理~~ 12 | 13 | 支持了一点,但不多(bushi) 14 | 15 | ## 已经实现的功能 16 | 17 | - [x] 插件管理 18 | - [x] 查看全部插件 19 | - [x] 插件启用停用 20 | - [x] 插件删除恢复 21 | - [x] 插件重命名 22 | - [x] 插件查找 23 | - [x] 查看插件 24 | - [x] 插件分组管理 25 | - [x] 创建删除分组 26 | - [x] 插件设置分组 27 | - [x] 同步plugins目录下的分组 28 | - [x] 命令 29 | - [x] 命令总览 30 | - [x] 测试命令 31 | - [x] 插件智能覆盖安装 32 | - [x] 插件智能重命名 33 | - [x] 更新插件 34 | - [x] 插件管理权限控制 35 | - [x] 插件核验 36 | - [x] V2插件识别 37 | - [x] plugin插件管理 38 | - [x] 插件通过网址安装 39 | - [x] 删除git插件 40 | 41 | ### 介绍 42 | Yunzai-Bot V3 的插件 43 | 为用户提供插件管理功能 44 | js插件可以从[插件库](https://gitee.com/Hikari666/Yunzai-Bot-plugins-index)或其他渠道获取 45 | 46 | ## 使用说明 47 | 48 | ### 安装 49 | 50 | 在[yunzai-bot](https://gitee.com/Le-niao/Yunzai-Bot)文件夹根目录打开cmd 51 | 52 | 使用[github仓库](https://github.com/XiTianGame/xitian-plugin) 53 | ```bash 54 | git clone --depth=1 https://github.com/XiTianGame/xitian-plugin.git ./plugins/xitian-plugin/ 55 | ``` 56 | 57 | 使用[gitee仓库](https://gitee.com/XiTianGame/xitian-plugin)(可能更新不及时) 58 | ```bash 59 | git clone --depth=1 https://gitee.com/XiTianGame/xitian-plugin.git ./plugins/xitian-plugin/ 60 | ``` 61 | 62 | ### 安装依赖 63 | 64 | ```bash 65 | pnpm install --filter=xitian-plugin 66 | ``` 67 | ps:插件管理器会自动进行依赖安装 68 | 69 | ### 帮助 70 | 71 | 插件加载完成后发送#插件帮助可以获取命令图 72 | 73 | ### 更新 74 | 75 | 发送#插件更新进行插件管理器更新 76 | 77 | 或者在xitian-plugin目录打开cmd手动`git pull` 78 | 79 | ### 链接 80 | 81 | - [云崽](https://gitee.com/Le-niao/Yunzai-Bot) 82 | - [插件库](https://gitee.com/yhArcadia/Yunzai-Bot-plugins-index) 83 | 84 | ### 指令 85 | 86 | | 功能 | 指令 | 作用 | 87 | |----|----|----| 88 | | 安装plugin插件 | #安装插件+仓库地址 | 从plugin仓库中克隆插件 | 89 | | (批量)安装插件 | #(批量)安装插件 | 通过QQ发送一个或多个js插件来安装 | 90 | | 停用/启用插件 | #停用/启用插件 | 暂时停用或启用一个插件 | 91 | | 删除/恢复插件 | #删除/恢复插件 | 暂时将一个插件扔到回收站 | 92 | | 删除plugin插件 | #删除插件+插件名(如xitian-plugin) | 删除plugin插件所有文件 | 93 | | 彻底删除插件 | #彻底插件 | 将一个插件彻底删除 | 94 | | 创建/删除分组 | #创建/删除分组 | 创建或删除一个插件分组 | 95 | | (插件)设置分组 | #(插件)设置分组 | 设置一个插件的分组,便于管理 | 96 | | 插件更新 | #插件(管理器)更新 | 更新插件管理器 | 97 | | 插件帮助 | #插件(管理器)帮助 | 查看所有的指令 | 98 | 99 | ### 其他 100 | 101 | - 素材来源于网络,仅供交流学习使用 102 | - 严禁用于商业和非法用途 103 | - 暂无群号,出现问题可以提交issue(建议github,因为有邮件提醒) 104 | - 最后求个star~ 105 | 106 | [![Star History Chart](https://api.star-history.com/svg?repos=XiTianGame/xitian-plugin&type=Date)](https://star-history.com/#XiTianGame/xitian-plugin&Date) -------------------------------------------------------------------------------- /apps/Group.js: -------------------------------------------------------------------------------- 1 | import plugin from '../../../lib/plugins/plugin.js' 2 | import config from '../module/config.js' 3 | import loader from '../module/loader.js' 4 | import PATH from 'node:path' 5 | import fs from 'node:fs' 6 | 7 | const WAITFLAG = Symbol('WAITFLAG') 8 | 9 | export class Group extends plugin { 10 | constructor() { 11 | super({ 12 | name: '分组', 13 | dsc: '提供js插件分组管理', 14 | /** https://oicqjs.github.io/oicq/#events */ 15 | event: 'message', 16 | priority: 5, 17 | rule: [ 18 | { 19 | reg: '^#分组列表$', 20 | fnc: 'list' 21 | }, 22 | { 23 | reg: '^#创建分组(.*)$', 24 | fnc: 'new' 25 | }, 26 | { 27 | reg: '^#删除分组(.*)$', 28 | fnc: 'del' 29 | }, 30 | { 31 | reg: '^#(.*)设置分组(.*)$', 32 | fnc: 'set' 33 | }, 34 | { 35 | reg: '^#同步分组$', 36 | fnc: 'sync' 37 | } 38 | ] 39 | }) 40 | } 41 | 42 | get groups() { 43 | return config.getConfig('group', 'set') 44 | } 45 | 46 | get exclude() { 47 | return config.getConfig('exclude', 'set') 48 | } 49 | 50 | get config() { 51 | return config.getConfig('js', 'set') 52 | } 53 | 54 | async list(e) { 55 | if (!config.auth(e)) { 56 | return true 57 | } 58 | 59 | let msg = ['====分组列表===='] 60 | this.groups.group.forEach(item => { 61 | msg.push(`\n${item}`) 62 | }) 63 | e.reply(msg) 64 | return true 65 | } 66 | 67 | async new(e) { 68 | if (!config.auth(e)) { 69 | return true 70 | } 71 | 72 | let group = e.msg.replace('#创建分组', ''); 73 | if (this.groups.group.includes(group)) { 74 | e.reply('已经存在该分组了') 75 | return true 76 | } 77 | const path = PATH.join('./plugins', group) 78 | const groups = this.groups 79 | groups.group.push(group) 80 | config.saveSet('group', 'set', 'config', groups) 81 | if (!fs.existsSync(path)) { 82 | fs.mkdirSync(path) 83 | } 84 | e.reply('创建分组成功') 85 | return true 86 | } 87 | 88 | async del(e) { 89 | if (!config.auth(e)) { 90 | return true 91 | } 92 | 93 | let group = e.msg.replace('#删除分组', '') 94 | //删除路径 95 | let path = PATH.join('./plugins', group) 96 | if (fs.existsSync(path) && fs.statSync(path).isDirectory()) { 97 | if (fs.readdirSync(path).length > 0) { 98 | e.reply('该分组内不为空,请清理分组内插件后重试') 99 | return true 100 | } else { 101 | fs.rmdirSync(path) 102 | } 103 | } else { 104 | e.reply('不存在该分组文件夹哦~'); 105 | } 106 | //判断一下分组的位置 107 | if (this.groups.group.includes(group)) { 108 | const groups = this.groups 109 | groups.group = groups.group.filter(g => g !== group) 110 | config.saveSet('group', 'set', 'config', groups) 111 | e.reply('删除成功!') 112 | } else { 113 | e.reply('不存在该分组配置') 114 | } 115 | return true; 116 | } 117 | 118 | async set(e) { 119 | if (!config.auth(e)) { 120 | return true 121 | } 122 | 123 | let keyword = e.msg.replace('#', '').split('设置分组'); 124 | if(!this.groups.group.includes(keyword[1])) { 125 | e.reply(`不存在分组< ${keyword[1]} >`) 126 | return true 127 | } 128 | //获取全部分组 129 | let tmp 130 | if (e[WAITFLAG]) { 131 | const index = Number(this.e.msg) 132 | if (Number.isNaN(index)) { 133 | this.e.reply('请发送序号数字') 134 | return true 135 | } 136 | if (index > e[WAITFLAG].length) { 137 | this.e.reply(`序号需要在0-${e[WAITFLAG].length}内,收到:${index}`) 138 | return true 139 | } 140 | this.finish('set', this.e.isGroup) 141 | if (index === 0) { 142 | this.e.reply('操作已取消') 143 | return true 144 | } 145 | tmp = [e[WAITFLAG][index - 1]] 146 | } 147 | if (!tmp) tmp = loader.find(keyword[0], loader.GROUP, true) 148 | switch(tmp.length) { 149 | case 0: 150 | e.reply('没有找到插件:' + keyword[0]) 151 | break 152 | case 1: 153 | fs.renameSync(tmp[0].Abpath, PATH.join('./plugins', keyword[1], tmp[0].file)) 154 | e.reply(`成功设置插件< ${keyword[0]} >为分组< ${keyword[1]} >`) 155 | break 156 | default: 157 | this.setContext('set', this.e.isGroup, this.config.timeout) 158 | this.e[WAITFLAG] = tmp 159 | this.e.reply([ 160 | '找到多个插件,请发送序号指定插件', 161 | '\n0 - 取消本次操作', 162 | ...tmp.map((item, i) => '\n' + (i + 1) + item.file) 163 | ]) 164 | } 165 | return true 166 | } 167 | 168 | async sync(e) { 169 | if (!config.auth(e)) { 170 | return true 171 | } 172 | 173 | const groups = this.groups 174 | groups.group = []//清空一下group 175 | let ignore = this.exclude.rule//排除列表 176 | ignore.push(PATH.basename(this.groups.bin))//排除列表加上辣姬箱目录 177 | fs.readdirSync('./plugins').forEach(name => { 178 | let path = PATH.join('./plugins', name) 179 | if (fs.statSync(path).isDirectory()) { 180 | let key = fs.readdirSync(path) 181 | if (key.includes('index.js') || (fs.existsSync(PATH.join(path, '.git')) && fs.statSync(PATH.join(path, '.git')).isDirectory()) || ignore.includes(name)) return//匹配排除正则 182 | groups.group.push(name) 183 | } 184 | }) 185 | config.saveSet('group', 'set', 'config', groups) 186 | e.reply(`同步完成!当前分组列表:`) 187 | this.list(e) 188 | return true 189 | } 190 | } -------------------------------------------------------------------------------- /apps/Install.js: -------------------------------------------------------------------------------- 1 | import plugin from '../../../lib/plugins/plugin.js' 2 | import install from '../module/install.js' 3 | import config from '../module/config.js' 4 | import PATH from 'node:path' 5 | import fs from 'node:fs' 6 | 7 | 8 | export class Install extends plugin { 9 | constructor() { 10 | super({ 11 | name: '插件安装', 12 | dsc: '进行安装和新增插件操作', 13 | /** https://oicqjs.github.io/oicq/#events */ 14 | event: 'message', 15 | priority: 5, 16 | rule: [ 17 | { 18 | reg: '^#(安装|新增|增加)插件(https:\/\/(github|gitee).com\/[a-zA-Z0-9-]{1,39}\/[a-zA-Z0-9_-]{1,100}(.git)?)?$', 19 | fnc: 'new' 20 | }, 21 | { 22 | reg: '^#开始批量安装插件$', 23 | fnc: 'batch' 24 | }, 25 | { 26 | reg: '^#清空回收站', 27 | fnc: 'clear' 28 | } 29 | ] 30 | }) 31 | } 32 | 33 | get config() { 34 | return config.getConfig('js', 'set'); 35 | } 36 | 37 | get groups() { 38 | return config.getConfig('group', 'set'); 39 | } 40 | 41 | //安装指令 42 | async new(e) { 43 | if (!config.auth(e)) { 44 | return true; 45 | } 46 | //判断是否包含git链接 47 | let url = e.msg.replace(/#|安装|新增|增加|插件/g, ''); 48 | if (url) { 49 | return install.clone(e, url); 50 | } 51 | //是否包含文件 52 | if (!e.file) { 53 | this.setContext('install', e.isGroup, this.config.timeout) 54 | e.reply('请发送js插件'); 55 | return true; 56 | } 57 | 58 | return this.install(e);//消息包含js文件,直接安装 59 | } 60 | 61 | async batch(e) { 62 | if (!config.auth(e)) { 63 | return true; 64 | } 65 | 66 | this.e.batch = true 67 | this.setContext('install', e.isGroup, this.config.timeout) 68 | e.reply('已开始批量安装,请发送js插件\n结束批量安装使用:#结束批量安装') 69 | } 70 | 71 | async install(e) { 72 | if (!config.auth(this.e)) { 73 | return false; 74 | } 75 | 76 | if (new RegExp('^#取消安装(插件)?$').test(this.e.msg)) { 77 | this.finish('install', this.e.isGroup) 78 | this.e.reply('安装已取消') 79 | return true 80 | } 81 | 82 | //防止人机合一 83 | if (this.e.raw_message.includes('发送非js文件,已取消本次安装') || this.e.raw_message.includes('已开始批量安装')) { 84 | return false; 85 | } 86 | 87 | let error = false 88 | 89 | this.finish('install', this.e.isGroup) 90 | //批量安装 91 | if (e.batch) { 92 | if (new RegExp('^#结束批量安装(插件)?$').test(this.e.msg)) { 93 | this.e.reply('已结束批量安装') 94 | return true 95 | } 96 | this.e.batch = true 97 | this.setContext('install', this.e.isGroup, this.config.timeout) 98 | } 99 | 100 | if (!this.e.file || !this.e.file.name.endsWith('.js')) { 101 | this.e.reply('发送非js文件,已取消本次安装') 102 | error = true 103 | } 104 | 105 | if (this.e.message[0]?.size > this.config.maxSize) { 106 | this.e.reply('文件过大,已取消本次安装'); 107 | error = true 108 | } 109 | 110 | //有错误不走行安装逻辑 111 | if (error) return true 112 | 113 | //获取下载链接 114 | const fileUrl = await this.e[this.e.isGroup ? 'group' : 'friend'].getFileUrl(this.e.file.fid) 115 | const savePath = PATH.join('./plugins', this.config.default_group, this.e.file.name) 116 | await install.install(this.e, fileUrl, savePath);//调用安装函数 117 | return true; 118 | } 119 | 120 | async clear(e) { 121 | if (!config.auth(e)) { 122 | return true; 123 | } 124 | e.reply('警告!此操作会清空回收站内的全部插件且无法找回!\n是否继续(是/否)') 125 | this.setContext('delete', e.isGroup, this.config.timeout) 126 | return true; 127 | } 128 | 129 | async delete() { 130 | switch (this.e.msg) { 131 | case '是': 132 | let files = fs.readdirSync(this.groups.bin); 133 | files.forEach(item => { 134 | //rm暴力删除 135 | fs.rmSync(PATH.join(this.groups.bin, item), { recursive: true, force: true }) 136 | }); 137 | this.e.reply('插件回收站已清空') 138 | this.finish('delete', this.e.isGroup) 139 | break; 140 | case '否': 141 | this.e.reply('操作已取消') 142 | this.finish('delete', this.e.isGroup); 143 | break; 144 | default: 145 | this.e.reply('请发送(是/否)进行选择') 146 | return false; 147 | } 148 | return false; 149 | } 150 | } -------------------------------------------------------------------------------- /apps/List.js: -------------------------------------------------------------------------------- 1 | import puppeteer from '../../../lib/puppeteer/puppeteer.js' 2 | import plugin from '../../../lib/plugins/plugin.js' 3 | import config from '../module/config.js' 4 | import loader from '../module/loader.js' 5 | import list from '../module/list.js' 6 | import YAML from 'yaml' 7 | 8 | 9 | export class List extends plugin { 10 | constructor() { 11 | super({ 12 | name: '插件列表', 13 | dsc: '查看js和大型插件', 14 | /** https://oicqjs.github.io/oicq/#events */ 15 | event: 'message', 16 | priority: 5000, 17 | rule: [ 18 | { 19 | reg: '^#插件列表$', 20 | fnc: 'read' 21 | }, 22 | { 23 | reg: '^#查看回收站$', 24 | fnc: 'look' 25 | } 26 | ] 27 | }) 28 | } 29 | 30 | get groups() { 31 | return config.getConfig('group', 'set') 32 | } 33 | 34 | async read(e) { 35 | if (!config.auth(e)) { 36 | return true; 37 | } 38 | const data = await new list(e).getData(); 39 | 40 | let img = await puppeteer.screenshot('xitian-plugin/list', data); 41 | e.reply(img) 42 | return true; 43 | } 44 | 45 | async look(e) { 46 | if (!config.auth(e)) { 47 | return true; 48 | } 49 | // 同步读取bin目录下的所有文件 50 | const files = loader.find('', loader.BIN) 51 | let msg = [] 52 | files.forEach(item => { 53 | msg.push(item.key) 54 | }) 55 | e.reply(`回收站的插件:\n${msg.join('\n')}\n恢复请用:#恢复插件+名字`); 56 | return true; 57 | } 58 | } -------------------------------------------------------------------------------- /apps/Manager.js: -------------------------------------------------------------------------------- 1 | import plugin from '../../../lib/plugins/plugin.js' 2 | import cfg from '../../../lib/config/config.js' 3 | import uninstall from '../module/uninstall.js' 4 | import config from '../module/config.js' 5 | import loader from '../module/loader.js' 6 | import PATH from 'node:path' 7 | import fs from 'node:fs' 8 | 9 | const WAITFLAG = Symbol('WAITFLAG') 10 | 11 | export class Manager extends plugin { 12 | constructor() { 13 | super({ 14 | name: '插件管理', 15 | dsc: '各种功能帮助master管理js插件', 16 | /** https://oicqjs.github.io/oicq/#events */ 17 | event: 'message', 18 | priority: 5, 19 | rule: [ 20 | { 21 | reg: '^#查找插件(.*)$', 22 | fnc: 'find' 23 | }, 24 | { 25 | reg: '^#停用插件(.*)$', 26 | fnc: 'mv_ty' 27 | }, 28 | { 29 | reg: '^#启用插件(.*)$', 30 | fnc: 'mv_qy' 31 | }, 32 | { 33 | reg: '^#(彻底)?删除插件(.*)$', 34 | fnc: 'del' 35 | }, 36 | { 37 | reg: '^#恢复插件(.*)$', 38 | fnc: 'rec' 39 | }, 40 | { 41 | reg: '^#插件(.*)重命名(.*)$', 42 | fnc: 'rename' 43 | }, 44 | { 45 | reg: '^#查看插件(.*)$', 46 | fnc: 'upload' 47 | } 48 | ] 49 | }) 50 | } 51 | 52 | get groups() { 53 | return config.getConfig('group', 'set') 54 | } 55 | 56 | get config() { 57 | return config.getConfig('js', 'set') 58 | } 59 | 60 | init() { 61 | for (let name of this.groups.group) { 62 | name = PATH.join('./plugins', name) 63 | if (!fs.existsSync(name)) { 64 | fs.mkdirSync(name); 65 | } 66 | } 67 | } 68 | 69 | async find(e) { 70 | if (!config.auth(e)) { 71 | return true 72 | } 73 | //获取关键字 74 | let keyword = e.msg.replace(/#查找插件|.js|.bak/g, '') 75 | let plugininfo = loader.find(keyword) 76 | switch (plugininfo.length) { 77 | case 0: 78 | e.reply('没有找到该插件,请确认你是否安装了该插件') 79 | break 80 | case 1: 81 | e.reply([ 82 | `找到插件:${plugininfo[0].key}\n`, 83 | `位于分组:${plugininfo[0].group}\n`, 84 | `当前状态:${plugininfo[0].state}` 85 | ]) 86 | break 87 | default: 88 | e.reply('找到多个插件') 89 | let msg = [] 90 | for (let item of plugininfo) { 91 | let info = [ 92 | `找到插件:${item.key}\n`, 93 | `位于分组:${item.group}\n`, 94 | `当前状态:${item.state}` 95 | ] 96 | msg.push({ 97 | message: info, 98 | nickname: Bot.nickname, 99 | user_id: cfg.qq 100 | }) 101 | } 102 | //判断是不是群聊,制作合并转发消息 103 | if (e.isGroup) { 104 | msg = await e.group.makeForwardMsg(msg) 105 | } else { 106 | msg = await e.friend.makeForwardMsg(msg) 107 | } 108 | await e.reply(msg) 109 | } 110 | return true; 111 | } 112 | 113 | async mv_ty(e) { 114 | if (!config.auth(this.e)) { 115 | return true 116 | } 117 | 118 | // 停用插件,添加.bak的后缀名 119 | let msg = this.e.msg.replace('#停用插件', '') 120 | let tmp 121 | if (e[WAITFLAG]) { 122 | const index = Number(this.e.msg) 123 | if (Number.isNaN(index)) { 124 | this.e.reply('请发送序号数字') 125 | return true 126 | } 127 | if (index > e[WAITFLAG].length) { 128 | this.e.reply(`序号需要在0-${e[WAITFLAG].length}内,收到:${index}`) 129 | return true 130 | } 131 | this.finish('mv_ty', this.e.isGroup) 132 | if (index === 0) { 133 | this.e.reply('操作已取消') 134 | return true 135 | } 136 | tmp = [e[WAITFLAG][index - 1]] 137 | } 138 | if (!tmp) tmp = loader.find(msg, loader.GROUP, true) 139 | switch (tmp.length) { 140 | case 0: 141 | this.e.reply('没有找到该插件') 142 | break; 143 | case 1: 144 | switch (tmp[0].state) { 145 | case '启用': 146 | fs.renameSync(tmp[0].Abpath, PATH.join('./plugins', tmp[0].group, tmp[0].file + '.bak')) 147 | this.e.reply(`已停用< ${tmp[0].key} >` + '立即生效') 148 | break; 149 | case '停用': 150 | this.e.reply('该插件已经处于停用状态') 151 | break; 152 | case '已删除': 153 | this.e.reply('该插件处于已删除状态,请先恢复插件') 154 | break; 155 | default: 156 | this.e.reply('该插件状态异常,请确认你指定了有效的插件') 157 | } 158 | break; 159 | default: 160 | this.setContext('mv_ty', this.e.isGroup, this.config.timeout) 161 | this.e[WAITFLAG] = tmp 162 | this.e.reply([ 163 | '找到多个插件,请发送序号指定插件', 164 | '\n0 - 取消本次操作', 165 | ...tmp.map((item, i) => `\n${i + 1} - ${item.group}/${item.file}`) 166 | ]) 167 | } 168 | return true 169 | } 170 | 171 | async mv_qy(e) { 172 | if (!config.auth(this.e)) { 173 | return true 174 | } 175 | 176 | // 启用插件,去除.bak的后缀名 177 | let msg = this.e.msg.replace('#启用插件', '') 178 | let tmp 179 | if (e[WAITFLAG]) { 180 | const index = Number(this.e.msg) 181 | if (Number.isNaN(index)) { 182 | this.e.reply('请发送序号数字') 183 | return true 184 | } 185 | if (index > e[WAITFLAG].length) { 186 | this.e.reply(`序号需要在0-${e[WAITFLAG].length}内,收到:${index}`) 187 | return true 188 | } 189 | this.finish('mv_qy', this.e.isGroup) 190 | if (index === 0) { 191 | this.e.reply('操作已取消') 192 | return true 193 | } 194 | tmp = [e[WAITFLAG][index - 1]] 195 | } 196 | if (!tmp) tmp = loader.find(msg, loader.GROUP, true) 197 | switch (tmp.length) { 198 | case 0: 199 | this.e.reply('没有找到该插件'); 200 | break; 201 | case 1: 202 | switch (tmp[0].state) { 203 | case '启用': 204 | this.e.reply('该插件已经处于启用状态'); 205 | break; 206 | case '停用': 207 | fs.renameSync(tmp[0].Abpath, PATH.join('./plugins', tmp[0].group, tmp[0].file.replace(/.bak$/, ''))) 208 | e.reply(`已启用:< ${tmp[0].key} >` + '立即生效') 209 | break; 210 | case '已删除': 211 | e.reply('该插件处于已删除状态,请先恢复插件'); 212 | break; 213 | default: 214 | e.reply('该插件状态异常,请确认你指定了有效的插件'); 215 | } 216 | break; 217 | default: 218 | this.setContext('mv_qy', this.e.isGroup, this.config.timeout) 219 | this.e[WAITFLAG] = tmp 220 | this.e.reply([ 221 | '找到多个插件,请发送序号指定插件', 222 | '\n0 - 取消本次操作', 223 | ...tmp.map((item, i) => `\n${i + 1} - ${item.group}/${item.file}`) 224 | ]) 225 | } 226 | return true; 227 | } 228 | 229 | async del(e) { 230 | if (!config.auth(this.e)) { 231 | return true 232 | } 233 | let msg = this.e.msg.replace('#', '') 234 | //检查是否是大型插件 235 | if (await uninstall.removePlugin(e)) return true; 236 | 237 | //彻底删除,直接删除该文件 238 | if (msg.startsWith('彻底')) { 239 | this.setContext('fullDel', this.e.isGroup, this.config.timeout); 240 | await e.reply('(是|否)确认删除该插件?彻底删除后再也找不回来了哦'); 241 | return true 242 | } else { 243 | msg = msg.replace('删除插件', '') 244 | } 245 | 246 | //删除插件,移动到回收站 247 | let tmp 248 | if (e[WAITFLAG]) { 249 | const index = Number(this.e.msg) 250 | if (Number.isNaN(index)) { 251 | this.e.reply('请发送序号数字') 252 | return true 253 | } 254 | if (index > e[WAITFLAG].length) { 255 | this.e.reply(`序号需要在0-${e[WAITFLAG].length}内,收到:${index}`) 256 | return true 257 | } 258 | this.finish('del', this.e.isGroup) 259 | if (index === 0) { 260 | this.e.reply('操作已取消') 261 | return true 262 | } 263 | tmp = [e[WAITFLAG][index - 1]] 264 | } 265 | if (!tmp) tmp = loader.find(msg, loader.GROUP, true) 266 | switch (tmp.length) { 267 | case 0: 268 | e.reply('没有找到该插件') 269 | break; 270 | case 1: 271 | switch (tmp[0].state) { 272 | case '启用': 273 | case '停用': 274 | break 275 | case '已删除': 276 | e.reply('该插件已经是删除状态') 277 | return true 278 | default: 279 | e.reply('该插件状态异常,请确认你指定了有效的插件') 280 | return true 281 | } 282 | fs.renameSync(tmp[0].Abpath, PATH.join(this.groups.bin, `[${tmp[0].group}]${tmp[0].file + (tmp[0].file.endsWith('.bak') ? '' : '.bak')}`)) 283 | e.reply(`已删除:< ${tmp[0].key} >` + '立即生效') 284 | break 285 | default: 286 | this.setContext('del', this.e.isGroup, this.config.timeout) 287 | this.e[WAITFLAG] = tmp 288 | this.e.reply([ 289 | '找到多个插件,请发送序号指定插件', 290 | '\n0 - 取消本次操作', 291 | ...tmp.map((item, i) => `\n${i + 1} - ${item.group}/${item.file}`) 292 | ]) 293 | } 294 | return true; 295 | } 296 | 297 | async fullDel(e) { 298 | if (!config.auth(this.e)) { 299 | return true 300 | } 301 | if (!this.e.msg) return true 302 | switch (e[WAITFLAG] || this.e.msg) { 303 | case '是': 304 | case e[WAITFLAG]: 305 | let msg = e.msg.replace('#彻底删除插件', '') 306 | let tmp 307 | if (e[WAITFLAG]) { 308 | const index = Number(this.e.msg) 309 | if (Number.isNaN(index)) { 310 | this.e.reply('请发送序号数字') 311 | return true 312 | } 313 | if (index > e[WAITFLAG].length) { 314 | this.e.reply(`序号需要在0-${e[WAITFLAG].length}内,收到:${index}`) 315 | return true 316 | } 317 | this.finish('fullDel', this.e.isGroup) 318 | if (index === 0) { 319 | this.e.reply('操作已取消') 320 | return true 321 | } 322 | tmp = [e[WAITFLAG][index - 1]] 323 | } else { 324 | this.finish('fullDel', this.e.isGroup) 325 | } 326 | if (!tmp) tmp = loader.find(msg, loader.GROUP, true) 327 | switch (tmp.length) { 328 | case 0: 329 | this.e.reply('没有找到该插件'); 330 | break 331 | case 1: 332 | fs.unlinkSync(tmp[0].Abpath); 333 | this.e.reply(`已经彻底删除插件< ${tmp[0].key} >`) 334 | break 335 | default: 336 | this.setContext('fullDel', this.e.isGroup, this.config.timeout) 337 | this.e[WAITFLAG] = tmp 338 | this.e.reply([ 339 | '找到多个插件,请发送序号指定插件', 340 | '\n0 - 取消本次操作', 341 | ...tmp.map((item, i) => `\n${i + 1} - ${item.group}/${item.file}`) 342 | ]) 343 | } 344 | break 345 | case '否': 346 | this.finish('fullDel', this.e.isGroup) 347 | this.e.reply('操作已取消') 348 | break 349 | default: 350 | if (!this.e.msg.includes('彻底删除后再也找不回来了哦') && !this.e.msg.includes('请回答 是/否 来进行操作')) { 351 | this.e.reply('请回答 是/否 来进行操作') 352 | } 353 | } 354 | return true 355 | } 356 | 357 | async rec(e) { 358 | if (!config.auth(e)) { 359 | return true; 360 | } 361 | 362 | // 恢复插件,去除.bak的后缀名 363 | let msg = e.msg.replace('#恢复插件', '') 364 | let tmp 365 | if (e[WAITFLAG]) { 366 | const index = Number(this.e.msg) 367 | if (Number.isNaN(index)) { 368 | this.e.reply('请发送序号数字') 369 | return true 370 | } 371 | if (index > e[WAITFLAG].length) { 372 | this.e.reply(`序号需要在0-${e[WAITFLAG].length}内,收到:${index}`) 373 | return true 374 | } 375 | this.finish('rec', this.e.isGroup) 376 | if (index === 0) { 377 | this.e.reply('操作已取消') 378 | return true 379 | } 380 | tmp = [e[WAITFLAG][index - 1]] 381 | } 382 | if (!tmp) tmp = loader.find(msg, loader.BIN, true) 383 | //确定来源文件夹 384 | switch (tmp.length) { 385 | case 0: 386 | this.e.reply('没有找到该插件') 387 | break; 388 | case 1: 389 | switch (tmp[0].state) { 390 | case '启用': 391 | this.e.reply('该插件处于启用状态') 392 | break; 393 | case '停用': 394 | this.e.reply('该插件处于停用状态') 395 | break; 396 | case '已删除': 397 | //先确定有没有这个分组 398 | if (!fs.existsSync(PATH.join('./plugins', tmp[0].origin))) { 399 | e.reply(`没有找到< ${tmp[0].origin} >分组\n即将恢复至默认分组`) 400 | fs.renameSync(tmp[0].Abpath, PATH.join('./plugins', this.config.default_group, tmp[0].key + '.js')) 401 | } else { 402 | fs.renameSync(tmp[0].Abpath, PATH.join('./plugins', tmp[0].origin, tmp[0].key + '.js')); 403 | } 404 | e.reply(`已恢复:< ${tmp[0].key} >` + '立即生效') 405 | break 406 | default: 407 | e.reply('该插件状态异常,请确认你指定了有效的插件'); 408 | } 409 | break; 410 | default: 411 | this.setContext('rec', this.e.isGroup, this.config.timeout) 412 | this.e[WAITFLAG] = tmp 413 | this.e.reply([ 414 | '找到多个插件,请发送序号指定插件', 415 | '\n0 - 取消本次操作', 416 | ...tmp.map((item, i) => `\n${i + 1} - ${item.group}/${item.file}`) 417 | ]) 418 | } 419 | return true; 420 | } 421 | 422 | async rename(e) { 423 | if (!config.auth(this.e)) { 424 | return true 425 | } 426 | 427 | let key = e.msg.replace('#插件', '').split('重命名') 428 | if (key.length > 2) { 429 | for (let num = 2; num < key.length; num++) { 430 | key[1] = key[1] + '重命名' + key[num]; 431 | } 432 | } 433 | let tmp 434 | if (e[WAITFLAG]) { 435 | const index = Number(this.e.msg) 436 | if (Number.isNaN(index)) { 437 | this.e.reply('请发送序号数字') 438 | return true 439 | } 440 | if (index > e[WAITFLAG].length) { 441 | this.e.reply(`序号需要在0-${e[WAITFLAG].length}内,收到:${index}`) 442 | return true 443 | } 444 | this.finish('rename', this.e.isGroup) 445 | if (index === 0) { 446 | this.e.reply('操作已取消') 447 | return true 448 | } 449 | tmp = [e[WAITFLAG][index - 1]] 450 | } 451 | if (!tmp) tmp = loader.find(key[0], loader.ALL, true) 452 | switch (tmp.length) { 453 | case 0: 454 | e.reply('未找到该插件') 455 | break; 456 | case 1: 457 | fs.renameSync(tmp[0].Abpath, PATH.join('./plugins', tmp[0].group, tmp[0].file.replace(key[0], key[1]))) 458 | e.reply(`插件< ${key[0]} >重命名< ${key[1]} >成功`) 459 | break; 460 | default: 461 | this.setContext('rename', this.e.isGroup, this.config.timeout) 462 | this.e[WAITFLAG] = tmp 463 | this.e.reply([ 464 | '找到多个插件,请发送序号指定插件', 465 | '\n0 - 取消本次操作', 466 | ...tmp.map((item, i) => `\n${i + 1} - ${item.group}/${item.file}`) 467 | ]) 468 | } 469 | return true; 470 | } 471 | 472 | async upload(e) { 473 | if (!config.auth(e)) { 474 | return true; 475 | } 476 | 477 | let msg = e.msg.replace('#查看插件', ''); 478 | let tmp 479 | if (e[WAITFLAG]) { 480 | const index = Number(this.e.msg) 481 | if (Number.isNaN(index)) { 482 | this.e.reply('请发送序号数字') 483 | return true 484 | } 485 | if (index > e[WAITFLAG].length) { 486 | this.e.reply(`序号需要在0-${e[WAITFLAG].length}内,收到:${index}`) 487 | return true 488 | } 489 | this.finish('upload', this.e.isGroup) 490 | if (index === 0) { 491 | this.e.reply('操作已取消') 492 | return true 493 | } 494 | tmp = [e[WAITFLAG][index - 1]] 495 | } 496 | if (!tmp) tmp = loader.find(msg, loader.ALL, true) 497 | switch (tmp.length) { 498 | case 0: 499 | e.reply('未找到该插件') 500 | break; 501 | case 1: 502 | if (this.e.isGroup) { 503 | //上传到群文件 504 | this.e.group.fs.upload(tmp[0].Abpath) 505 | } else { 506 | //发送离线文件 507 | this.e.friend.sendFile(tmp[0].Abpath) 508 | } 509 | break 510 | default: 511 | this.setContext('upload', this.e.isGroup, this.config.timeout) 512 | this.e[WAITFLAG] = tmp 513 | this.e.reply([ 514 | '找到多个插件,请发送序号指定插件', 515 | '\n0 - 取消本次操作', 516 | ...tmp.map((item, i) => `\n${i + 1} - ${item.group}/${item.file}`) 517 | ]) 518 | } 519 | return true 520 | } 521 | } -------------------------------------------------------------------------------- /apps/help.js: -------------------------------------------------------------------------------- 1 | import puppeteer from '../../../lib/puppeteer/puppeteer.js' 2 | import plugin from '../../../lib/plugins/plugin.js' 3 | import config from '../module/config.js' 4 | import Help from '../module/help.js' 5 | import md5 from 'md5' 6 | 7 | let helpData = { 8 | md5: '', 9 | img: '', 10 | }; 11 | 12 | export class help extends plugin { 13 | constructor() { 14 | super({ 15 | name: '插件帮助', 16 | dsc: '发送插件管理器使用帮助', 17 | /** https://oicqjs.github.io/oicq/#events */ 18 | event: 'message', 19 | priority: 5, 20 | rule: [ 21 | { 22 | reg: '^#插件(管理器)?(菜单|帮助|help)$', 23 | fnc: 'help' 24 | } 25 | ] 26 | }) 27 | } 28 | 29 | async help(e) { 30 | if (!config.auth(e)) { 31 | return true; 32 | } 33 | let data = await Help.get(this.e); 34 | 35 | if (!data) return; 36 | let img = await this.cache(data); 37 | await this.reply(img); 38 | } 39 | 40 | async cache(data) { 41 | let tmp = md5(JSON.stringify(data)); 42 | if (helpData.md5 == tmp) return helpData.img; 43 | 44 | helpData.img = await puppeteer.screenshot('xitian-plugin/help', data); 45 | helpData.md5 = tmp; 46 | 47 | return helpData.img; 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /apps/regTest.js: -------------------------------------------------------------------------------- 1 | import plugin from '../../../lib/plugins/plugin.js' 2 | import loader from '../../../lib/plugins/loader.js' 3 | import common from '../../../lib/common/common.js' 4 | import config from '../module/config.js' 5 | import util from 'node:util' 6 | import lodash from 'lodash' 7 | 8 | 9 | export class regTest extends plugin { 10 | constructor() { 11 | super({ 12 | name: '插件测试', 13 | dsc: '测试或查看全部命令', 14 | /** https://oicqjs.github.io/oicq/#events */ 15 | event: 'message', 16 | priority: 500, 17 | rule: [ 18 | { 19 | reg: '^#命令(总览|列表)$', 20 | fnc: 'getrule' 21 | }, 22 | { 23 | reg: '^#测试(执行)?命令(.*)$', 24 | fnc: 'testrule' 25 | } 26 | ] 27 | }) 28 | } 29 | 30 | async getrule(e) { 31 | if (!config.auth(e)) return true; 32 | let msgs = [] 33 | for (let plugin of loader.priority) { 34 | let p = new plugin.class(e); 35 | let msg = `插件名:${plugin.name}\n路径:${plugin.key}\n优先级:${plugin.priority}\n` 36 | if (lodash.isEmpty(p.rule)) { 37 | msg += `无命令正则\n` 38 | msgs.push(msg); 39 | continue; 40 | } 41 | for (let v in p.rule) { 42 | msg += `命令正则<${Number(v) + 1}>:${p.rule[v].reg}\n` 43 | } 44 | msgs.push(msg) 45 | } 46 | msgs = lodash.chunk(msgs, 50); 47 | for (let i in msgs) { 48 | msgs[i] = await common.makeForwardMsg(e, msgs[i], `第${Number(i) + 1}页`) 49 | await e.reply(msgs[i]) 50 | } 51 | return true; 52 | } 53 | 54 | async testrule(e) { 55 | if (!config.auth(e)) return true; 56 | let key = e.msg.replace('#测试', '').replace('命令', '') 57 | let execute = false 58 | if (key.startsWith('执行')) { 59 | key = key.replace('执行', '') 60 | execute = true 61 | } 62 | //替换执行指令 63 | e.msg = key 64 | e.message[0].text = key 65 | let msgs = [`命令<${key}>响应插件`] 66 | for (let plugin of loader.priority) { 67 | let p = new plugin.class(e) 68 | if (!this.filtEvent(e, p)) continue 69 | if (lodash.isEmpty(p.rule)) continue 70 | let msg = '' 71 | for (let v of p.rule) { 72 | if (v.event && !this.filtEvent(e, v)) continue 73 | if (new RegExp(v.reg).test(key)) { 74 | msg += `插件:${plugin.name}\n路径:${plugin.key}\n优先级:${plugin.priority}\n` 75 | msg += `命令正则:${v.reg}\n执行方法:${v.fnc}` 76 | if (execute) { 77 | try { 78 | let res = p[v.fnc] && p[v.fnc](e) 79 | if (util.types.isPromise(res)) res = await res 80 | msg += `\n返回结果:${util.format(res)}` 81 | if (res !== false) { 82 | msg += `\n该命令在此终止` 83 | } 84 | } catch (err) { 85 | msg += `\n执行报错:${err}\n该命令在此终止` 86 | } 87 | } 88 | } 89 | } 90 | if (msg) msgs.push(msg); 91 | } 92 | msgs = await common.makeForwardMsg(e, msgs) 93 | await e.reply(msgs) 94 | return true 95 | } 96 | 97 | /** 过滤事件 */ 98 | filtEvent(e, v) { 99 | let event = v.event.split('.') 100 | let eventMap = { 101 | message: ['post_type', 'message_type', 'sub_type'], 102 | notice: ['post_type', 'notice_type', 'sub_type'], 103 | request: ['post_type', 'request_type', 'sub_type'] 104 | } 105 | let newEvent = [] 106 | event.forEach((val, index) => { 107 | if (val === '*') { 108 | newEvent.push(val) 109 | } else if (eventMap[e.post_type]) { 110 | newEvent.push(e[eventMap[e.post_type][index]]) 111 | } 112 | }) 113 | newEvent = newEvent.join('.') 114 | 115 | if (v.event == newEvent) return true 116 | 117 | return false 118 | } 119 | } -------------------------------------------------------------------------------- /apps/update.js: -------------------------------------------------------------------------------- 1 | import puppeteer from '../../../lib/puppeteer/puppeteer.js' 2 | import plugin from '../../../lib/plugins/plugin.js' 3 | import common from '../../../lib/common/common.js' 4 | import { Restart } from '../../other/restart.js' 5 | import Version from '../module/version.js' 6 | import { exec } from 'node:child_process' 7 | import config from '../module/config.js' 8 | import path from 'node:path' 9 | import lodash from 'lodash' 10 | 11 | let uping = false 12 | 13 | export class update extends plugin { 14 | constructor() { 15 | super({ 16 | name: '更新插件', 17 | dsc: '#更新 #强制更新', 18 | event: 'message', 19 | priority: 4000, 20 | rule: [ 21 | { 22 | reg: '^#插件(管理器)?更新日志$', 23 | fnc: 'updateLog' 24 | }, 25 | { 26 | reg: '^#插件(管理器)?(强制)*更新$', 27 | fnc: 'update' 28 | }, 29 | { 30 | reg: '^#插件(管理器)?版本$', 31 | fnc: 'version' 32 | } 33 | ] 34 | }) 35 | } 36 | 37 | get versionData() { 38 | return config.getdefSet('version', 'set') 39 | } 40 | 41 | async update() { 42 | if (!this.e.isMaster) return false 43 | //是不是在更新? 44 | if (uping) { 45 | await this.reply('已有命令更新中..请勿重复操作') 46 | return 47 | } 48 | //可能是其他的插件 49 | if (/详细|详情|面板|面版/.test(this.e.msg)) return false 50 | 51 | /** 检查git安装 */ 52 | if (!await this.checkGit()) return 53 | 54 | /** 执行更新 */ 55 | await this.runUpdate() 56 | 57 | /** 是否需要重启 */ 58 | if (this.isUp) { 59 | // await this.reply('即将执行重启,以应用更新') 60 | setTimeout(() => this.restart(), 2000) 61 | } 62 | } 63 | 64 | /** 65 | * 插件版本信息 66 | */ 67 | async version() { 68 | const data = await new Version(this.e).getData( 69 | this.versionData.slice(0, 3) 70 | ); 71 | let img = await puppeteer.screenshot('xitian-plugin/version', data); 72 | this.e.reply(img); 73 | } 74 | 75 | /** 76 | * 检查git是否安装 77 | * @returns 78 | */ 79 | async checkGit() { 80 | let ret = await this.execSync('git --version', { encoding: 'utf-8' }).then(res => res.stdout) 81 | if (!ret || !ret.includes('git version')) { 82 | await e.reply('请先安装git') 83 | return false 84 | } 85 | return true 86 | } 87 | 88 | /** 89 | * 执行cmd命令 90 | * @param {string} cmd git命令 91 | * @returns {Promise<{error:Error|null,stdout:string,stderr:string}>} 92 | */ 93 | async execSync(cmd) { 94 | return new Promise(resolve => { 95 | exec(cmd, { windowsHide: true }, (error, stdout, stderr) => { 96 | resolve({ error, stdout, stderr }) 97 | }) 98 | }) 99 | } 100 | 101 | async runUpdate() { 102 | this.isNowUp = false 103 | 104 | let cm = `git -C ./plugins/${path.basename(config.baseDir)}/ pull --no-rebase` 105 | 106 | let type = '更新' 107 | //判断是不是强制更新 108 | if (this.e.msg.includes('强制')) { 109 | type = '强制更新' 110 | cm = `git -C ./plugins/${path.basename(config.baseDir)}/ checkout . && ${cm}` 111 | } 112 | /** 获取上次提交的commitId,用于获取日志时判断新增的更新日志 */ 113 | this.oldCommitId = await this.getcommitId(path.basename(config.baseDir)) 114 | 115 | logger.mark(`${this.e.logFnc} 开始${type}:插件管理器`) 116 | 117 | await this.reply(`开始${type}:插件管理器`) 118 | uping = true 119 | let ret = await this.execSync(cm) 120 | uping = false 121 | 122 | if (ret.error) { 123 | logger.mark(`${this.e.logFnc} 插件管理器更新失败!`) 124 | this.gitErr(ret.error, ret.stdout) 125 | return false 126 | } 127 | 128 | let time = await this.getTime(path.basename(config.baseDir)) 129 | 130 | if (/Already up|已经是最新/g.test(ret.stdout)) { 131 | await this.reply(`插件管理器已经是最新\n最后更新时间:${time}`) 132 | } else { 133 | await this.reply(`插件管理器更新成功\n更新时间:${time}`) 134 | this.isUp = true 135 | let log = await this.getLog(path.basename(config.baseDir)) 136 | await this.reply(log) 137 | } 138 | 139 | logger.mark(`${this.e.logFnc} 最后更新时间:${time}`) 140 | 141 | return true 142 | } 143 | 144 | async getcommitId(plugin = '') { 145 | let cm = 'git rev-parse --short HEAD' 146 | if (plugin) { 147 | cm = `git -C ./plugins/${plugin}/ rev-parse --short HEAD` 148 | } 149 | 150 | let commitId = await this.execSync(cm, { encoding: 'utf-8', windowsHide: true }).then(res => res.stdout) 151 | commitId = lodash.trim(commitId) 152 | 153 | return commitId 154 | } 155 | 156 | async getTime(plugin = '') { 157 | let cm = 'git log -1 --oneline --pretty=format:"%cd" --date=format:"%m-%d %H:%M"' 158 | if (plugin) { 159 | cm = `cd ./plugins/${plugin}/ && git log -1 --oneline --pretty=format:"%cd" --date=format:"%m-%d %H:%M"` 160 | } 161 | 162 | let time = '' 163 | try { 164 | time = await this.execSync(cm, { encoding: 'utf-8', windowsHide: true }).then(res => res.stdout) 165 | time = lodash.trim(time) 166 | } catch (error) { 167 | logger.error(error.toString()) 168 | time = '获取时间失败' 169 | } 170 | 171 | return time 172 | } 173 | 174 | /** 175 | * 处理更新失败的相关函数 176 | * @param {string} err 177 | * @param {string} stdout 178 | * @returns 179 | */ 180 | async gitErr(err, stdout) { 181 | let msg = '更新失败!' 182 | let errMsg = err.toString() 183 | stdout = stdout.toString() 184 | 185 | if (errMsg.includes('Timed out')) { 186 | let remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '') 187 | await this.reply(msg + `\n连接超时:${remote}`) 188 | return 189 | } 190 | 191 | if (/Failed to connect|unable to access/g.test(errMsg)) { 192 | let remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '') 193 | await this.reply(msg + `\n连接失败:${remote}`) 194 | return 195 | } 196 | 197 | if (errMsg.includes('be overwritten by merge')) { 198 | await this.reply(msg + `存在冲突:\n${errMsg}\n` + '请解决冲突后再更新,或者执行#强制更新,放弃本地修改') 199 | return 200 | } 201 | 202 | if (stdout.includes('CONFLICT')) { 203 | await this.reply([msg + '存在冲突\n', errMsg, stdout, '\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改']) 204 | return 205 | } 206 | 207 | await this.reply([errMsg, stdout]) 208 | } 209 | 210 | restart() { 211 | new Restart(this.e).restart() 212 | } 213 | 214 | /** 215 | * 获取插件更新日志 216 | * @param {string} plugin 插件名称 217 | * @returns 218 | */ 219 | async getLog(plugin = '') { 220 | let cm = 'git log -20 --oneline --pretty=format:"%h||[%cd] %s" --date=format:"%m-%d %H:%M"' 221 | if (plugin) { 222 | cm = `cd ./plugins/${plugin}/ && ${cm}` 223 | } 224 | 225 | let logAll = await this.execSync(cm, {cwd: path.join()}) 226 | if (logAll.error) { 227 | logger.error(logAll.error) 228 | this.reply(logAll.error.toString()) 229 | } 230 | logAll = logAll.stdout 231 | 232 | if (!logAll) return false 233 | 234 | logAll = logAll.split('\n') 235 | 236 | let log = [] 237 | for (let str of logAll) { 238 | str = str.split('||') 239 | if (str[0] == this.oldCommitId) break 240 | if (str[1].includes('Merge branch')) continue 241 | log.push(str[1]) 242 | } 243 | let line = log.length 244 | log = log.join('\n\n') 245 | 246 | if (log.length <= 0) return '' 247 | 248 | let end = '' 249 | if (!plugin) { 250 | end = '更多详细信息,请前往github查看\nhttps://github.com/XiTianGame/xitian-plugin' 251 | } 252 | 253 | const title = `${plugin || path.basename(config.baseDir)}更新日志,共${line}条` 254 | 255 | const forwardMsg = [title, log, end] 256 | log = await common.makeForwardMsg(this.e, forwardMsg, title) 257 | 258 | return log 259 | } 260 | 261 | /* 262 | *更新日志的方法 263 | */ 264 | async updateLog() { 265 | let log = await this.getLog(path.basename(config.baseDir)) 266 | await this.reply(log) 267 | } 268 | } -------------------------------------------------------------------------------- /config/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/config/.keep -------------------------------------------------------------------------------- /defSet/auth/set.yaml: -------------------------------------------------------------------------------- 1 | #选择插件操作等级 2 | # 主人master,群主owner,群管理admin,所有人everyone 3 | grade: 4 | - master 5 | #授权插件操作的用户QQ 6 | accredit: 7 | - 12345 8 | #是否允许群聊操作 9 | group: true -------------------------------------------------------------------------------- /defSet/exclude/set.yaml: -------------------------------------------------------------------------------- 1 | #分组排除的文件夹,排除后不会同步进分组 2 | rule: 3 | - system 4 | - other 5 | - genshin -------------------------------------------------------------------------------- /defSet/group/set.yaml: -------------------------------------------------------------------------------- 1 | #辣姬箱目录 2 | bin: ./plugins/bin/ 3 | #分组列表 4 | group: 5 | - example -------------------------------------------------------------------------------- /defSet/help/set.yaml: -------------------------------------------------------------------------------- 1 | - group: 安装插件 2 | list: 3 | - icon: install 4 | title: "#安装插件" 5 | desc: 安装单个js插件 6 | - icon: batch 7 | title: "#(开始/结束)批量安装插件" 8 | desc: 一次性安装多个插件 9 | - group: 插件管理 10 | list: 11 | - icon: disable 12 | title: "#停用插件 xxx" 13 | desc: 停用名为 xxx 的js插件 14 | - icon: enable 15 | title: "#启用插件 xxx" 16 | desc: 启用名为 xxx 的js插件 17 | - icon: delete 18 | title: "#删除插件 xxx" 19 | desc: 将名为 xxx 的js插件移动至回收站 20 | - icon: fuldelete 21 | title: "#彻底删除插件 xxx" 22 | desc: 将名为 xxx 的js插件直接移除 23 | - icon: restore 24 | title: "#恢复插件 xxx" 25 | desc: 从回收站恢复名为 xxx 的js插件 26 | - icon: rename 27 | title: "#插件 xxx 重命名 xxx" 28 | desc: 重命名名为 xxx 的插件 29 | - icon: debug 30 | title: "#测试(执行)命令 xxx" 31 | desc: 测试(执行)响应指令的插件,用于解决冲突 32 | - icon: upload 33 | title: "#查看插件 xxx" 34 | desc: 发送名为 xxx 的插件 35 | - group: 查看插件 36 | list: 37 | - icon: list 38 | title: "#插件列表" 39 | desc: 查看所有分组的插件 40 | - icon: command 41 | title: "#命令总览" 42 | desc: 查看所有启用插件的命令 43 | - icon: find 44 | title: "#查找插件 xxx" 45 | desc: 从所有分组查找名为 xxx 的js插件 46 | - icon: look 47 | title: "#查看回收站" 48 | desc: 查看回收站内的全部插件 49 | - icon: clear 50 | title: "#清空回收站" 51 | desc: 清空回收站内的全部插件 52 | - group: 插件分组 53 | list: 54 | - icon: gplist 55 | title: "#分组列表" 56 | desc: 查看所有的分组 57 | - icon: create 58 | title: "#创建分组 xxx" 59 | desc: 创建名为xxx的分组 60 | - icon: remove 61 | title: "#删除分组 xxx" 62 | desc: 删除名为xxx的分组 63 | - icon: set 64 | title: "# xxx设置分组+分组名" 65 | desc: 设置名为xxx插件的分组 66 | - icon: sync 67 | title: "#同步分组" 68 | desc: 同步plugins目录下的分组 69 | - group: 其他指令 70 | list: 71 | - icon: version 72 | title: "#插件版本" 73 | desc: 查看当前插件版本 74 | - icon: update 75 | title: "#插件(强制)更新" 76 | desc: 更新插件管理器 77 | - icon: help 78 | title: "#插件帮助" 79 | desc: 查看插件管理器帮助 80 | - icon: log 81 | title: "#插件更新日志" 82 | desc: 插件管理器的更新日志 -------------------------------------------------------------------------------- /defSet/js/set.yaml: -------------------------------------------------------------------------------- 1 | #默认安装分组 2 | default_group: example 3 | #单个js插件极限大小 4 | maxSize: 6291456 5 | #是否开启智能重命名 6 | auto_rename: true 7 | #是否开启智能安装 8 | auto_install: true 9 | #是否开启插件核验 10 | auto_check: true 11 | #插件安装等待时间,单位秒 12 | timeout: 60 13 | #是否尝试安装依赖 14 | install_package: true -------------------------------------------------------------------------------- /defSet/lexicon/set.yaml: -------------------------------------------------------------------------------- 1 | #插件重命名替换词库 2 | key: 3 | - v 4 | - V 5 | - "\\[.*?\\]" 6 | - "\\(.*?\\)" 7 | - "\\(.*?\\)" 8 | - "\\【.*?\\】" 9 | - "\\-" 10 | - "\\_" 11 | - "[0-9]+" 12 | - "\\." 13 | - "js" 14 | - "bak" -------------------------------------------------------------------------------- /defSet/version/set.yaml: -------------------------------------------------------------------------------- 1 | - { 2 | version: 2.0.0, 3 | data: 4 | [ 5 | 新增指令#测试执行命令, 6 | 重构全部文件,优化代码质量, 7 | 使用js解析器精准读取插件信息, 8 | 解决回收站路径混乱, 9 | 删除onlyJS,目前只会读js&bak文件 10 | ], 11 | } 12 | - { 13 | version: 1.3.1, 14 | data: 15 | [ 16 | 新增指令#命令列表, 17 | 新增指令#测试命令, 18 | 分组配置结构优化, 19 | 最大幅度减少插件读取次数, 20 | 修改插件启用停用描述, 21 | 修复若干问题 22 | ], 23 | } 24 | - { 25 | version: 1.3.0, 26 | data: 27 | [ 28 | 插件列表改为图片, 29 | 优化插件存储逻辑, 30 | 增加插件读取提取名字与简介, 31 | 调整图片渲染颜色, 32 | 增加对于git插件的支持, 33 | 修复权限控制bug, 34 | 增加对插件文件夹出现其他文件的识别 35 | ], 36 | } 37 | - { 38 | version: 1.2.4, 39 | data: 40 | [ 41 | 新增对于插件核验功能, 42 | 新增了插件管理权限控制, 43 | 增加覆盖安装的原分组识别, 44 | 大幅度优化了插件列表读取次数, 45 | 修复了一些不为人知的bug, 46 | 增加了对未知文件的识别, 47 | 更多贴心小提示(^_-)☆ 48 | ], 49 | } 50 | - { 51 | version: 1.2.3, 52 | data: 53 | [ 54 | 新增更多插件权限管理, 55 | 文件结构大幅调整, 56 | 减少了插件读取的次数, 57 | 优化了启动逻辑,防止报错, 58 | 新增彻底删除插件指令, 59 | 更多对于锅巴的支持 60 | ], 61 | } 62 | - { 63 | version: 1.2.2, 64 | data: 65 | [ 66 | 新增默认分组设置, 67 | 查找插件的函数增加精确查找, 68 | 安装插件的函数优化, 69 | 全部设置支持锅巴插件, 70 | ], 71 | } 72 | - { 73 | version: 1.2.1, 74 | data: 75 | [ 76 | 新增创建删除分组功能, 77 | 新增插件重命名功能, 78 | 插件帮助由文字说明改为图片, 79 | ], 80 | } 81 | - { 82 | version: 1.2.0, 83 | data: 84 | [ 85 | 重构插件管理器, 86 | 修改部分提示语, 87 | 将插件管理器更改为大插件, 88 | ], 89 | } 90 | - { 91 | version: 1.1.2, 92 | data: 93 | [ 94 | 新增了对多文件夹的支持, 95 | 引入JS插件分组概念, 96 | ], 97 | } 98 | - { 99 | version: 1.1.1, 100 | data: 101 | [ 102 | 修复智能命名bug, 103 | ], 104 | } 105 | - { 106 | version: 1.1.0, 107 | data: 108 | [ 109 | 新增智能覆盖安装, 110 | 新增插件安装智能重命名, 111 | ], 112 | } 113 | - { 114 | version: 1.0.4, 115 | data: 116 | [ 117 | 修复若干bug, 118 | 新增未知bug(bushi), 119 | ], 120 | } 121 | - { 122 | version: 1.0.3, 123 | data: 124 | [ 125 | 增加了清空回收站的询问, 126 | 新增js文件大小限制, 127 | ], 128 | } 129 | - { 130 | version: 1.0.2, 131 | data: 132 | [ 133 | 新增查找插件功能, 134 | ], 135 | } 136 | - { 137 | version: 1.0.1, 138 | data: 139 | [ 140 | 修复了插件处于停用状态无法删除的bug, 141 | ], 142 | } 143 | - { 144 | version: 1.0.0, 145 | data: 146 | [ 147 | 创建插件"xitian-plugin", 148 | 原型来自V2的插件管理器2.0, 149 | 新增对js插件的管理, 150 | ], 151 | } -------------------------------------------------------------------------------- /guoba.support.js: -------------------------------------------------------------------------------- 1 | import cfg from './module/config.js' 2 | import path from 'node:path' 3 | 4 | 5 | // 支持锅巴 6 | export function supportGuoba() { 7 | return { 8 | // 插件信息,将会显示在前端页面 9 | pluginInfo: { 10 | name: 'xitian-plugin', 11 | title: 'Xitian-Plugin', 12 | author: '@戏天', 13 | authorLink: 'https://github.com/XiTianGame', 14 | link: 'https://github.com/XiTianGame/xitian-plugin', 15 | isV3: true, 16 | isV2: false, 17 | description: '提供JS类的插件管理', 18 | // 显示图标,此为个性化配置 19 | icon: 'mdi:stove', 20 | // 图标颜色,例:#FF0000 或 rgb(255, 0, 0) 21 | iconColor: '#00e5d8', 22 | // 如果想要显示成图片,也可以填写图标路径(绝对路径) 23 | iconPath: path.resolve('./plugins/xitian-plugin/resources/img/icon.png'), 24 | }, 25 | // 配置项信息 26 | configInfo: { 27 | // 配置项 schemas 28 | schemas: [ 29 | /* 30 | //情况不对,好像锅巴这块有点问题 31 | { 32 | field: 'upload', 33 | label: '上传js插件', 34 | bottomHelpMessage: '上传后将会自动安装插件', 35 | component: 'Upload', 36 | componentProps: { 37 | accept: ['.js'], 38 | helpText: '上传后将会自动安装插件', 39 | maxNumber: 1, 40 | maxSize: cfg.getConfig('js', 'set').maxSize / (1024 ^ 2), 41 | api: async (data, callback) => { 42 | console.log(data) 43 | callback({ loaded: 100, total: 100 }) 44 | return { success: true, data: { success: true } } 45 | } 46 | }, 47 | },*/ 48 | { 49 | field: 'js.default_group', 50 | label: '默认安装分组', 51 | bottomHelpMessage: '设置后新增插件将安装到该分组', 52 | component: 'Select', 53 | componentProps: { 54 | options: cfg.getConfig('group', 'set').group.map(name => { 55 | return { label: name, value: name } 56 | }), 57 | placeholder: '请选择默认分组', 58 | }, 59 | }, 60 | { 61 | field: 'js.maxSize', 62 | label: '大小限制', 63 | helpMessage: '换算:1MB=1048576字节', 64 | bottomHelpMessage: '限制安装插件时的字节大小', 65 | component: 'InputNumber', 66 | required: true, 67 | componentProps: { 68 | placeholder: '请输入插件限制大小', 69 | }, 70 | }, 71 | { 72 | field: 'js.auto_rename', 73 | label: '智能重命名', 74 | bottomHelpMessage: '是否开启插件智能重命名', 75 | component: 'Switch', 76 | }, 77 | { 78 | field: 'js.auto_install', 79 | label: '智能安装', 80 | bottomHelpMessage: '是否开启插件智能安装', 81 | component: 'Switch', 82 | }, 83 | { 84 | field: 'js.auto_check', 85 | label: '插件核验', 86 | bottomHelpMessage: '是否开启插件智能核验', 87 | component: 'Switch', 88 | }, 89 | { 90 | field: 'js.timeout', 91 | label: '等待时间', 92 | helpMessage: '插件安装指令的等待时间', 93 | bottomHelpMessage: '请输入时间,单位秒', 94 | component: 'InputNumber', 95 | required: true, 96 | componentProps: { 97 | placeholder: '请输入等待时间', 98 | }, 99 | }, 100 | { 101 | field: 'group.bin', 102 | label: '回收站路径', 103 | helpMessage: '被删除的插件会进入回收站', 104 | bottomHelpMessage: '路径支持相对和绝对路径', 105 | component: 'Input', 106 | componentProps: { 107 | placeholder: '请输入回收站路径', 108 | }, 109 | }, 110 | { 111 | field: 'group.group', 112 | label: '分组列表', 113 | component: 'GTags', 114 | bottomHelpMessage: 'plugins目录下文件夹就是分组', 115 | componentProps: { 116 | allowAdd: true, 117 | allowDel: true, 118 | }, 119 | }, 120 | { 121 | field: 'exclude.rule', 122 | label: '排除文件夹', 123 | component: 'GTags', 124 | bottomHelpMessage: '被排除的文件夹在分组中不会进行同步', 125 | componentProps: { 126 | allowAdd: true, 127 | allowDel: true, 128 | }, 129 | }, 130 | { 131 | field: 'auth.grade', 132 | label: '操作权限', 133 | component: 'CheckboxGroup', 134 | bottomHelpMessage: '设置操作插件的权限', 135 | componentProps: { 136 | options: [ 137 | { label: '主人权限', value: 'master' }, 138 | { label: '群主权限', value: 'owner' }, 139 | { label: '群管理权限', value: 'admin' }, 140 | { label: '所有人权限', value: 'everyone' } 141 | ], 142 | placeholder: '请选择操作权限' 143 | }, 144 | }, 145 | { 146 | field: 'auth.accredit', 147 | label: '授权QQ', 148 | helpMessage: '如果为空就默认所有主人QQ', 149 | component: 'GTags', 150 | bottomHelpMessage: '授权插件操作的用户QQ', 151 | componentProps: { 152 | allowAdd: true, 153 | allowDel: true, 154 | }, 155 | }, 156 | { 157 | field: 'auth.group', 158 | label: '群聊操作', 159 | bottomHelpMessage: '是否允许在群内使用插件管理', 160 | component: 'Switch', 161 | }, 162 | ], 163 | 164 | // 获取配置数据方法(用于前端填充显示数据) 165 | getConfigData() { 166 | return { 167 | upload: {}, 168 | js: cfg.getConfig('js', 'set'), 169 | group: cfg.getConfig('group', 'set'), 170 | exclude: cfg.getConfig('exclude', 'set'), 171 | auth: cfg.getConfig('auth', 'set') 172 | } 173 | }, 174 | 175 | // 设置配置的方法(前端点确定后调用的方法) 176 | setConfigData(data, { Result }) { 177 | //保存数据 178 | Object.keys(data).forEach(key => { 179 | if (key.startsWith('js.')) { 180 | cfg.saveSet('js', 'set', 'config', data[key]) 181 | } 182 | if (key.startsWith('group.')) { 183 | cfg.saveSet('group', 'set', 'config', data[key]) 184 | } 185 | if (key.startsWith('exclude.')) { 186 | cfg.saveSet('exclude', 'set', 'config', data[key]) 187 | } 188 | if (key.startsWith('auth.')) { 189 | cfg.saveSet('auth', 'set', 'config', data[key]) 190 | } 191 | }); 192 | 193 | return Result.ok({}, '保存成功~') 194 | }, 195 | }, 196 | } 197 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import { execSync } from 'node:child_process' 2 | import config from './module/config.js' 3 | import fs from 'node:fs' 4 | 5 | if (!globalThis.segment) { 6 | globalThis.segment = (await import('oicq')).segment 7 | } 8 | 9 | let versionData = config.getdefSet('version', 'set'); 10 | 11 | const version = (versionData && versionData.length && versionData[0].version) || '1.0.0'; 12 | 13 | logger.info(`-----------^ω^----------`) 14 | logger.info(`插件管理器${version}初始化~`) 15 | 16 | if (!await import('acorn').catch(() => { })) { 17 | logger.warn('检测到未安装依赖包,尝试安装中...') 18 | let npm = 'npm' 19 | if (fs.existsSync('node_modules/.pnpm')) npm = 'pnpm' 20 | if (fs.existsSync('node_modules/.yarn-integrity')) npm = 'yarn' 21 | if (fs.existsSync('node_modules/.cache')) npm = 'bun' 22 | try { 23 | logger.info('安装完成,输出:\n' + execSync(`${npm} install`, { cwd: config.baseDir })) 24 | } catch (err) { 25 | logger.error('安装失败,错误信息:' + err) 26 | } 27 | } 28 | 29 | /**加载插件**/ 30 | const files = fs.readdirSync('./plugins/xitian-plugin/apps').filter((file) => file.endsWith('.js')) 31 | 32 | let ret = [] 33 | files.forEach((file) => { 34 | ret.push(import(`./apps/${file}`)) 35 | }); 36 | ret = await Promise.allSettled(ret) 37 | 38 | let apps = {} 39 | for (let i in files) { 40 | let name = files[i].replace('.js', '') 41 | 42 | if (ret[i].status != 'fulfilled') { 43 | logger.error(`载入插件错误:${logger.red(name)}`) 44 | logger.error(ret[i].reason) 45 | continue 46 | } 47 | apps[name] = ret[i].value[Object.keys(ret[i].value)[0]] 48 | } 49 | 50 | export { apps } 51 | /* 52 | * _oo0oo_ 53 | * o8888888o 54 | * 88' . '88 55 | * (| -_- |) 56 | * 0\ = /0 57 | * ___/`---'\___ 58 | * .' \\| |// '. 59 | * / \\||| : |||// \ 60 | * / _||||| -:- |||||- \ 61 | * | | \\\ - /// | | 62 | * | \_| ''\---/'' |_/ | 63 | * \ .-\__ '-' ___/-. / 64 | * ___'. .' /--.--\ `. .'___ 65 | * .'' '< `.___\_<|>_/___.' >' ''. 66 | * | | : `- \`.;`\ _ /`;.`/ - ` : | | 67 | * \ \ `_. \_ __\ /__ _/ .-` / / 68 | * =====`-.____`.___ \_____/___.-`___.-'===== 69 | * `=---=' 70 | * 71 | * 72 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 73 | * 74 | * 佛祖保佑 永无BUG 75 | */ -------------------------------------------------------------------------------- /module/base.js: -------------------------------------------------------------------------------- 1 | import cfg from '../../../lib/config/config.js' 2 | import config from './config.js' 3 | 4 | export default class base { 5 | constructor(e = {}) { 6 | this.e = e; 7 | this.userId = e?.user_id; 8 | this.model = 'xitian-plugin'; 9 | this._path = process.cwd().replace(/\\/g, '/'); 10 | this.yunzai = 'Yunzai-Bot' 11 | if (cfg.package.name === 'miao-yunzai') { 12 | this.yunzai = 'Miao-Yunzai' 13 | } else if (cfg.package.name === 'trss-yunzai') { 14 | this.yunzai = 'TRSS-Yunzai' 15 | } 16 | else if (cfg.package.name === 'a-yunzai') { 17 | this.yunzai = 'A-Yunzai' 18 | } 19 | } 20 | 21 | get prefix() { 22 | return `Yz:xitian-plugin:${this.model}:`; 23 | } 24 | 25 | /** 26 | * 截图默认数据 27 | * @param saveId html保存id 28 | * @param tplFile 模板html路径 29 | * @param pluResPath 插件资源路径 30 | */ 31 | get screenData() { 32 | return { 33 | saveId: this.userId, 34 | yunzai: this.yunzai + ' ' + cfg.package.version, 35 | xitian: `Xitian-Plugin ${config.package.version}`, 36 | tplFile: `./plugins/xitian-plugin/resources/html/${this.model}/${this.model}.html`, 37 | /** 绝对路径 */ 38 | pluResPath: `${this._path}/plugins/xitian-plugin/resources/`, 39 | }; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /module/config.js: -------------------------------------------------------------------------------- 1 | import chokidar from 'chokidar' 2 | import PATH from 'node:path' 3 | import lodash from 'lodash' 4 | import url from 'node:url' 5 | import fs from 'node:fs' 6 | import YAML from 'yaml' 7 | 8 | 9 | /** 配置文件 直接借鉴yunzai配置代码 */ 10 | class ConfigSet { 11 | constructor() { 12 | this.baseDir = PATH.join(url.fileURLToPath(import.meta.url), '../../') 13 | /** 默认设置 */ 14 | this.defSetPath = this.baseDir + '/defSet/'; 15 | this.defSet = {}; 16 | 17 | /** 用户设置 */ 18 | this.configPath = this.baseDir + '/config/'; 19 | this.config = {}; 20 | 21 | /** 监听文件 */ 22 | this.watcher = { config: {}, defSet: {} }; 23 | 24 | this.ignore = ['char.set', 'help.set', 'lexicon.set', 'version.set']; 25 | } 26 | 27 | /** 28 | * 确认权限 29 | * @param e 消息 30 | */ 31 | auth(e) { 32 | const permis = this.getConfig('auth', 'set') 33 | //是否允许群聊 34 | if (!permis.group && e.isGroup) { 35 | return false; 36 | } 37 | //获取授权QQ列表,没有就默认全部主人 38 | if (permis.grade.length == 0 && permis.accredit.length == 0) { 39 | permis.grade.push('master') 40 | } 41 | //判断权限 42 | if ( 43 | (permis.grade.includes('master') && e.isMaster) 44 | || (permis.grade.includes('owner') && e?.sender?.role == 'owner') 45 | || (permis.grade.includes('admin') && e?.sender?.role == 'admin') 46 | || (permis.grade.includes('everyone')) 47 | || (permis.accredit.includes(e.user_id)) 48 | ) { 49 | return true 50 | } 51 | //都不是就是未授权 52 | return false 53 | } 54 | 55 | /** 56 | * package.json 57 | * @returns {import('../package.json')} 58 | */ 59 | get package() { 60 | if (this._package) return this._package 61 | 62 | this._package = JSON.parse(fs.readFileSync(this.baseDir + '/package.json', 'utf8')) 63 | return this._package 64 | } 65 | 66 | /** package.json */ 67 | set package(data) { 68 | this._package = lodash.assign(this.package, data) 69 | fs.writeFileSync(this.baseDir + '/package.json', JSON.stringify(this._package, null, 2), 'utf8') 70 | return this._package 71 | } 72 | 73 | /** 74 | * 默认设置 75 | * @param {string} app 功能 76 | * @param {string} name 配置文件名称 77 | */ 78 | getdefSet(app, name) { 79 | return this.getYaml(app, name, 'defSet'); 80 | } 81 | 82 | /** 用户配置 */ 83 | getConfig(app, name) { 84 | if (this.ignore.includes(`${app}.${name}`)) return this.getdefSet(app, name); 85 | this.checkConfig(app, name) 86 | 87 | return { 88 | ...this.getdefSet(app, name), 89 | ...this.getYaml(app, name, 'config'), 90 | }; 91 | } 92 | 93 | /** 94 | * 获取配置yaml 95 | * @param {string} app 功能 96 | * @param {string} name 名称 97 | * @param {'config'|'defSet'} type 默认跑配置-defSet,用户配置-config 98 | */ 99 | getYaml(app, name, type = 'defSet') { 100 | const key = `${app}.${name}`; 101 | 102 | if (this[type][key]) return this[type][key].toJSON() 103 | 104 | this.checkConfig(app, name, type) 105 | const file = this.getFilePath(app, name, type) 106 | // 保留注释 107 | this[type][key] = YAML.parseDocument(fs.readFileSync(file, 'utf8')) 108 | 109 | this.watch(file, app, name, type) 110 | 111 | return this[type][key].toJSON() 112 | } 113 | 114 | /** 115 | * 获取配置文件路径 116 | * @param {string} app 功能 117 | * @param {string} name 名称 118 | * @param {'config'|'defSet'} type 配置类型 119 | * @returns 120 | */ 121 | getFilePath(app, name, type) { 122 | if (type == 'defSet') return `${this.defSetPath}${app}/${name}.yaml`; 123 | else return `${this.configPath}${app}.${name}.yaml`; 124 | } 125 | 126 | /** 127 | * 监听配置文件 128 | * @param {string} file 文件路径 129 | * @param {string} app 功能 130 | * @param {string} name 名称 131 | * @param {'config'|'defSet'} type 配置类型 132 | */ 133 | watch(file, app, name, type = 'defSet') { 134 | const key = `${app}.${name}`; 135 | 136 | if (this.watcher[type][key]) return; 137 | 138 | const watcher = chokidar.watch(file); 139 | watcher.on('change', () => { 140 | delete this[type][key]; 141 | logger.mark(`[修改配置文件][${type}][${app}][${name}]`); 142 | if (type == 'defSet') this.assign(app, name) 143 | }); 144 | 145 | this.watcher[type][key] = watcher; 146 | } 147 | 148 | /** 149 | * 检查是否存在配置文件 150 | * @param {string} app 功能 151 | * @param {string} name 名称 152 | * @param {'config'|'defSet'} type 配置类型 153 | */ 154 | hasConfig(app, name, type = 'config') { 155 | const file = this.getFilePath(app, name, type) 156 | return fs.existsSync(file) 157 | } 158 | 159 | /** 160 | * 检查配置文件 161 | * @param {string} app 功能 162 | * @param {string} name 名称 163 | * @param {'config'|'defSet'} type 配置类型 164 | */ 165 | checkConfig(app, name, type = 'config') { 166 | if (!this.hasConfig(app, name, type)) { 167 | if (type == 'defSet') { 168 | throw new Error(`不存在默认配置文件[${app}][${name}]`) 169 | } else { 170 | this.cpCfg(app, name) 171 | } 172 | } 173 | } 174 | 175 | /** 176 | * 复制配置文件 177 | * @param {string} app 功能 178 | * @param {string} name 名称 179 | * @param {boolean} force 覆盖原先设置 180 | */ 181 | cpCfg(app, name, force = false) { 182 | let set = this.getFilePath(app, name, 'config'); 183 | if (force || !fs.existsSync(set)) { 184 | fs.copyFileSync(this.getFilePath(app, name, 'defSet'), set); 185 | } 186 | } 187 | 188 | /** 189 | * 修改defSet后覆写config 190 | * @param {string} app 功能 191 | * @param {string} name 名称 192 | */ 193 | assign(app, name) { 194 | const file = this.getFilePath(app, name, 'config') 195 | if (!fs.existsSync(file)) { 196 | this.cpCfg(app, name) 197 | return true 198 | } 199 | const config = this.getConfig(app, name) 200 | this.cpCfg(app, name, true) 201 | delete this.config[`${app}.${name}`]//太快了要手动删一下 202 | this.saveSet(app, name, 'config', config) 203 | return true 204 | } 205 | 206 | /** 207 | * 保存设置 208 | * @param {string} app 功能 209 | * @param {string} name 名称 210 | * @param {'config'|'defSet'} type 类型 211 | * @param {object} data 数据 212 | */ 213 | saveSet(app, name, type, data) { 214 | const key = `${app}.${name}`; 215 | const file = this.getFilePath(app, name, type) 216 | if (!data) { 217 | logger.mark(`[重置配置文件][${type}][${app}][${name}]`) 218 | fs.existsSync(file) && fs.unlinkSync(file) 219 | } else if (lodash.isPlainObject(data)) { 220 | if (!this[type][key]) this.getYaml(app, name, type) 221 | /** 222 | * 递归设置数据 223 | * @param {object} obj 224 | * @param {Array} path 225 | */ 226 | const setIn = (obj, path = []) => { 227 | lodash.forEach(obj, (value, k) => { 228 | if (lodash.isPlainObject(value)) { 229 | setIn(value, path.concat(k)) 230 | } else { 231 | this[type][key].setIn(path.concat(k), value) 232 | } 233 | }) 234 | } 235 | setIn(data) 236 | fs.writeFileSync(file, this[type][key].toString(), 'utf8') 237 | } 238 | return true 239 | } 240 | } 241 | 242 | export default new ConfigSet(); 243 | -------------------------------------------------------------------------------- /module/help.js: -------------------------------------------------------------------------------- 1 | import cfg from '../../../lib/config/config.js' 2 | import config from './config.js' 3 | import base from './base.js' 4 | 5 | export default class Help extends base { 6 | constructor(e) { 7 | super(e); 8 | this.model = 'help'; 9 | } 10 | 11 | static async get(e) { 12 | let html = new Help(e); 13 | return await html.getData(); 14 | } 15 | 16 | async getData() { 17 | let helpData = config.getdefSet('help', 'set'); 18 | 19 | let groupCfg = cfg.getGroup(this.group_id); 20 | 21 | if (groupCfg.disable && groupCfg.disable.length) { 22 | helpData.map((item) => { 23 | if (groupCfg.disable.includes(item.group)) { 24 | item.disable = true; 25 | } 26 | return item; 27 | }); 28 | } 29 | 30 | let versionData = config.getdefSet('version', 'set'); 31 | 32 | const version = (versionData && versionData.length && versionData[0].version) || '1.0.0'; 33 | 34 | return { 35 | ...this.screenData, 36 | saveId: 'help', 37 | version: version, 38 | helpData, 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /module/install.js: -------------------------------------------------------------------------------- 1 | import common from '../../../lib/common/common.js' 2 | import { Restart } from '../../other/restart.js' 3 | import { exec } from 'child_process' 4 | import search from './loader.js' 5 | import config from './config.js' 6 | import fetch from 'node-fetch' 7 | import * as acorn from 'acorn' 8 | import path from 'node:path' 9 | import fs from 'node:fs' 10 | 11 | class install { 12 | get config() { 13 | return config.getConfig('js', 'set') 14 | } 15 | 16 | get groups() { 17 | return config.getConfig('group', 'set') 18 | } 19 | 20 | get char() { 21 | return config.getdefSet('char', 'set') 22 | } 23 | 24 | get lexicon() { 25 | return config.getdefSet('lexicon', 'set') 26 | } 27 | 28 | rename(oldName) { 29 | const ext = path.extname(oldName) 30 | oldName = oldName.replace(new RegExp(ext + '$'), '') 31 | for (let item of this.lexicon.key) { 32 | oldName = oldName.replace(new RegExp(item, 'g'), ''); 33 | } 34 | return oldName + ext 35 | } 36 | 37 | /** 38 | * 选择安装文件夹 39 | * @param savePath 安装路径 40 | * @param sameplugin 查找的相似插件列表 41 | */ 42 | choose(savePath, sameplugin) { 43 | //设置组名 44 | const changeGroup = (name) => { 45 | const baseDir = path.dirname(path.dirname(savePath)) 46 | const saveName = path.basename(savePath) 47 | savePath = path.join(baseDir, name, saveName) 48 | } 49 | switch (sameplugin.length) { 50 | case 0: 51 | //默认路径 52 | break 53 | case 1: 54 | if (sameplugin[0].state !== '已删除') { 55 | changeGroup(sameplugin[0].path) 56 | } 57 | break 58 | default: 59 | for (let plugin of sameplugin) { 60 | if (plugin.state !== '已删除') { 61 | changeGroup(plugin.path) 62 | } 63 | } 64 | break 65 | } 66 | return savePath 67 | } 68 | 69 | /** 70 | * 进行插件安装 71 | * @param e 消息事件 72 | * @param fileUrl 文件下载链接 73 | * @param savePath 安装路径 74 | */ 75 | async install(e, fileUrl, savePath) { 76 | if (this.config.auto_rename) { 77 | //重命名 78 | savePath = path.join(path.dirname(savePath), this.rename(path.basename(savePath, '.js'))) 79 | } 80 | 81 | //智能安装 82 | if (this.config.auto_install) { 83 | let sameplugin = await search.find(path.basename(savePath, '.js'), 1);//提取插件关键名字 84 | savePath = this.choose(savePath, sameplugin); 85 | //下载文件 86 | //根据不同匹配数来运行不同安装操作 87 | switch (sameplugin.length) { 88 | case 0: 89 | if (!await common.downFile(fileUrl, savePath + '.bak')) { 90 | e.reply('安装插件错误:文件下载失败') 91 | return 92 | } 93 | //核验插件 94 | if (await this.check(e, savePath + '.bak')) { 95 | e.reply('此插件已安装,立即生效') 96 | } 97 | break; 98 | case 1: 99 | e.reply(`检测到相似插件:${sameplugin[0].key},正在执行覆盖安装`) 100 | //根据插件不同的状态分类处理 101 | switch (sameplugin[0].state) { 102 | case '启用': 103 | fs.renameSync(sameplugin[0].Abpath, path.join(this.groups.bin, `${sameplugin[0].file}.bak`)) 104 | break; 105 | case '停用': 106 | fs.renameSync(sameplugin[0].Abpath, path.join(this.groups.bin, sameplugin[0].file)) 107 | break; 108 | default://回收站的不做处理 109 | } 110 | if (!await common.downFile(fileUrl, savePath + '.bak')) { 111 | e.reply('安装插件错误:文件下载失败') 112 | return 113 | } 114 | await common.sleep(200);//防止消息重叠 115 | //核验插件 116 | if (await this.check(e, savePath + '.bak')) { 117 | e.reply('此插件已覆盖安装,立即生效') 118 | } 119 | break; 120 | default: 121 | e.reply('检测到多个相似插件,正在进行处理...') 122 | for (let sameItem of sameplugin) { 123 | switch (sameItem.state) { 124 | case '启用': 125 | fs.renameSync(sameItem.Abpath, path.join(this.groups.bin, `${sameItem.file}.bak`)) 126 | break; 127 | case '停用': 128 | fs.renameSync(sameItem.Abpath, path.join(this.groups.bin, sameItem.file)) 129 | break; 130 | default://回收站的会直接删除 131 | fs.unlinkSync(sameItem.Abpath) 132 | } 133 | } 134 | if (!await common.downFile(fileUrl, savePath + '.bak')) { 135 | e.reply('安装插件错误:文件下载失败') 136 | return 137 | } 138 | await common.sleep(200);//防止消息重叠 139 | //核验插件 140 | if (await this.check(e, savePath + '.bak')) { 141 | e.reply('处理完成!此插件已覆盖安装,立即生效') 142 | } 143 | } 144 | } else { 145 | //没开启智能安装直接无脑覆盖 146 | //下载文件 147 | await common.downFile(fileUrl, savePath + '.bak') 148 | //核验插件 149 | //核验插件 150 | if (await this.check(e, savePath + '.bak')) { 151 | e.reply('此插件已安装,立即生效') 152 | } 153 | } 154 | } 155 | 156 | /** 157 | * 对插件进行核验 158 | * @param e 消息 159 | * @param {string} filepath 插件路径 160 | */ 161 | async check(e, filepath) { 162 | if (!this.config.auto_check) { 163 | fs.renameSync(filepath, filepath.substring(0, filepath.length - 4)); 164 | return true; 165 | } 166 | try { 167 | //读取插件 168 | const esTree = acorn.parse(fs.readFileSync(filepath, 'utf8')) 169 | //导出的东西 170 | const imports = [] 171 | 172 | for (const nodeRoot of esTree.body) { 173 | if (nodeRoot.type === 'ImportDeclaration') { 174 | switch (nodeRoot.source.value) { 175 | case 'fs': 176 | case 'node:fs': 177 | imports.push('文件系统 - 可以执行文件操作') 178 | break 179 | case 'child_process': 180 | case 'node:child_process': 181 | imports.push('子进程 - 可以运行命令') 182 | } 183 | } 184 | //导出了一个东西 185 | if (nodeRoot.type === 'ExportNamedDeclaration') { 186 | //导出的不是class(这个导出应该不会加载,会报错) 187 | if (nodeRoot.declaration.type !== 'ClassDeclaration') { 188 | e.reply(`检测到非法导出类型:${nodeRoot.declaration.type},插件管理器已将其停用`) 189 | return false 190 | } 191 | } 192 | } 193 | 194 | //去除.bak,启用该插件 195 | fs.renameSync(filepath, filepath.substring(0, filepath.length - 4)) 196 | const msg = ['核验完成!该插件无问题'] 197 | if (imports.length) msg.push('\n插件调用了以下敏感模块:\n' + imports.join('\n')) 198 | e.reply(msg) 199 | return true 200 | } catch (err) { 201 | e.reply(`插件读取出现问题!核验已终止。错误信息:$${err}`) 202 | fs.renameSync(filepath, filepath.substring(0, filepath.length - 4)) 203 | return true 204 | } 205 | } 206 | 207 | /** 208 | * 安装github插件 209 | * @param url 插件地址 210 | * @param e 消息 211 | */ 212 | async clone(e, url) { 213 | if (!url.endsWith('.git')) { 214 | url = url + '.git'; 215 | } 216 | /**插件名 */ 217 | let name = path.basename(new URL(url).pathname.replace(/.git$/, '')) 218 | e.reply(`开始安装:${name}`) 219 | 220 | /**检查链接和插件 */ 221 | if (!await this.checkurl(url)) { 222 | e.reply(`安装失败!无法连接到目标仓库`) 223 | return true; 224 | } 225 | 226 | /**检查已安装情况 */ 227 | if (fs.existsSync(path.join('./plugins', name))) { 228 | e.reply(`已经安装该插件,若该插件无法运行,可以尝试卸载后重装`) 229 | return true 230 | } 231 | 232 | /**检查git安装 */ 233 | if (!await this.checkGit(e)) return true 234 | 235 | /**执行安装命令 */ 236 | const result = await this.execSync(`git clone ${url}`, { cwd: path.join(process.cwd(), 'plugins') }) 237 | 238 | if (result.error) { 239 | await e.reply(`安装${name}失败,错误信息:\n${result.error}`) 240 | return true 241 | } 242 | 243 | if (this.config.install_package && fs.existsSync(path.join('./plugins', name, 'package.json'))) { 244 | await e.reply(`安装插件${name}依赖...`) 245 | const res = await this.addPak(path.join(process.cwd(), 'plugins', name)) 246 | if (res.error) { 247 | await e.reply(`安装依赖失败,错误信息:\n${res.error}`) 248 | } else { 249 | await e.reply(`安装依赖成功`) 250 | } 251 | } 252 | /**重启云崽 */ 253 | await e.reply('安装成功!即将进行重启...') 254 | this.restart(e) 255 | return true 256 | } 257 | 258 | /** 259 | * 检查插件地址有效性 260 | * @param {string} url 插件地址 261 | */ 262 | async checkurl(url) { 263 | //检查链接 264 | try { 265 | const response = await fetch(url) 266 | if (response.status !== 200) return false 267 | return true 268 | } catch (err) { 269 | return false 270 | } 271 | } 272 | 273 | /** 274 | * 检查git是否安装 275 | */ 276 | async checkGit(e) { 277 | let ret = await this.execSync('git --version', { encoding: 'utf-8' }).then(res => res.stdout) 278 | if (!ret || !ret.includes('git version')) { 279 | await e.reply('请先安装git') 280 | return false 281 | } 282 | return true 283 | } 284 | 285 | async addPak(cwd = process.cwd()) { 286 | let npm = 'npm' 287 | if (fs.existsSync('node_modules/.pnpm')) npm = 'pnpm' 288 | if (fs.existsSync('node_modules/.yarn-integrity')) npm = 'yarn' 289 | if (fs.existsSync('node_modules/.cache')) npm = 'bun' 290 | return this.execSync(`${npm} install`, { cwd }) 291 | } 292 | 293 | /** 294 | * 执行cmd命令 295 | * @param {string} cmd git命令 296 | * @returns {Promise<{error:Error|null,stdout:string,stderr:string}>} 297 | */ 298 | async execSync(cmd, options = {}) { 299 | return new Promise(resolve => { 300 | exec(cmd, { ...options, windowsHide: true }, (error, stdout, stderr) => { 301 | resolve({ error, stdout, stderr }) 302 | }) 303 | }) 304 | } 305 | 306 | /** 307 | * 重启云崽 308 | */ 309 | restart(e) { 310 | new Restart(e).restart() 311 | } 312 | } 313 | 314 | export default new install() -------------------------------------------------------------------------------- /module/list.js: -------------------------------------------------------------------------------- 1 | import loader from './loader.js' 2 | import config from './config.js' 3 | import base from './base.js' 4 | 5 | 6 | 7 | export default class list extends base { 8 | constructor(e) { 9 | super(e); 10 | this.model = 'list'; 11 | } 12 | 13 | get groups() { 14 | return config.getConfig('group', 'set') 15 | } 16 | 17 | async getData() { 18 | return { 19 | ...this.screenData, 20 | saveId: 'list', 21 | quality: 100, 22 | listData: this.dealData(), 23 | } 24 | } 25 | 26 | dealData() { 27 | const data = [] 28 | this.groups.group.forEach(group => { 29 | data.push({ 30 | group: group, 31 | list: loader.find('', group) 32 | }) 33 | }) 34 | return data 35 | } 36 | } -------------------------------------------------------------------------------- /module/loader.js: -------------------------------------------------------------------------------- 1 | import config from './config.js' 2 | import chokidar from 'chokidar' 3 | import * as acorn from 'acorn' 4 | import PATH from 'node:path' 5 | import lodash from 'lodash' 6 | import fs from 'node:fs' 7 | 8 | class pluginLoader { 9 | constructor() { 10 | /** @type {Map} 插件储存 */ 11 | this.plugins = new Map() 12 | /** 监听文件夹 */ 13 | this.dir = './plugins' 14 | /** 垃圾桶 */ 15 | const bin = config.getConfig('group', 'set').bin 16 | this.bin = PATH.relative(this.dir, bin) 17 | fs.existsSync(bin) || fs.mkdirSync(bin, { recursive: true }) 18 | /** 插件包标志 */ 19 | this.pkgFlag = ['index.js'] 20 | fs.existsSync(this.dir) || fs.mkdirSync(this.dir, { recursive: true }) 21 | 22 | /** @type {Set} 插件包文件夹 */ 23 | this.pluginPkg = new Set() 24 | /** @type {boolean} 插件是否加载完成 */ 25 | this.loadReady = false 26 | //理论上加载一次就行 27 | this.load(false) 28 | } 29 | 30 | /** 31 | * 搜索标志ALL,查找全部 32 | */ 33 | ALL = Symbol('ALL') 34 | 35 | /** 36 | * 搜索标志GROUP,除了回收站都查找 37 | */ 38 | GROUP = Symbol('GROUP') 39 | 40 | /** 41 | * 搜索标志BIN,只查回收站 42 | */ 43 | BIN = Symbol('BIN') 44 | 45 | /** 46 | * 默认分组 47 | * @returns {string} 48 | */ 49 | get defGroup() { 50 | return config.getConfig('js', 'set').default_group || 'example' 51 | } 52 | 53 | /** 54 | * 加载插件 55 | * @param {boolean} isRefresh 是否刷新 56 | */ 57 | async load(isRefresh = false) { 58 | if (this.watcher) { 59 | if (!isRefresh) return 60 | /**清空监听 */ 61 | await this.watcher.close() 62 | this.pluginPkg.clear() 63 | } 64 | 65 | logger.info('[插件管理器]加载插件中...') 66 | 67 | this.watcher = chokidar.watch( 68 | [ 69 | './', 70 | this.bin 71 | ], 72 | { 73 | depth: 1, 74 | cwd: this.dir, 75 | ignorePermissionErrors: true 76 | } 77 | ).on('all', (event, path) => { 78 | /* 是否是回收站 */ 79 | const { dir, base, ext } = PATH.parse(path) 80 | if(!['addDir', 'unlinkDir'].includes(event) && !['.js', '.bak'].includes(ext)) return 81 | this[`deal${lodash.upperFirst(event)}`](dir, base).catch(err => { 82 | logger.error('[插件管理器]处理插件错误:', err) 83 | }) 84 | }).on('ready', () => { 85 | this.loadReady = true 86 | logger.info(`[插件管理器]插件加载完成<${this.plugins.size}>个`) 87 | }).on('error', (err) => { 88 | logger.error('[插件管理器]监听插件错误:', err) 89 | }) 90 | } 91 | 92 | /** 93 | * 根据名字查找插件 94 | * @param {string} name 插件名 95 | * @param {symbol|string} type 查找类型 96 | * @param {boolean} strict 是否精确查找 97 | */ 98 | find(name, type = this.ALL, strict = false) { 99 | const result = [] 100 | this.plugins.forEach(pluginInfo => { 101 | if (type === this.GROUP && pluginInfo.group === this.bin) return 102 | if (type === this.BIN && pluginInfo.group !== this.bin) return 103 | if (typeof type === 'string' && pluginInfo.group !== type) return 104 | if (strict && pluginInfo.key === name) { 105 | result.push(pluginInfo) 106 | } else if (pluginInfo.key.includes(name)) { 107 | result.push(pluginInfo) 108 | } 109 | }) 110 | return result 111 | } 112 | 113 | async dealAdd(dirName, fileName) { 114 | if (this.pluginPkg.has(dirName) && !this.pkgFlag.includes(fileName)) return 115 | 116 | if (PATH.dirname(dirName) === this.bin && fileName) return 117 | 118 | this.sendLog('插件管理器', this.loadReady ? '新增插件' : '载入插件', ...arguments) 119 | 120 | let key = `${dirName}/${fileName}/` 121 | 122 | const stateMap = { 123 | '.js': '启用', 124 | '.bak': '停用' 125 | } 126 | const origin = (fileName.match(/^\[.*?\]/) || [this.defGroup])[0].replace(/^\[|\]$/g, '') 127 | const pluginInfo = { 128 | type: PATH.extname(fileName).replace('.', '') || '???', 129 | file: fileName, 130 | key: fileName.replace(/^\[.*?\]|.js(.bak)?$/g, ''), 131 | group: dirName, 132 | Abpath: PATH.resolve(this.dir, dirName, fileName), 133 | name: '???', 134 | dsc: '???', 135 | state: (dirName === this.bin ? '已删除' : stateMap[PATH.extname(fileName)] || '???'), 136 | origin: origin, 137 | imports: [] 138 | } 139 | 140 | try { 141 | //ps:插件包先咕一下 142 | if (this.pkgFlag.includes(fileName)) return true 143 | 144 | const code = await fs.promises.readFile(PATH.join(this.dir, dirName, fileName), 'utf8') 145 | 146 | const esTree = acorn.parse(code, { 147 | ecmaVersion: 'latest', 148 | sourceType: 'module', 149 | }) 150 | 151 | esTree.body.forEach(nodeRoot => { 152 | if (nodeRoot.type === 'ImportDeclaration') { 153 | pluginInfo.imports.push(nodeRoot.source.value || '') 154 | } 155 | //导出了一个东西 156 | if (nodeRoot.type === 'ExportNamedDeclaration') { 157 | //导出的不是class(这个导出应该不会加载) 158 | if (nodeRoot.declaration.type !== 'ClassDeclaration') return 159 | //没有继承的class(还有高手?) 160 | if (!nodeRoot.declaration.superClass) return 161 | const classBody = nodeRoot.declaration.body 162 | //构造函数 163 | const constructorFnc = classBody.body.find(method => method.type === 'MethodDefinition' && method.kind === 'constructor') 164 | if (!constructorFnc) return 165 | //构造函数代码块 166 | const constructorBlock = constructorFnc.value.body 167 | //super函数 168 | const superFnc = constructorBlock.body.find(express => express.type === 'ExpressionStatement' && express.expression.type === 'CallExpression' && express.expression.callee?.type === 'Super') 169 | if (!superFnc) return 170 | //传入super函数的data 171 | const superData = superFnc.expression.arguments[0] 172 | //传入的第一参数不是对象 173 | if (superData?.type !== 'ObjectExpression') return 174 | superData.properties.forEach(item => { 175 | if (item.type !== 'Property') return 176 | if (item.key?.name === 'name') pluginInfo.name = item.value?.value || '???' 177 | if (item.key?.name === 'dsc') pluginInfo.dsc = item.value?.value || '???' 178 | //还能解出来其他东西,但用不上 179 | }) 180 | } 181 | }) 182 | } catch (err) { 183 | logger.error(`[插件管理器]加载插件< ${key} >错误:`, err) 184 | } 185 | this.plugins.set(key, pluginInfo) 186 | } 187 | 188 | async dealUnlink(dirName, fileName) { 189 | if (this.pluginPkg.has(dirName) && this.pkgFlag.includes(fileName)) this.pluginPkg.delete(dirName) 190 | 191 | this.sendLog('插件管理器', '卸载插件', ...arguments) 192 | 193 | let key = `${dirName}/${fileName}/` 194 | 195 | this.plugins.delete(key) 196 | } 197 | 198 | async dealChange(dirName, fileName) { 199 | if (this.pluginPkg.has(dirName) && !this.pkgFlag.includes(fileName)) return 200 | 201 | if (PATH.dirname(dirName) === this.bin && fileName) return 202 | 203 | this.sendLog('插件管理器', '修改插件', ...arguments) 204 | 205 | let key = `${dirName}/${fileName}/` 206 | 207 | this.plugins.delete(key) 208 | 209 | const stateMap = { 210 | '.js': '启用', 211 | '.bak': '停用' 212 | } 213 | const origin = (fileName.match(/^\[.*?\]/) || [this.defGroup])[0].replace(/^\[|\]$/g, '') 214 | const pluginInfo = { 215 | type: PATH.extname(fileName).replace('.', '') || '???', 216 | file: fileName, 217 | key: PATH.basename(fileName), 218 | group: dirName, 219 | Abpath: PATH.resolve(this.dir, dirName, fileName), 220 | name: '???', 221 | dsc: '???', 222 | state: (dirName === this.bin ? '已删除' : stateMap[PATH.extname(fileName)] || '???'), 223 | origin: origin, 224 | imports: [] 225 | } 226 | 227 | try { 228 | //ps:插件包先咕一下 229 | if (this.pkgFlag.includes(fileName)) return true 230 | 231 | const code = await fs.promises.readFile(PATH.join(this.dir, dirName, fileName), 'utf8') 232 | 233 | const esTree = acorn.parse(code, { 234 | ecmaVersion: 'latest', 235 | sourceType: 'module', 236 | }) 237 | 238 | esTree.body.forEach(nodeRoot => { 239 | if (nodeRoot.type === 'ImportDeclaration') { 240 | pluginInfo.imports.push(nodeRoot.source.value || '') 241 | } 242 | //导出了一个东西 243 | if (nodeRoot.type === 'ExportNamedDeclaration') { 244 | //导出的不是class(这个导出应该不会加载) 245 | if (nodeRoot.declaration.type !== 'ClassDeclaration') return 246 | //没有继承的class(还有高手?) 247 | if (!nodeRoot.declaration.superClass) return 248 | const classBody = nodeRoot.declaration.body 249 | //构造函数 250 | const constructorFnc = classBody.body.find(method => method.type === 'MethodDefinition' && method.kind === 'constructor') 251 | if (!constructorFnc) return 252 | //构造函数代码块 253 | const constructorBlock = constructorFnc.value.body 254 | //super函数 255 | const superFnc = constructorBlock.body.find(express => express.type === 'ExpressionStatement' && express.expression.type === 'CallExpression' && express.expression.callee?.type === 'Super') 256 | if (!superFnc) return 257 | //传入super函数的data 258 | const superData = superFnc.expression.arguments[0] 259 | //传入的第一参数不是对象 260 | if (superData?.type !== 'ObjectExpression') return 261 | superData.properties.forEach(item => { 262 | if (item.type !== 'Property') return 263 | if (item.key?.name === 'name') pluginInfo.name = item.value?.value || '???' 264 | if (item.key?.name === 'dsc') pluginInfo.dsc = item.value?.value || '???' 265 | //还能解出来其他东西,但用不上 266 | }) 267 | } 268 | }) 269 | } catch (err) { 270 | logger.error('[插件管理器]加载插件错误:', err) 271 | } 272 | this.plugins.set(key, pluginInfo) 273 | } 274 | 275 | async dealAddDir(dirName, fileName) { 276 | if (dirName) return; 277 | if (this.pkgFlag.find(name => fs.existsSync(PATH.join(this.dir, fileName, name)))) this.pluginPkg.add(fileName) 278 | this.sendLog('插件管理器', this.loadReady ? '新增插件包' : '载入插件包', ...arguments) 279 | } 280 | 281 | async dealUnlinkDir(dirName, fileName) { 282 | if (dirName) return; 283 | this.pluginPkg.delete(fileName) 284 | this.sendLog('插件管理器', '删除插件包', ...arguments) 285 | } 286 | 287 | /** 288 | * 发送日志 289 | * @param {...any} arg 要拼接的字符数组 290 | */ 291 | sendLog(...arg) { 292 | const msg = lodash.compact(arg).map(val => `[${val}]`).join('') 293 | logger[this.loadReady ? 'info' : 'debug'](msg) 294 | } 295 | } 296 | 297 | export default new pluginLoader() -------------------------------------------------------------------------------- /module/uninstall.js: -------------------------------------------------------------------------------- 1 | import { Restart } from '../../other/restart.js' 2 | import fs from 'node:fs' 3 | 4 | class uninstall { 5 | /** 6 | * 删除插件 7 | * @param e 消息 8 | */ 9 | async removePlugin(e) { 10 | let name = e.msg.replace(/#|彻底|删除插件/g, ""); 11 | let path = `./plugins/${name}`; 12 | if (!fs.existsSync(path)) return false; 13 | //包含git文件夹 14 | if (!fs.statSync(`${path}/.git`).isDirectory()) return false; 15 | fs.rmdirSync(path, { recursive: true }); 16 | await e.reply(`成功删除:${name}`); 17 | new Restart(e).restart(); 18 | return true; 19 | } 20 | } 21 | 22 | export default new uninstall() -------------------------------------------------------------------------------- /module/version.js: -------------------------------------------------------------------------------- 1 | import base from './base.js' 2 | 3 | export default class Version extends base { 4 | constructor(e) { 5 | super(e); 6 | this.model = 'version' 7 | } 8 | 9 | /** 生成版本信息图片 */ 10 | async getData(versionData) { 11 | const version = (versionData && versionData.length && versionData[0].version) || '1.0.0' 12 | let data = { 13 | ...this.screenData, 14 | userId: version, 15 | quality: 100, 16 | saveId: version, 17 | versionData: versionData, 18 | }; 19 | return data; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "xitian-plugin", 3 | "version": "2.0.0", 4 | "author": "Xitian", 5 | "description": "一个平平无奇的插件管理器", 6 | "type": "module", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/XiTianGame/xitian-plugin.git" 10 | }, 11 | "dependencies": { 12 | "acorn": "^8.12.1" 13 | } 14 | } -------------------------------------------------------------------------------- /resources/font/HYWenHei-55W.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/font/HYWenHei-55W.ttf -------------------------------------------------------------------------------- /resources/font/tttgbnumber.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/font/tttgbnumber.ttf -------------------------------------------------------------------------------- /resources/html/help/help.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: "tttgbnumber"; 3 | src: url("../../font/tttgbnumber.ttf"); 4 | font-weight: normal; 5 | font-style: normal; 6 | } 7 | @font-face { 8 | font-family: "genshin"; 9 | src: url("../../font/HYWenHei-55W.ttf"); 10 | font-weight: normal; 11 | font-style: normal; 12 | } 13 | * { 14 | margin: 0; 15 | padding: 0; 16 | box-sizing: border-box; 17 | user-select: none; 18 | } 19 | body { 20 | font-family: sans-serif; 21 | font-size: 16px; 22 | width: 788px; 23 | color: #000000; 24 | transform: scale(1.5); 25 | transform-origin: 0 0; 26 | } 27 | .container { 28 | width: 788px; 29 | padding: 20px 15px 10px 15px; 30 | background-image: url(../../img/bg.jpg); 31 | background-size: 100%; 32 | } 33 | .head_box { 34 | border-radius: 15px; 35 | font-family: 'tttgbnumber'; 36 | padding: 10px 20px; 37 | position: relative; 38 | color: rgb(0, 85, 255);/*大标题颜色*/ 39 | box-shadow: 0 5px 10px 0 rgba(0, 81, 255, 0.5); 40 | } 41 | .head_box .id_text { 42 | font-size: 24px; 43 | } 44 | .head_box .day_text { 45 | font-size: 20px; 46 | } 47 | .head_box .genshin_logo { 48 | position: absolute; 49 | top: -10px; 50 | right: 15px; 51 | width: 97px; 52 | } 53 | 54 | 55 | .data_box { 56 | border-radius: 15px; 57 | font-family: 'genshin'; 58 | margin-top: 20px; 59 | margin-bottom: 15px; 60 | padding: 20px 0px 5px 0px; 61 | background: rgba(255, 255, 255, 0.5); 62 | box-shadow: 0 0 1px 0 rgb(36, 36, 36), 2px 2px 4px 0 rgba(180, 180, 180, 0.8); 63 | position: relative; 64 | } 65 | .tab_lable { 66 | position: absolute; 67 | top: -10px; 68 | left: -8px; 69 | background-color: rgb(0, 85, 255); 70 | box-shadow: 0 0 1px 0 rgb(0, 0, 0), 2px 2px 4px 0 rgba(0, 166, 255, 0.8); 71 | color: rgb(255, 255, 255); 72 | font-family: 'genshin'; 73 | font-size: 14px; 74 | padding: 3px 10px; 75 | border-radius: 15px 0px 15px 15px; 76 | z-index: 20; 77 | } 78 | 79 | .list{ 80 | display: flex; 81 | justify-content: flex-start; 82 | flex-wrap: wrap; 83 | } 84 | 85 | .list .item { 86 | width: 235px; 87 | display: flex; 88 | align-items: center; 89 | color: rgb(0, 80, 255); 90 | background: transparent; 91 | box-shadow: 0 0 1px 0 rgb(0, 0, 0), 2px 2px 4px 0 rgba(0, 120, 255, 0.8); 92 | padding: 8px 6px 8px 6px; 93 | border-radius: 8px; 94 | margin: 0 0px 10px 10px; 95 | } 96 | .list .item .icon{ 97 | width: 30px; 98 | height: 30px; 99 | background-repeat: no-repeat; 100 | background-size: 100% 100%; 101 | position: relative; 102 | flex-shrink: 0; 103 | } 104 | .list .item .title{ 105 | font-size: 16px; 106 | margin-left: 6px; 107 | line-height: 20px; 108 | } 109 | .list .item .title .text{ 110 | font-family: 'genshin'; 111 | white-space: nowrap; 112 | } 113 | .list .item .title .dec{ 114 | font-size: 12px; 115 | color: rgb(255, 0, 120); 116 | margin-top: 2px; 117 | } 118 | .logo{ 119 | text-align: center; 120 | font-size: 14px; 121 | color: rgb(0, 125, 255); 122 | font-family: 'genshin'; 123 | } -------------------------------------------------------------------------------- /resources/html/help/help.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | {{@headStyle}} 16 | 17 | 18 |
19 |
20 |
Xitian-Plugin
21 |

使用说明-v{{version}}

22 |
23 | {{each helpData val}} 24 |
25 |
26 | {{val.group}}{{val.disable ? ' - 已禁用' : ''}} 27 |
28 |
29 | {{each val.list item}} 30 |
31 | 32 |
33 |
{{@item.title}}
34 |
{{item.desc}}
35 |
36 |
37 | {{/each}} 38 |
39 |
40 | {{/each}} 41 | 42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /resources/html/list/list.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: "tttgbnumber"; 3 | src: url("../../font/tttgbnumber.ttf"); 4 | font-weight: normal; 5 | font-style: normal; 6 | } 7 | @font-face { 8 | font-family: "genshin"; 9 | src: url("../../font/HYWenHei-55W.ttf"); 10 | font-weight: normal; 11 | font-style: normal; 12 | } 13 | * { 14 | margin: 0; 15 | padding: 0; 16 | box-sizing: border-box; 17 | user-select: none; 18 | } 19 | body { 20 | font-family: sans-serif; 21 | font-size: 16px; 22 | width: 788px; 23 | background-image: url(../../img/list/body.jpg); 24 | transform: scale(1.5); 25 | transform-origin: 0 0; 26 | } 27 | .container { 28 | width: 788px; 29 | padding: 20px 15px 10px 15px; 30 | background: url(../../img/list/head.jpg) top left no-repeat; 31 | background-size: 100%; 32 | } 33 | .head_box { 34 | border-radius: 15px; 35 | font-family: 'tttgbnumber'; 36 | padding: 10px 20px; 37 | position: relative; 38 | color: rgb(0, 240, 255);;/*大标题颜色*/ 39 | box-shadow: 0 5px 10px 0 rgba(0, 150, 255, 0.5); 40 | } 41 | .head_box .id_text { 42 | font-size: 35px; 43 | text-shadow: 2px 2px 5px rgb(0, 0, 255) 44 | } 45 | .head_box .day_text { 46 | font-size: 20px; 47 | text-shadow: 1px 1px 3px rgb(0, 0, 255) 48 | } 49 | .head_box .genshin_logo { 50 | position: absolute; 51 | top: -10px; 52 | right: 15px; 53 | width: 97px; 54 | } 55 | 56 | 57 | .data_box { 58 | border-radius: 15px; 59 | font-family: 'genshin'; 60 | margin-top: 20px; 61 | margin-bottom: 15px; 62 | padding: 20px 0px 5px 0px; 63 | background: rgba(255, 255, 255, 0.5); 64 | box-shadow: 0 0 1px 0 rgb(36, 36, 36), 2px 2px 4px 0 rgba(180, 180, 180, 0.8); 65 | position: relative; 66 | } 67 | .tab_lable { 68 | position: absolute; 69 | top: -10px; 70 | left: -8px; 71 | background-color: rgb(0, 85, 255); 72 | box-shadow: 0 0 1px 0 rgb(0, 0, 0), 2px 2px 4px 0 rgba(0, 166, 255, 0.8); 73 | color: rgb(255, 255, 255); 74 | font-family: 'genshin'; 75 | font-size: 14px; 76 | padding: 3px 10px; 77 | border-radius: 15px 0px 15px 15px; 78 | z-index: 20; 79 | } 80 | 81 | .list{ 82 | display: flex; 83 | justify-content: flex-start; 84 | flex-wrap: wrap; 85 | } 86 | 87 | .list .item { 88 | width: 235px; 89 | display: flex; 90 | align-items: center; 91 | color: rgb(0, 80, 255); 92 | background: transparent; 93 | box-shadow: 0 0 1px 0 rgb(0, 0, 0), 2px 2px 4px 0 rgba(0, 120, 255, 0.8); 94 | padding: 8px 6px 8px 6px; 95 | border-radius: 8px; 96 | margin: 0 0px 10px 10px; 97 | } 98 | .list .item .icon{ 99 | width: 30px; 100 | height: 30px; 101 | background-repeat: no-repeat; 102 | background-size: 100% 100%; 103 | position: relative; 104 | flex-shrink: 0; 105 | } 106 | .list .item .title{ 107 | font-size: 16px; 108 | margin-left: 6px; 109 | line-height: 20px; 110 | } 111 | .list .item .title .text{ 112 | font-family: 'genshin'; 113 | white-space: nowrap; 114 | } 115 | .list .item .title .dec{ 116 | font-size: 12px; 117 | color: rgb(255, 0, 120); 118 | margin-top: 2px; 119 | } 120 | .logo{ 121 | text-align: center; 122 | font-size: 14px; 123 | color: rgb(0, 125, 255); 124 | font-family: 'genshin'; 125 | } -------------------------------------------------------------------------------- /resources/html/list/list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |
Xitian-Plugin
21 |

插件列表

22 |
23 | {{each listData val}} 24 |
25 |
26 | {{val.group}} 27 |
28 |
29 | {{each val.list item}} 30 |
31 | 32 |
33 |
[{{@item.state}}]{{item.key}}
34 |
{{item.dsc.length>15?item.dsc.slice(0,14)+'...':item.dsc}}
35 |
36 |
37 | {{/each}} 38 |
39 |
40 | {{/each}} 41 | 42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /resources/html/version/version.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: "genshin"; 3 | src: url("../../font/genshin.ttf"); 4 | font-weight: normal; 5 | font-style: normal; 6 | } 7 | 8 | * { 9 | margin: 0; 10 | padding: 0; 11 | box-sizing: border-box; 12 | user-select: none; 13 | } 14 | body { 15 | font-size: 16px; 16 | font-family: "genshin"; 17 | transform: scale(1.5); 18 | transform-origin: 0 0; 19 | color: black; 20 | } 21 | .container { 22 | width: 536px; 23 | background-image: url(../../img/bg.jpg); 24 | background-size: 100%; 25 | padding: 10px 0 10px 0; 26 | } 27 | .version-card { 28 | background: transparent; 29 | margin: 5px 10px 8px 10px; 30 | position: relative; 31 | box-shadow: 0 0 1px 0 #ccc, 2px 2px 4px 0 rgba(255, 255, 255, 0.8); 32 | overflow: hidden; 33 | color: rgb(0, 80, 255); 34 | font-family: 'genshin'; 35 | font-size: 16px; 36 | border-radius: 4px; 37 | } 38 | .version-card .title { 39 | background: rgba(255, 255, 255, 0.4); 40 | box-shadow: 0 0 1px 0 #fff; 41 | color: rgb(255, 0, 120); 42 | font-family: 'genshin'; 43 | padding: 10px 20px; 44 | text-align: left; 45 | font-size: 16px; 46 | padding: 8px 20px 8px; 47 | font-weight: bold; 48 | } 49 | .version-card .content { 50 | padding: 10px 15px; 51 | font-size: 12px; 52 | background: rgba(255, 255, 255, 0.6); 53 | box-shadow: 0 0 1px 0 #fff; 54 | font-family: "genshin"; 55 | font-weight: normal; 56 | } 57 | .version-card ul { 58 | font-size: 14px; 59 | padding-left: 20px; 60 | } 61 | .version-card ul li { 62 | margin: 3px 0; 63 | } 64 | .version-card .cmd { 65 | color: #ffcf6e; 66 | display: inline-block; 67 | border-radius: 3px; 68 | padding: 0 3px; 69 | margin: 1px 2px; 70 | } 71 | .version-card .strong { 72 | color: #67a9e4; 73 | display: inline-block; 74 | border-radius: 3px; 75 | padding: 0 3px; 76 | margin: 1px 2px; 77 | } 78 | .logo{ 79 | text-align: center; 80 | font-size: 14px; 81 | color: rgb(0, 125, 255); 82 | font-family: 'genshin'; 83 | } -------------------------------------------------------------------------------- /resources/html/version/version.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | 14 | 15 |
16 | {{each versionData item idx}} 17 |
18 |
{{item.version}}{{idx ? '': ' - 当前版本'}}
19 |
20 |
    21 | {{each item.data sub}} 22 |
  • {{@sub}}
  • 23 | {{/each}} 24 |
25 |
26 |
27 | {{/each}} 28 | 29 |
30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /resources/img/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/bg.jpg -------------------------------------------------------------------------------- /resources/img/head.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/head.jpg -------------------------------------------------------------------------------- /resources/img/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon.png -------------------------------------------------------------------------------- /resources/img/icon/batch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/batch.png -------------------------------------------------------------------------------- /resources/img/icon/clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/clear.png -------------------------------------------------------------------------------- /resources/img/icon/command.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/command.png -------------------------------------------------------------------------------- /resources/img/icon/create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/create.png -------------------------------------------------------------------------------- /resources/img/icon/debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/debug.png -------------------------------------------------------------------------------- /resources/img/icon/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/delete.png -------------------------------------------------------------------------------- /resources/img/icon/disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/disable.png -------------------------------------------------------------------------------- /resources/img/icon/enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/enable.png -------------------------------------------------------------------------------- /resources/img/icon/find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/find.png -------------------------------------------------------------------------------- /resources/img/icon/fuldelete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/fuldelete.png -------------------------------------------------------------------------------- /resources/img/icon/gplist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/gplist.png -------------------------------------------------------------------------------- /resources/img/icon/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/help.png -------------------------------------------------------------------------------- /resources/img/icon/install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/install.png -------------------------------------------------------------------------------- /resources/img/icon/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/list.png -------------------------------------------------------------------------------- /resources/img/icon/log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/log.png -------------------------------------------------------------------------------- /resources/img/icon/look.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/look.png -------------------------------------------------------------------------------- /resources/img/icon/remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/remove.png -------------------------------------------------------------------------------- /resources/img/icon/rename.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/rename.png -------------------------------------------------------------------------------- /resources/img/icon/restore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/restore.png -------------------------------------------------------------------------------- /resources/img/icon/set.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/set.png -------------------------------------------------------------------------------- /resources/img/icon/sync.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/sync.png -------------------------------------------------------------------------------- /resources/img/icon/update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/update.png -------------------------------------------------------------------------------- /resources/img/icon/upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/upload.png -------------------------------------------------------------------------------- /resources/img/icon/version.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/icon/version.png -------------------------------------------------------------------------------- /resources/img/list/body.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/list/body.jpg -------------------------------------------------------------------------------- /resources/img/list/head.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/list/head.jpg -------------------------------------------------------------------------------- /resources/img/suffix/bak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/suffix/bak.png -------------------------------------------------------------------------------- /resources/img/suffix/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/suffix/folder.png -------------------------------------------------------------------------------- /resources/img/suffix/js.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/suffix/js.png -------------------------------------------------------------------------------- /resources/img/suffix/unknown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XiTianGame/xitian-plugin/cb0f540c6c7faecdcc101d0f2038c2c1b8f3c698/resources/img/suffix/unknown.png --------------------------------------------------------------------------------