main #1
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/venv
|
||||||
|
config.toml
|
||||||
|
.vs
|
||||||
|
.vscode
|
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# 默认忽略的文件
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
8
.idea/icalingua-python-bot.iml
Normal file
8
.idea/icalingua-python-bot.iml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.9 (2)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
4
.idea/misc.xml
Normal file
4
.idea/misc.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (2)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/icalingua-python-bot.iml" filepath="$PROJECT_DIR$/.idea/icalingua-python-bot.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
373
LICENSE
Normal file
373
LICENSE
Normal file
|
@ -0,0 +1,373 @@
|
||||||
|
Mozilla Public License Version 2.0
|
||||||
|
==================================
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
--------------
|
||||||
|
|
||||||
|
1.1. "Contributor"
|
||||||
|
means each individual or legal entity that creates, contributes to
|
||||||
|
the creation of, or owns Covered Software.
|
||||||
|
|
||||||
|
1.2. "Contributor Version"
|
||||||
|
means the combination of the Contributions of others (if any) used
|
||||||
|
by a Contributor and that particular Contributor's Contribution.
|
||||||
|
|
||||||
|
1.3. "Contribution"
|
||||||
|
means Covered Software of a particular Contributor.
|
||||||
|
|
||||||
|
1.4. "Covered Software"
|
||||||
|
means Source Code Form to which the initial Contributor has attached
|
||||||
|
the notice in Exhibit A, the Executable Form of such Source Code
|
||||||
|
Form, and Modifications of such Source Code Form, in each case
|
||||||
|
including portions thereof.
|
||||||
|
|
||||||
|
1.5. "Incompatible With Secondary Licenses"
|
||||||
|
means
|
||||||
|
|
||||||
|
(a) that the initial Contributor has attached the notice described
|
||||||
|
in Exhibit B to the Covered Software; or
|
||||||
|
|
||||||
|
(b) that the Covered Software was made available under the terms of
|
||||||
|
version 1.1 or earlier of the License, but not also under the
|
||||||
|
terms of a Secondary License.
|
||||||
|
|
||||||
|
1.6. "Executable Form"
|
||||||
|
means any form of the work other than Source Code Form.
|
||||||
|
|
||||||
|
1.7. "Larger Work"
|
||||||
|
means a work that combines Covered Software with other material, in
|
||||||
|
a separate file or files, that is not Covered Software.
|
||||||
|
|
||||||
|
1.8. "License"
|
||||||
|
means this document.
|
||||||
|
|
||||||
|
1.9. "Licensable"
|
||||||
|
means having the right to grant, to the maximum extent possible,
|
||||||
|
whether at the time of the initial grant or subsequently, any and
|
||||||
|
all of the rights conveyed by this License.
|
||||||
|
|
||||||
|
1.10. "Modifications"
|
||||||
|
means any of the following:
|
||||||
|
|
||||||
|
(a) any file in Source Code Form that results from an addition to,
|
||||||
|
deletion from, or modification of the contents of Covered
|
||||||
|
Software; or
|
||||||
|
|
||||||
|
(b) any new file in Source Code Form that contains any Covered
|
||||||
|
Software.
|
||||||
|
|
||||||
|
1.11. "Patent Claims" of a Contributor
|
||||||
|
means any patent claim(s), including without limitation, method,
|
||||||
|
process, and apparatus claims, in any patent Licensable by such
|
||||||
|
Contributor that would be infringed, but for the grant of the
|
||||||
|
License, by the making, using, selling, offering for sale, having
|
||||||
|
made, import, or transfer of either its Contributions or its
|
||||||
|
Contributor Version.
|
||||||
|
|
||||||
|
1.12. "Secondary License"
|
||||||
|
means either the GNU General Public License, Version 2.0, the GNU
|
||||||
|
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||||
|
Public License, Version 3.0, or any later versions of those
|
||||||
|
licenses.
|
||||||
|
|
||||||
|
1.13. "Source Code Form"
|
||||||
|
means the form of the work preferred for making modifications.
|
||||||
|
|
||||||
|
1.14. "You" (or "Your")
|
||||||
|
means an individual or a legal entity exercising rights under this
|
||||||
|
License. For legal entities, "You" includes any entity that
|
||||||
|
controls, is controlled by, or is under common control with You. For
|
||||||
|
purposes of this definition, "control" means (a) the power, direct
|
||||||
|
or indirect, to cause the direction or management of such entity,
|
||||||
|
whether by contract or otherwise, or (b) ownership of more than
|
||||||
|
fifty percent (50%) of the outstanding shares or beneficial
|
||||||
|
ownership of such entity.
|
||||||
|
|
||||||
|
2. License Grants and Conditions
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
2.1. Grants
|
||||||
|
|
||||||
|
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||||
|
non-exclusive license:
|
||||||
|
|
||||||
|
(a) under intellectual property rights (other than patent or trademark)
|
||||||
|
Licensable by such Contributor to use, reproduce, make available,
|
||||||
|
modify, display, perform, distribute, and otherwise exploit its
|
||||||
|
Contributions, either on an unmodified basis, with Modifications, or
|
||||||
|
as part of a Larger Work; and
|
||||||
|
|
||||||
|
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||||
|
for sale, have made, import, and otherwise transfer either its
|
||||||
|
Contributions or its Contributor Version.
|
||||||
|
|
||||||
|
2.2. Effective Date
|
||||||
|
|
||||||
|
The licenses granted in Section 2.1 with respect to any Contribution
|
||||||
|
become effective for each Contribution on the date the Contributor first
|
||||||
|
distributes such Contribution.
|
||||||
|
|
||||||
|
2.3. Limitations on Grant Scope
|
||||||
|
|
||||||
|
The licenses granted in this Section 2 are the only rights granted under
|
||||||
|
this License. No additional rights or licenses will be implied from the
|
||||||
|
distribution or licensing of Covered Software under this License.
|
||||||
|
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||||
|
Contributor:
|
||||||
|
|
||||||
|
(a) for any code that a Contributor has removed from Covered Software;
|
||||||
|
or
|
||||||
|
|
||||||
|
(b) for infringements caused by: (i) Your and any other third party's
|
||||||
|
modifications of Covered Software, or (ii) the combination of its
|
||||||
|
Contributions with other software (except as part of its Contributor
|
||||||
|
Version); or
|
||||||
|
|
||||||
|
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||||
|
its Contributions.
|
||||||
|
|
||||||
|
This License does not grant any rights in the trademarks, service marks,
|
||||||
|
or logos of any Contributor (except as may be necessary to comply with
|
||||||
|
the notice requirements in Section 3.4).
|
||||||
|
|
||||||
|
2.4. Subsequent Licenses
|
||||||
|
|
||||||
|
No Contributor makes additional grants as a result of Your choice to
|
||||||
|
distribute the Covered Software under a subsequent version of this
|
||||||
|
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||||
|
permitted under the terms of Section 3.3).
|
||||||
|
|
||||||
|
2.5. Representation
|
||||||
|
|
||||||
|
Each Contributor represents that the Contributor believes its
|
||||||
|
Contributions are its original creation(s) or it has sufficient rights
|
||||||
|
to grant the rights to its Contributions conveyed by this License.
|
||||||
|
|
||||||
|
2.6. Fair Use
|
||||||
|
|
||||||
|
This License is not intended to limit any rights You have under
|
||||||
|
applicable copyright doctrines of fair use, fair dealing, or other
|
||||||
|
equivalents.
|
||||||
|
|
||||||
|
2.7. Conditions
|
||||||
|
|
||||||
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||||
|
in Section 2.1.
|
||||||
|
|
||||||
|
3. Responsibilities
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
3.1. Distribution of Source Form
|
||||||
|
|
||||||
|
All distribution of Covered Software in Source Code Form, including any
|
||||||
|
Modifications that You create or to which You contribute, must be under
|
||||||
|
the terms of this License. You must inform recipients that the Source
|
||||||
|
Code Form of the Covered Software is governed by the terms of this
|
||||||
|
License, and how they can obtain a copy of this License. You may not
|
||||||
|
attempt to alter or restrict the recipients' rights in the Source Code
|
||||||
|
Form.
|
||||||
|
|
||||||
|
3.2. Distribution of Executable Form
|
||||||
|
|
||||||
|
If You distribute Covered Software in Executable Form then:
|
||||||
|
|
||||||
|
(a) such Covered Software must also be made available in Source Code
|
||||||
|
Form, as described in Section 3.1, and You must inform recipients of
|
||||||
|
the Executable Form how they can obtain a copy of such Source Code
|
||||||
|
Form by reasonable means in a timely manner, at a charge no more
|
||||||
|
than the cost of distribution to the recipient; and
|
||||||
|
|
||||||
|
(b) You may distribute such Executable Form under the terms of this
|
||||||
|
License, or sublicense it under different terms, provided that the
|
||||||
|
license for the Executable Form does not attempt to limit or alter
|
||||||
|
the recipients' rights in the Source Code Form under this License.
|
||||||
|
|
||||||
|
3.3. Distribution of a Larger Work
|
||||||
|
|
||||||
|
You may create and distribute a Larger Work under terms of Your choice,
|
||||||
|
provided that You also comply with the requirements of this License for
|
||||||
|
the Covered Software. If the Larger Work is a combination of Covered
|
||||||
|
Software with a work governed by one or more Secondary Licenses, and the
|
||||||
|
Covered Software is not Incompatible With Secondary Licenses, this
|
||||||
|
License permits You to additionally distribute such Covered Software
|
||||||
|
under the terms of such Secondary License(s), so that the recipient of
|
||||||
|
the Larger Work may, at their option, further distribute the Covered
|
||||||
|
Software under the terms of either this License or such Secondary
|
||||||
|
License(s).
|
||||||
|
|
||||||
|
3.4. Notices
|
||||||
|
|
||||||
|
You may not remove or alter the substance of any license notices
|
||||||
|
(including copyright notices, patent notices, disclaimers of warranty,
|
||||||
|
or limitations of liability) contained within the Source Code Form of
|
||||||
|
the Covered Software, except that You may alter any license notices to
|
||||||
|
the extent required to remedy known factual inaccuracies.
|
||||||
|
|
||||||
|
3.5. Application of Additional Terms
|
||||||
|
|
||||||
|
You may choose to offer, and to charge a fee for, warranty, support,
|
||||||
|
indemnity or liability obligations to one or more recipients of Covered
|
||||||
|
Software. However, You may do so only on Your own behalf, and not on
|
||||||
|
behalf of any Contributor. You must make it absolutely clear that any
|
||||||
|
such warranty, support, indemnity, or liability obligation is offered by
|
||||||
|
You alone, and You hereby agree to indemnify every Contributor for any
|
||||||
|
liability incurred by such Contributor as a result of warranty, support,
|
||||||
|
indemnity or liability terms You offer. You may include additional
|
||||||
|
disclaimers of warranty and limitations of liability specific to any
|
||||||
|
jurisdiction.
|
||||||
|
|
||||||
|
4. Inability to Comply Due to Statute or Regulation
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this
|
||||||
|
License with respect to some or all of the Covered Software due to
|
||||||
|
statute, judicial order, or regulation then You must: (a) comply with
|
||||||
|
the terms of this License to the maximum extent possible; and (b)
|
||||||
|
describe the limitations and the code they affect. Such description must
|
||||||
|
be placed in a text file included with all distributions of the Covered
|
||||||
|
Software under this License. Except to the extent prohibited by statute
|
||||||
|
or regulation, such description must be sufficiently detailed for a
|
||||||
|
recipient of ordinary skill to be able to understand it.
|
||||||
|
|
||||||
|
5. Termination
|
||||||
|
--------------
|
||||||
|
|
||||||
|
5.1. The rights granted under this License will terminate automatically
|
||||||
|
if You fail to comply with any of its terms. However, if You become
|
||||||
|
compliant, then the rights granted under this License from a particular
|
||||||
|
Contributor are reinstated (a) provisionally, unless and until such
|
||||||
|
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||||
|
ongoing basis, if such Contributor fails to notify You of the
|
||||||
|
non-compliance by some reasonable means prior to 60 days after You have
|
||||||
|
come back into compliance. Moreover, Your grants from a particular
|
||||||
|
Contributor are reinstated on an ongoing basis if such Contributor
|
||||||
|
notifies You of the non-compliance by some reasonable means, this is the
|
||||||
|
first time You have received notice of non-compliance with this License
|
||||||
|
from such Contributor, and You become compliant prior to 30 days after
|
||||||
|
Your receipt of the notice.
|
||||||
|
|
||||||
|
5.2. If You initiate litigation against any entity by asserting a patent
|
||||||
|
infringement claim (excluding declaratory judgment actions,
|
||||||
|
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||||
|
directly or indirectly infringes any patent, then the rights granted to
|
||||||
|
You by any and all Contributors for the Covered Software under Section
|
||||||
|
2.1 of this License shall terminate.
|
||||||
|
|
||||||
|
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||||
|
end user license agreements (excluding distributors and resellers) which
|
||||||
|
have been validly granted by You or Your distributors under this License
|
||||||
|
prior to termination shall survive termination.
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 6. Disclaimer of Warranty *
|
||||||
|
* ------------------------- *
|
||||||
|
* *
|
||||||
|
* Covered Software is provided under this License on an "as is" *
|
||||||
|
* basis, without warranty of any kind, either expressed, implied, or *
|
||||||
|
* statutory, including, without limitation, warranties that the *
|
||||||
|
* Covered Software is free of defects, merchantable, fit for a *
|
||||||
|
* particular purpose or non-infringing. The entire risk as to the *
|
||||||
|
* quality and performance of the Covered Software is with You. *
|
||||||
|
* Should any Covered Software prove defective in any respect, You *
|
||||||
|
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||||
|
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||||
|
* essential part of this License. No use of any Covered Software is *
|
||||||
|
* authorized under this License except under this disclaimer. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 7. Limitation of Liability *
|
||||||
|
* -------------------------- *
|
||||||
|
* *
|
||||||
|
* Under no circumstances and under no legal theory, whether tort *
|
||||||
|
* (including negligence), contract, or otherwise, shall any *
|
||||||
|
* Contributor, or anyone who distributes Covered Software as *
|
||||||
|
* permitted above, be liable to You for any direct, indirect, *
|
||||||
|
* special, incidental, or consequential damages of any character *
|
||||||
|
* including, without limitation, damages for lost profits, loss of *
|
||||||
|
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||||
|
* and all other commercial damages or losses, even if such party *
|
||||||
|
* shall have been informed of the possibility of such damages. This *
|
||||||
|
* limitation of liability shall not apply to liability for death or *
|
||||||
|
* personal injury resulting from such party's negligence to the *
|
||||||
|
* extent applicable law prohibits such limitation. Some *
|
||||||
|
* jurisdictions do not allow the exclusion or limitation of *
|
||||||
|
* incidental or consequential damages, so this exclusion and *
|
||||||
|
* limitation may not apply to You. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
8. Litigation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Any litigation relating to this License may be brought only in the
|
||||||
|
courts of a jurisdiction where the defendant maintains its principal
|
||||||
|
place of business and such litigation shall be governed by laws of that
|
||||||
|
jurisdiction, without reference to its conflict-of-law provisions.
|
||||||
|
Nothing in this Section shall prevent a party's ability to bring
|
||||||
|
cross-claims or counter-claims.
|
||||||
|
|
||||||
|
9. Miscellaneous
|
||||||
|
----------------
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning the subject
|
||||||
|
matter hereof. If any provision of this License is held to be
|
||||||
|
unenforceable, such provision shall be reformed only to the extent
|
||||||
|
necessary to make it enforceable. Any law or regulation which provides
|
||||||
|
that the language of a contract shall be construed against the drafter
|
||||||
|
shall not be used to construe this License against a Contributor.
|
||||||
|
|
||||||
|
10. Versions of the License
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
10.1. New Versions
|
||||||
|
|
||||||
|
Mozilla Foundation is the license steward. Except as provided in Section
|
||||||
|
10.3, no one other than the license steward has the right to modify or
|
||||||
|
publish new versions of this License. Each version will be given a
|
||||||
|
distinguishing version number.
|
||||||
|
|
||||||
|
10.2. Effect of New Versions
|
||||||
|
|
||||||
|
You may distribute the Covered Software under the terms of the version
|
||||||
|
of the License under which You originally received the Covered Software,
|
||||||
|
or under the terms of any subsequent version published by the license
|
||||||
|
steward.
|
||||||
|
|
||||||
|
10.3. Modified Versions
|
||||||
|
|
||||||
|
If you create software not governed by this License, and you want to
|
||||||
|
create a new license for such software, you may create and use a
|
||||||
|
modified version of this License if you rename the license and remove
|
||||||
|
any references to the name of the license steward (except to note that
|
||||||
|
such modified license differs from this License).
|
||||||
|
|
||||||
|
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||||
|
Licenses
|
||||||
|
|
||||||
|
If You choose to distribute Source Code Form that is Incompatible With
|
||||||
|
Secondary Licenses under the terms of this version of the License, the
|
||||||
|
notice described in Exhibit B of this License must be attached.
|
||||||
|
|
||||||
|
Exhibit A - Source Code Form License Notice
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
If it is not possible or desirable to put the notice in a particular
|
||||||
|
file, then You may include the notice in a location (such as a LICENSE
|
||||||
|
file in a relevant directory) where a recipient would be likely to look
|
||||||
|
for such a notice.
|
||||||
|
|
||||||
|
You may add additional accurate notices of copyright ownership.
|
||||||
|
|
||||||
|
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||||
|
---------------------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
defined by the Mozilla Public License, v. 2.0.
|
64
bot/types.py
Normal file
64
bot/types.py
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
from typing import Optional
|
||||||
|
from lib_not_dr.types import Options
|
||||||
|
|
||||||
|
|
||||||
|
class SocketData(Options):
|
||||||
|
name = 'SocketData'
|
||||||
|
|
||||||
|
def init(self, **kwargs) -> bool:
|
||||||
|
self.from_json(kwargs)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def from_json(self, data: dict):
|
||||||
|
...
|
||||||
|
|
||||||
|
def to_json(self) -> dict:
|
||||||
|
return self.option()
|
||||||
|
|
||||||
|
|
||||||
|
class Message(SocketData):
|
||||||
|
name = 'icalingua socket message'
|
||||||
|
|
||||||
|
# 消息 id
|
||||||
|
message_id: str
|
||||||
|
# 发送者 id
|
||||||
|
sender_id: int
|
||||||
|
# 发送者昵称
|
||||||
|
sender_name: str
|
||||||
|
# 消息内容
|
||||||
|
content: str
|
||||||
|
|
||||||
|
# 消息时间戳
|
||||||
|
# 13:32:46
|
||||||
|
time_stamp: str
|
||||||
|
# 消息日期
|
||||||
|
# 2023/10/05
|
||||||
|
date: str
|
||||||
|
# unix 时间戳
|
||||||
|
# 1633395166
|
||||||
|
unix_time_stamp: int
|
||||||
|
|
||||||
|
# 发送者身份
|
||||||
|
role: str
|
||||||
|
# 发送者群昵称/备注
|
||||||
|
title: str
|
||||||
|
# 匿名 id
|
||||||
|
anonymous_id: Optional[int] = None
|
||||||
|
# 是否匿名
|
||||||
|
is_anonymous: bool = False
|
||||||
|
# 啊 ?
|
||||||
|
bubble_id: int
|
||||||
|
# 啊 ?
|
||||||
|
sub_id: int
|
||||||
|
|
||||||
|
file: Optional[dict] = None
|
||||||
|
files: Optional[list] = None
|
||||||
|
|
||||||
|
|
||||||
|
class AddMessage(SocketData):
|
||||||
|
name = 'icalingua socket add message event'
|
||||||
|
|
||||||
|
room_id: int
|
||||||
|
|
||||||
|
|
||||||
|
|
5
config-temp.toml
Normal file
5
config-temp.toml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
private_key = "d76a25fea1d5c3c8ccfdb31179798f31f87a2afc7e8feda3f67d515790ee9ee5" # 与 icalingua 客户端使用的 private_key 一致
|
||||||
|
host = "http://192.168.1.6:6789" # docker 版 icalingua 服务的地址
|
||||||
|
self_id = 2163534756 # 机器人的 qq 号
|
||||||
|
|
343
connect.py
Normal file
343
connect.py
Normal file
|
@ -0,0 +1,343 @@
|
||||||
|
import time
|
||||||
|
import random
|
||||||
|
import asyncio
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
from typing import Dict, List, Tuple, Any, Optional, Union, Literal
|
||||||
|
|
||||||
|
import qtoml
|
||||||
|
import socketio
|
||||||
|
from colorama import Fore, Style
|
||||||
|
from nacl.signing import SigningKey
|
||||||
|
from lib_not_dr.types import Options
|
||||||
|
from mcstatus import JavaServer
|
||||||
|
|
||||||
|
# 功能包引用处
|
||||||
|
from module import hitokoto
|
||||||
|
|
||||||
|
# 功能包结束引用
|
||||||
|
|
||||||
|
def get_config() -> Tuple[str, str, int]:
|
||||||
|
with open('config-temp.toml', 'r', encoding='utf-8') as f:
|
||||||
|
config = qtoml.load(f)
|
||||||
|
return config['host'], config['private_key'], config['self_id']
|
||||||
|
|
||||||
|
|
||||||
|
HOST, KEY, SELF_ID = get_config()
|
||||||
|
|
||||||
|
|
||||||
|
class AtElement(Options):
|
||||||
|
text: str
|
||||||
|
id: Union[int, Literal['all']] = 'all'
|
||||||
|
|
||||||
|
|
||||||
|
class ReplyMessage(Options):
|
||||||
|
id: str
|
||||||
|
username: str = ''
|
||||||
|
content: str = ''
|
||||||
|
files: list = []
|
||||||
|
|
||||||
|
def to_json(self) -> dict:
|
||||||
|
return {
|
||||||
|
'_id': self.id,
|
||||||
|
'username': self.username,
|
||||||
|
'content': self.content,
|
||||||
|
'files': self.files
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Message(Options):
|
||||||
|
content: str
|
||||||
|
room_id: Optional[int] = None
|
||||||
|
room: Optional[int] = None # room id 和 room 二选一 ( 实际上直接填 room id 就行了 )
|
||||||
|
file: None = None # TODO: 上传文件
|
||||||
|
reply_to: Optional[ReplyMessage] = None # 源码 给了一个 any TODO: 回复消息
|
||||||
|
b64_img: Optional[str] = None # TODO: 发送图片
|
||||||
|
at: Optional[List[AtElement]] = [] # TODO: @某人
|
||||||
|
sticker: Optional[None] = None # TODO: 发送表情
|
||||||
|
message_type: Optional[str] = None # TODO: 消息类型
|
||||||
|
|
||||||
|
def to_json(self) -> dict:
|
||||||
|
return {
|
||||||
|
'content': self.content,
|
||||||
|
'roomId': self.room_id,
|
||||||
|
'room': self.room,
|
||||||
|
'file': self.file,
|
||||||
|
'replyMessage': self.reply_to.to_json() if self.reply_to else None,
|
||||||
|
'b64img': self.b64_img,
|
||||||
|
'at': self.at,
|
||||||
|
'sticker': self.sticker,
|
||||||
|
'messageType': self.message_type
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sio: socketio.AsyncClient = socketio.AsyncClient()
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('connect')
|
||||||
|
def connect():
|
||||||
|
print(f'{Fore.GREEN}icalingua 已连接{Style.RESET_ALL}')
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('requireAuth')
|
||||||
|
async def require_auth(salt: str, versions: Dict[str, str]):
|
||||||
|
print(f"{Fore.BLUE}versions: {versions}{Style.RESET_ALL}\n{type(salt)}|{salt=}")
|
||||||
|
# 准备数据
|
||||||
|
sign = SigningKey(bytes.fromhex(KEY))
|
||||||
|
signature = sign.sign(bytes.fromhex(salt))
|
||||||
|
|
||||||
|
# 发送数据
|
||||||
|
print(f"{len(signature.signature)=} {type(signature.signature)=}")
|
||||||
|
await sio.emit('auth', signature.signature)
|
||||||
|
print(f"{Fore.BLUE}send auth emit{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
# @sio.on('requireAuth')
|
||||||
|
# def require_auth(*data: Dict[str, Any]):
|
||||||
|
# print(f"{Fore.BLUE}requireAuth: {data}{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('auth')
|
||||||
|
def auth(data: Dict[str, Any]):
|
||||||
|
print(f"auth: {data}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('authFailed')
|
||||||
|
async def auth_failed():
|
||||||
|
print(f"{Fore.RED}authFailed{Style.RESET_ALL}")
|
||||||
|
await sio.disconnect()
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('authSucceed')
|
||||||
|
def auth_succeed():
|
||||||
|
print(f"{Fore.GREEN}authSucceed{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('connect_error')
|
||||||
|
def connect_error(*args, **kwargs):
|
||||||
|
print(f"连接错误 {args}, {kwargs}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('updateRoom')
|
||||||
|
def update_room(data: Dict[str, Any]):
|
||||||
|
print(f"{Fore.CYAN}update_room: {data}{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
|
||||||
|
def safe_eval(code: str) -> str:
|
||||||
|
try:
|
||||||
|
# code = code.replace('help', '坏东西!\n')
|
||||||
|
# code = code.replace('bytes', '坏东西!\n')
|
||||||
|
# code = code.replace('encode', '坏东西!\n')
|
||||||
|
# code = code.replace('decode', '坏东西!\n')
|
||||||
|
# code = code.replace('compile', '屑的!\n')
|
||||||
|
# code = code.replace('globals', '拿不到!\n')
|
||||||
|
code = code.replace('os', '坏东西!\n')
|
||||||
|
code = code.replace('sys', '坏东西!\n')
|
||||||
|
# code = code.replace('input', '坏东西!\n')
|
||||||
|
# code = code.replace('__', '啊哈!\n')
|
||||||
|
# code = code.replace('import', '很坏!\n')
|
||||||
|
code = code.replace(' kill', '别跑!\n')
|
||||||
|
code = code.replace(' rm ', '别跑!\n')
|
||||||
|
code = code.replace('exit', '好坏!\n')
|
||||||
|
code = code.replace('eval', '啊哈!\n')
|
||||||
|
code = code.replace('exec', '抓住!\n')
|
||||||
|
start_time = time.time()
|
||||||
|
try:
|
||||||
|
import os
|
||||||
|
import math
|
||||||
|
import decimal
|
||||||
|
global_val = {'time': time,
|
||||||
|
'math': math,
|
||||||
|
'decimal': decimal,
|
||||||
|
'random': random,
|
||||||
|
'__import__': '<built-in function __import__>',
|
||||||
|
'globals': '也别惦记你那个 globals 了',
|
||||||
|
'compile': '想得美',
|
||||||
|
'help': '虽然但是 help 也不行',
|
||||||
|
'exit': '不许 exit',
|
||||||
|
'input': '你想干嘛',
|
||||||
|
'return': '别惦记你那个 return 了',
|
||||||
|
'getattr': '<built-in function getattr>',
|
||||||
|
'setattr': '<built-in function setattr>'}
|
||||||
|
os.system = '不许'
|
||||||
|
result = str(eval(code, global_val, {}))
|
||||||
|
limit = 500
|
||||||
|
if len(result) > limit:
|
||||||
|
result = result[:limit]
|
||||||
|
except:
|
||||||
|
result = traceback.format_exc()
|
||||||
|
end_time = time.time()
|
||||||
|
result = result.replace(KEY, '***')
|
||||||
|
result = result.replace(HOST, '***')
|
||||||
|
|
||||||
|
print(f"{Fore.MAGENTA}safe_eval: {result}{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
if result == '6' or result == 6:
|
||||||
|
result = '他确实等于 6'
|
||||||
|
|
||||||
|
result = f'{code}\neval result:\n{result}\n耗时: {end_time - start_time} s'
|
||||||
|
return result
|
||||||
|
except:
|
||||||
|
error = traceback.format_exc()
|
||||||
|
result = f'error:\n{error}'
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('addMessage')
|
||||||
|
async def add_message(data: Dict[str, Any]):
|
||||||
|
print(f"{Fore.MAGENTA}add_message: {data}{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
is_self = data['message']['senderId'] == SELF_ID
|
||||||
|
sender_name = data['message']['username']
|
||||||
|
sender_id = data['message']['senderId']
|
||||||
|
content = data['message']['content']
|
||||||
|
room_id = data['roomId']
|
||||||
|
|
||||||
|
if not is_self:
|
||||||
|
if data.get('message').get('content') == '/bot':
|
||||||
|
message = Message(content='icalingua bot test',
|
||||||
|
room_id=data['roomId'])
|
||||||
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
|
elif content == '!!status':
|
||||||
|
server = JavaServer.lookup("192.168.1.6:25565")
|
||||||
|
status=server.status()
|
||||||
|
# query = server.query()
|
||||||
|
|
||||||
|
# if status.players.online != 0:
|
||||||
|
# message = Message(content=f"此服务器有 {status.players.online} 个玩家在线\n当前在线玩家有 {.join(query.players.names)}",room_id=data['roomId'])
|
||||||
|
# else:
|
||||||
|
# message = Message(content=f"此服务器空无一人",room_id=data['roomId'])
|
||||||
|
|
||||||
|
message = Message(content=f"此服务器有 {status.players.online} 个玩家在线",room_id=data['roomId'])
|
||||||
|
|
||||||
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
|
elif content == '!!players':
|
||||||
|
server = JavaServer.lookup("192.168.1.6:25565")
|
||||||
|
query = server.query()
|
||||||
|
players = query.players.names
|
||||||
|
message = Message(content=f"此服务器当前在线玩家有 {players}",room_id=data['roomId'])
|
||||||
|
|
||||||
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
|
elif content.startswith("!!hitokoto "):
|
||||||
|
|
||||||
|
ctypet = content[len("!!hitokoto "):]
|
||||||
|
|
||||||
|
result_code, result_data = hitokoto.hitokoto(ctypet)
|
||||||
|
|
||||||
|
if result_code == 3:
|
||||||
|
message = Message(content=f"参数不对哦!",room_id=data['roomId'])
|
||||||
|
elif result_code == 0:
|
||||||
|
message = Message(f"Hitokoto: {result_data['hitokoto']}")
|
||||||
|
else:
|
||||||
|
message = Message(content=f"但你看到这条消息就代表有bug出炉", room_id=data['roomId'])
|
||||||
|
|
||||||
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
|
elif data.get('message').get('content').startswith('=='):
|
||||||
|
|
||||||
|
evals: str = data.get('message').get('content')[2:]
|
||||||
|
|
||||||
|
# quene = multiprocessing.Queue()
|
||||||
|
# def run(quene, evals):
|
||||||
|
# go = safe_eval(evals)
|
||||||
|
# quene.put(go)
|
||||||
|
# process = multiprocessing.Process(target=run, args=(quene, evals))
|
||||||
|
# process.start()
|
||||||
|
# process.join(1)
|
||||||
|
# if quene.empty():
|
||||||
|
# result = '超时'
|
||||||
|
# else:
|
||||||
|
# result = quene.get()
|
||||||
|
whitelist = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ', '.', '+', '-', '*', '/', '(', ')', '<',
|
||||||
|
'>', '=']
|
||||||
|
evals = evals.replace('**', '')
|
||||||
|
express = ''
|
||||||
|
for text in evals:
|
||||||
|
if text in whitelist:
|
||||||
|
express += text
|
||||||
|
if express == '':
|
||||||
|
result = '你在干嘛'
|
||||||
|
else:
|
||||||
|
result = str(eval(express))
|
||||||
|
|
||||||
|
reply = ReplyMessage(id=data['message']['_id'])
|
||||||
|
message = Message(content=result,
|
||||||
|
reply_to=reply,
|
||||||
|
room_id=room_id)
|
||||||
|
|
||||||
|
await asyncio.sleep(random.random() * 2)
|
||||||
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
elif data['message']['content'] == '!!jrrp':
|
||||||
|
randomer = random.Random(f'{sender_id}-{data["message"]["date"]}-jrrp-v2')
|
||||||
|
result = randomer.randint(0, 50) + randomer.randint(0, 50)
|
||||||
|
print(f'{sender_name} 今日人品值为 {result}')
|
||||||
|
reply = ReplyMessage(id=data['message']['_id'])
|
||||||
|
message = Message(content=f'{sender_name} 今日人品值为 {result}',
|
||||||
|
reply_to=reply,
|
||||||
|
room_id=room_id)
|
||||||
|
await asyncio.sleep(0.5)
|
||||||
|
await sio.emit('sendMessage', message.to_json())
|
||||||
|
# 如果只包括一个或多个 6
|
||||||
|
# elif data['message']['content'].replace(' ', '') in ('6', '666', '六', '3+3', '5+1', '4+2', '2+4', '1+5'):
|
||||||
|
# reply = ReplyMessage(id=data['message']['_id'])
|
||||||
|
# message = Message(content='你 6 nm 呢',
|
||||||
|
# reply_to=reply,
|
||||||
|
# room_id=room_id)
|
||||||
|
# await asyncio.sleep(0.5)
|
||||||
|
# await sio.emit('sendMessage', message.to_json())
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('deleteMessage')
|
||||||
|
def delete_message(message_id: str):
|
||||||
|
print(f"{Fore.MAGENTA}delete_message: {message_id}{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('setMessages')
|
||||||
|
def set_messages(data: Dict[str, Any]):
|
||||||
|
print(f"{Fore.YELLOW}set_messages: {data}\nmessage_len: {len(data['messages'])}{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('setAllRooms')
|
||||||
|
def set_all_rooms(rooms: List[Dict[str, Any]]):
|
||||||
|
print(f"{Fore.YELLOW}set_all_rooms: {rooms}\nlen: {len(rooms)}\n{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('setAllChatGroups')
|
||||||
|
def set_all_chat_groups(groups: List[Dict[str, Any]]):
|
||||||
|
print(f"{Fore.YELLOW}set_all_chat_groups: {groups}\nlen: {len(groups)}\n{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('notify')
|
||||||
|
def notify(data: List[Tuple[str, Any]]):
|
||||||
|
print(f"notify: {data}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('closeLoading')
|
||||||
|
def close_loading(_):
|
||||||
|
print(f"{Fore.GREEN}close_loading{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('onlineData')
|
||||||
|
def online_data(data: Dict[str, Any]):
|
||||||
|
print(f"{Fore.GREEN}online_data: {data}{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on('*')
|
||||||
|
def catch_all(event, data):
|
||||||
|
print(f"{Fore.RED}catch_all: {event}|{data}{Style.RESET_ALL}")
|
||||||
|
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
await sio.connect(HOST)
|
||||||
|
await sio.wait()
|
||||||
|
|
||||||
|
# await sio.emit('requireAuth', ('', {'version': '', 'protocolVersion': ''}))
|
||||||
|
# await asyncio.sleep(2)
|
||||||
|
|
||||||
|
# await asyncio.gather(sio.wait(), sio.wait(), sio.wait())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
asyncio.run(main())
|
1
ica-rs/.gitignore
vendored
Normal file
1
ica-rs/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
target
|
1630
ica-rs/Cargo.lock
generated
Normal file
1630
ica-rs/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
ica-rs/Cargo.toml
Normal file
16
ica-rs/Cargo.toml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[package]
|
||||||
|
name = "ica-rs"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
ed25519 = "2.2.3"
|
||||||
|
ed25519-dalek = "2.1.0"
|
||||||
|
hex = "0.4.3"
|
||||||
|
rust_socketio = "0.4.4"
|
||||||
|
serde_json = "1.0.108"
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
rust_socketio = { path = "V:/githubs/rust-socketio/socketio" }
|
25
ica-rs/src/client.rs
Normal file
25
ica-rs/src/client.rs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
use ed25519_dalek::{Signature, Signer, SigningKey};
|
||||||
|
|
||||||
|
pub struct IcalinguaSinger {
|
||||||
|
pub host: String,
|
||||||
|
pub pub_key: SigningKey,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IcalinguaSinger {
|
||||||
|
pub fn new(host: String, pub_key: &str) -> Self {
|
||||||
|
let array_key: [u8; 32] = hex::decode(pub_key).unwrap().try_into().unwrap();
|
||||||
|
|
||||||
|
let signing_key: SigningKey = SigningKey::from_bytes(&array_key);
|
||||||
|
Self {
|
||||||
|
host,
|
||||||
|
pub_key: signing_key,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn sign_for_salt(&self, salt: String) -> Vec<u8> {
|
||||||
|
let salt: Vec<u8> = hex::decode(salt).unwrap();
|
||||||
|
let signature: Signature = self.pub_key.sign(salt.as_slice());
|
||||||
|
|
||||||
|
signature.to_bytes().to_vec()
|
||||||
|
}
|
||||||
|
}
|
79
ica-rs/src/main.rs
Normal file
79
ica-rs/src/main.rs
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
mod client;
|
||||||
|
|
||||||
|
use ed25519_dalek::{Signature, Signer, SigningKey};
|
||||||
|
use rust_socketio::{ClientBuilder, Event, Payload, RawClient};
|
||||||
|
use serde_json::Value;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
fn require_auth_callback(payload: Payload, client: RawClient, _id: Option<i32>) {
|
||||||
|
let key = std::env::args().nth(2).expect("No key given");
|
||||||
|
let require_data = match payload {
|
||||||
|
Payload::String(_) => None,
|
||||||
|
Payload::Binary(_) => None,
|
||||||
|
Payload::Text(json_value) => Some(json_value),
|
||||||
|
}
|
||||||
|
.expect("Payload should be Json data");
|
||||||
|
|
||||||
|
println!("require_data: {:?}", require_data);
|
||||||
|
|
||||||
|
// let (auth_key, version) = (&require_data[0], &require_data[1]);
|
||||||
|
// println!("auth_key: {:?}, version: {:?}", auth_key, version);
|
||||||
|
let auth_key = match &require_data.get(0) {
|
||||||
|
Some(Value::String(auth_key)) => Some(auth_key),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
.expect("auth_key should be string");
|
||||||
|
|
||||||
|
let array_key: [u8; 32] = hex::decode(key)
|
||||||
|
.expect("Key should be hex")
|
||||||
|
.try_into()
|
||||||
|
.expect("Key should be 32 bytes");
|
||||||
|
|
||||||
|
let signing_key: SigningKey = SigningKey::from_bytes(&array_key);
|
||||||
|
|
||||||
|
let salt = hex::decode(auth_key).expect("Got an invalid salt from the server");
|
||||||
|
let signature: Signature = signing_key.sign(salt.as_slice());
|
||||||
|
// let sign = hex::encode(signature.to_bytes());
|
||||||
|
let sign = signature.to_bytes().to_vec();
|
||||||
|
client.emit("auth", sign).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
fn any_event(event: Event, payload: Payload, _client: RawClient, id: Option<i32>) {
|
||||||
|
// println!("event: {} | {:#?}", event, payload);
|
||||||
|
match payload {
|
||||||
|
Payload::Binary(bin) => println!("event: {}|id:{:?}|bin: {:?}", event, id, bin),
|
||||||
|
Payload::String(str) => println!("event: {}|id:{:?}|str: {:?}", event, id, str),
|
||||||
|
Payload::Text(txt) => println!("event: {}|id:{:?}|txt: {:?}", event, id, txt),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ws_main() {
|
||||||
|
// define a callback which is called when a payload is received
|
||||||
|
// this callback gets the payload as well as an instance of the
|
||||||
|
// socket to communicate with the server
|
||||||
|
let connect_call_back = |payload: Payload, _client: RawClient, _id| {
|
||||||
|
println!("Connect callback: {:#?}", payload);
|
||||||
|
};
|
||||||
|
// 从命令行获取 host 和 key
|
||||||
|
let host = std::env::args().nth(1).expect("No host given");
|
||||||
|
|
||||||
|
// get a socket that is connected to the admin namespace
|
||||||
|
|
||||||
|
let socket = ClientBuilder::new(host)
|
||||||
|
// .namespace("/admin")
|
||||||
|
.on_any(any_event)
|
||||||
|
.on("connect", connect_call_back)
|
||||||
|
.on("requireAuth", require_auth_callback)
|
||||||
|
.connect()
|
||||||
|
.expect("Connection failed");
|
||||||
|
|
||||||
|
std::thread::sleep(Duration::from_secs(10));
|
||||||
|
|
||||||
|
socket.disconnect().expect("Disconnect failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
ws_main();
|
||||||
|
}
|
43
module/hitokoto/__init__.py
Normal file
43
module/hitokoto/__init__.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import requests
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
def hitokoto(ctypet):
|
||||||
|
if ctypet == '动画' or ctypet == 'a':
|
||||||
|
ctype = 'a'
|
||||||
|
elif ctypet == '漫画' or ctypet == 'b':
|
||||||
|
ctype = 'b'
|
||||||
|
elif ctypet == '游戏' or ctypet == 'c':
|
||||||
|
ctype = 'c'
|
||||||
|
elif ctypet == '文学' or ctypet == 'd':
|
||||||
|
ctype = 'd'
|
||||||
|
elif ctypet == '原创' or ctypet == 'e':
|
||||||
|
ctype = 'e'
|
||||||
|
elif ctypet == '网络' or ctypet == 'f':
|
||||||
|
ctype = 'f'
|
||||||
|
elif ctypet == '其他' or ctypet == 'g':
|
||||||
|
ctype = 'g'
|
||||||
|
elif ctypet == '影视' or ctypet == 'h':
|
||||||
|
ctype = 'h'
|
||||||
|
elif ctypet == '诗词' or ctypet == 'i':
|
||||||
|
ctype = 'i'
|
||||||
|
elif ctypet == '网易云' or ctypet == 'j':
|
||||||
|
ctype = 'j'
|
||||||
|
elif ctypet == '哲学' or ctypet == 'k':
|
||||||
|
ctype = 'k'
|
||||||
|
elif ctypet == '抖机灵' or ctypet == 'l':
|
||||||
|
ctype = 'l'
|
||||||
|
else:
|
||||||
|
ctype = random.choice('abcdefghijkl')
|
||||||
|
return 3, None
|
||||||
|
|
||||||
|
params_value = {'c': ctype}
|
||||||
|
hitokoto = requests.get('https://v1.hitokoto.cn', params=params_value)
|
||||||
|
|
||||||
|
return 0, hitokoto.json()
|
||||||
|
|
||||||
|
# except Exception as e:
|
||||||
|
# return 2, None
|
||||||
|
|
||||||
|
|
||||||
|
|
0
module/hitokoto/test.py
Normal file
0
module/hitokoto/test.py
Normal file
0
module/minecraft_server/__init__.py
Normal file
0
module/minecraft_server/__init__.py
Normal file
48
readme.md
Normal file
48
readme.md
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# icalingua bot
|
||||||
|
|
||||||
|
## 源项目
|
||||||
|
本项目fork自[icalingua-python-bot](http://shenjack.top:5100/shenjack/icalingua-python-bot) \
|
||||||
|
fork时版本[69f202e83a7477490a58b5a1548d7d9240e82c72](http://shenjack.top:5100/shenjack/icalingua-python-bot/commit/69f202e83a7477490a58b5a1548d7d9240e82c72)
|
||||||
|
|
||||||
|
## 简介
|
||||||
|
|
||||||
|
这是一个基于 icalingua docker 版的 bot
|
||||||
|
|
||||||
|
> 出于某个企鹅, 和保护 作者 和 原项目 ( ica ) 的原因 \
|
||||||
|
> 功能请自行理解
|
||||||
|
|
||||||
|
## 使用方法
|
||||||
|
|
||||||
|
- 安装依赖
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python -m pip install -r requirement.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
> 如果你想使用虚拟环境 \
|
||||||
|
> 可以使用 `python -m venv venv` 创建虚拟环境 \
|
||||||
|
> 然后使用 `venv\Scripts\activate` 激活虚拟环境 \
|
||||||
|
> 最后使用 `python -m pip install -r requirement.txt` 安装依赖
|
||||||
|
|
||||||
|
- 修改配置文件
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
Copy-Item config-temp.toml config.toml
|
||||||
|
# 欸我就用 powershell
|
||||||
|
```
|
||||||
|
|
||||||
|
- icalingua 启动!
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 用你自己的方法启动你的 icalingua 后端
|
||||||
|
# 例如
|
||||||
|
docker start icalingua
|
||||||
|
# 或者
|
||||||
|
docker up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
- bot 启动!
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python connect.py
|
||||||
|
```
|
6
requirement.txt
Normal file
6
requirement.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
lib-not-dr
|
||||||
|
colorama
|
||||||
|
qtoml
|
||||||
|
pynacl
|
||||||
|
python-socketio[asyncio_client]
|
||||||
|
mcstatus
|
Loading…
Reference in New Issue
Block a user