添加项目文件。

This commit is contained in:
milimoe 2024-03-19 00:13:13 +08:00
commit f683ef1b08
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
22 changed files with 3504 additions and 0 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

363
.gitignore vendored Normal file
View File

@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

674
LICENSE.txt Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

1
README.md Normal file
View File

@ -0,0 +1 @@
# RainBOT-CSharp

25
RainBOT-CSharp.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RainBOT-CSharp", "src\RainBOT.csproj", "{46A60688-46D6-4414-A079-7DC0C95B5A37}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{46A60688-46D6-4414-A079-7DC0C95B5A37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46A60688-46D6-4414-A079-7DC0C95B5A37}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46A60688-46D6-4414-A079-7DC0C95B5A37}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46A60688-46D6-4414-A079-7DC0C95B5A37}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1BA9267E-37E9-4C77-8F9E-1B6E8BAF898B}
EndGlobalSection
EndGlobal

4
build-linux-x64.bat Normal file
View File

@ -0,0 +1,4 @@
@echo off
call cd src
call dotnet publish -c Release -r linux-x64
pause

View File

@ -0,0 +1,304 @@
using Milimoe.RainBOT.Settings;
namespace Milimoe.RainBOT.Command
{
public class MasterCommand
{
public static string Execute(string command, string part, params string[] args)
{
string msg;
bool isadd;
command = command.ToLower();
part = part.ToLower();
switch (command)
{
case ".osm stop":
GeneralSettings.IsRun = false;
return "OSM Core服务已关闭。";
case ".osm start":
GeneralSettings.IsRun = true;
return "OSM Core服务已启动。";
case ".osm send":
if (long.TryParse(part, out long _) && args.Length > 0)
{
return string.Join(" ", args);
}
break;
case ".osm sendall":
return part;
case ".osm set":
bool status;
switch (part)
{
case "repeat":
if (args.Length > 0)
{
if (args[0] != "on" && args[0] != "off")
{
break;
}
status = args[0] == "on";
msg = UpdateValue("随机复读", GeneralSettings.IsRepeat ? "开启" : "关闭", status ? "开启" : "关闭");
GeneralSettings.IsRepeat = status;
return msg;
}
break;
case "prepeat":
if (args.Length > 0 && int.TryParse(args[0], out int prepeat))
{
if (prepeat >= 0 && prepeat <= 100)
{
msg = UpdateValue("随机复读的概率", GeneralSettings.PRepeat + "%", prepeat + "%");
GeneralSettings.PRepeat = prepeat;
return msg;
}
}
break;
case "mindelay":
if (args.Length > 0 && int.TryParse(args[0], out int mindelay))
{
if (mindelay > 0 && mindelay <= 600 && mindelay <= GeneralSettings.RepeatDelay[1])
{
msg = UpdateValue("最短复读延迟", GeneralSettings.RepeatDelay[0] + "秒", mindelay + "秒");
GeneralSettings.RepeatDelay[0] = mindelay;
return msg;
}
return "OSM Core最短复读延迟不能小于等于0或者大于最长复读延迟" + GeneralSettings.RepeatDelay[1] + "秒不能大于600秒10分钟。";
}
break;
case "maxdelay":
if (args.Length > 0 && int.TryParse(args[0], out int maxdelay))
{
if (maxdelay >= 0 && maxdelay <= 600 && maxdelay >= GeneralSettings.RepeatDelay[0])
{
msg = UpdateValue("最长复读延迟", GeneralSettings.RepeatDelay[1] + "秒", maxdelay + "秒");
GeneralSettings.RepeatDelay[1] = maxdelay;
return msg;
}
return "OSM Core最长复读延迟不能小于等于0或者小于最短复读延迟" + GeneralSettings.RepeatDelay[0] + "秒不能大于600秒10分钟。";
}
break;
case "osm":
if (args.Length > 0)
{
if (args[0] != "on" && args[0] != "off")
{
break;
}
status = args[0] == "on";
msg = UpdateValue("随机OSM", GeneralSettings.IsOSM ? "开启" : "关闭", status ? "开启" : "关闭");
GeneralSettings.IsOSM = status;
return msg;
}
break;
case "posm":
if (args.Length > 0 && int.TryParse(args[0], out int posm))
{
if (posm >= 0 && posm <= 100)
{
msg = UpdateValue("随机OSM的概率", GeneralSettings.POSM + "%", posm + "%");
GeneralSettings.POSM = posm;
return msg;
}
}
break;
case "sayno":
if (args.Length > 0)
{
if (args[0] != "on" && args[0] != "off")
{
break;
}
status = args[0] == "on";
msg = UpdateValue("随机反驳不", GeneralSettings.IsSayNo ? "开启" : "关闭", status ? "开启" : "关闭");
GeneralSettings.IsSayNo = status;
return msg;
}
break;
case "psayno":
if (args.Length > 0 && int.TryParse(args[0], out int psayno))
{
if (psayno >= 0 && psayno <= 100)
{
msg = UpdateValue("随机反驳不的概率", GeneralSettings.PSayNo + "%", psayno + "%");
GeneralSettings.PSayNo = psayno;
return msg;
}
}
break;
case "reverseat":
if (args.Length > 0)
{
if (args[0] != "on" && args[0] != "off")
{
break;
}
status = args[0] == "on";
msg = UpdateValue("反向艾特", GeneralSettings.IsReverseAt ? "开启" : "关闭", status ? "开启" : "关闭");
GeneralSettings.IsReverseAt = status;
return msg;
}
break;
case "preverseat":
if (args.Length > 0 && int.TryParse(args[0], out int preverseat))
{
if (preverseat >= 0 && preverseat <= 100)
{
msg = UpdateValue("反向艾特的概率", GeneralSettings.PReverseAt + "%", preverseat + "%");
GeneralSettings.PReverseAt = preverseat;
return msg;
}
}
break;
case "callbrother":
if (args.Length > 0)
{
if (args[0] != "on" && args[0] != "off")
{
break;
}
status = args[0] == "on";
msg = UpdateValue("随机叫哥", GeneralSettings.IsCallBrother ? "开启" : "关闭", status ? "开启" : "关闭");
GeneralSettings.IsCallBrother = status;
return msg;
}
break;
case "pcallbrother":
if (args.Length > 0 && int.TryParse(args[0], out int pcallbrother))
{
if (pcallbrother >= 0 && pcallbrother <= 100)
{
msg = UpdateValue("随机叫哥的概率", GeneralSettings.PCallBrother + "%", pcallbrother + "%");
GeneralSettings.PCallBrother = pcallbrother;
return msg;
}
}
break;
case "mute":
if (args.Length > 0)
{
if (args[0] != "on" && args[0] != "off")
{
break;
}
status = args[0] == "on";
msg = UpdateValue("禁言抽奖", GeneralSettings.IsMute ? "开启" : "关闭", status ? "开启" : "关闭");
GeneralSettings.IsMute = status;
return msg;
}
break;
case "minmute":
if (args.Length > 0 && int.TryParse(args[0], out int minmute))
{
if (minmute > 0 && minmute <= 604800 && minmute <= GeneralSettings.MuteTime[1])
{
msg = UpdateValue("最短禁言时长", GeneralSettings.MuteTime[0] + "秒", minmute + "秒");
GeneralSettings.MuteTime[0] = minmute;
return msg;
}
return "OSM Core最短禁言时长不能小于等于0或者大于最长禁言时长" + GeneralSettings.MuteTime[1] + "秒不能大于604800秒7天。";
}
break;
case "maxmute":
if (args.Length > 0 && int.TryParse(args[0], out int maxmute))
{
if (maxmute >= 0 && maxmute <= 604800 && maxmute >= GeneralSettings.MuteTime[0])
{
msg = UpdateValue("最长禁言时长", GeneralSettings.MuteTime[1] + "秒", maxmute + "秒");
GeneralSettings.MuteTime[1] = maxmute;
return msg;
}
return "OSM Core最长禁言时长不能小于等于0或者小于最短禁言时长" + GeneralSettings.MuteTime[0] + "秒不能大于604800秒7天。";
}
break;
case "blacktimes":
if (args.Length > 0 && int.TryParse(args[0], out int blacktimes))
{
if (blacktimes >= 0 && blacktimes <= 100)
{
msg = UpdateValue("每分钟频繁操作上限次数", GeneralSettings.BlackTimes + "次", blacktimes + "次");
GeneralSettings.BlackTimes = blacktimes;
return msg;
}
}
break;
case "frozentime":
if (args.Length > 0 && int.TryParse(args[0], out int blackfrozentime))
{
if (blackfrozentime >= 0 && blackfrozentime <= 100)
{
msg = UpdateValue("频繁操作封禁时间", GeneralSettings.BlackFrozenTime + "秒", blackfrozentime + "秒");
GeneralSettings.BlackFrozenTime = blackfrozentime;
return msg;
}
}
break;
case "muteaccessgroup":
if (args.Length > 1 && long.TryParse(args[1].Replace("@", "").Trim(), out long muteaccess_qq))
{
string args0 = args[0].ToString().Trim();
if (args0 == "add" || args0 == "remove" || args0 == "+" || args0 == "-")
{
isadd = args0 == "add" || args0 == "+";
if (isadd) GeneralSettings.MuteAccessGroup.Add(muteaccess_qq);
else GeneralSettings.MuteAccessGroup.Remove(muteaccess_qq);
msg = AddRemoveAccessGroupMember("禁言权限组成员", isadd, muteaccess_qq);
return msg;
}
}
break;
case "unmuteaccessgroup":
if (args.Length > 1 && long.TryParse(args[1].Replace("@", "").Trim(), out long unmuteaccess_qq))
{
string args0 = args[0].ToString().Trim();
if (args0 == "add" || args0 == "remove" || args0 == "+" || args0 == "-")
{
isadd = args0 == "add" || args0 == "+";
if (isadd) GeneralSettings.UnMuteAccessGroup.Add(unmuteaccess_qq);
else GeneralSettings.UnMuteAccessGroup.Remove(unmuteaccess_qq);
msg = AddRemoveAccessGroupMember("解禁权限组成员", isadd, unmuteaccess_qq);
return msg;
}
}
break;
case "recallaccessgroup":
if (args.Length > 1 && long.TryParse(args[1].Replace("@", "").Trim(), out long recallaccess_qq))
{
string args0 = args[0].ToString().Trim();
if (args0 == "add" || args0 == "remove" || args0 == "+" || args0 == "-")
{
isadd = args0 == "add" || args0 == "+";
if (isadd) GeneralSettings.RecallAccessGroup.Add(recallaccess_qq);
else GeneralSettings.RecallAccessGroup.Remove(recallaccess_qq);
msg = AddRemoveAccessGroupMember("撤回权限组成员", isadd, recallaccess_qq);
return msg;
}
}
break;
}
return "OSM Core指令格式不正确或传入的参数不支持。\r\n格式.osm <command> [part] [args...]";
}
return "OSM Core指令格式不正确或传入的参数不支持。\r\n格式.osm <command> [part] [args...]";
}
public static string UpdateValue(string part, string old_value, string new_value, ConsoleColor color = ConsoleColor.Cyan)
{
string msg = "OSM Core" + part + "已调整为:" + new_value + "(原始值:" + old_value + ")。";
Console.ForegroundColor = color;
Console.WriteLine(msg);
Console.ForegroundColor = ConsoleColor.Gray;
GeneralSettings.SaveConfig();
return msg;
}
public static string AddRemoveAccessGroupMember(string part, bool isadd, long value, ConsoleColor color = ConsoleColor.Cyan)
{
string msg = "OSM Core" + part + $"已{(isadd ? "" : "")}" + value + "。";
Console.ForegroundColor = color;
Console.WriteLine(msg);
Console.ForegroundColor = ConsoleColor.Gray;
GeneralSettings.SaveConfig();
return msg;
}
}
}

View File

@ -0,0 +1,310 @@
using System.Text.RegularExpressions;
using Milimoe.OneBot.Framework;
using Milimoe.OneBot.Framework.Interface;
using Milimoe.OneBot.Framework.Utility;
using Milimoe.OneBot.Model.Content;
using Milimoe.OneBot.Model.Event;
using Milimoe.OneBot.Model.Message;
using Milimoe.OneBot.Model.Other;
using Milimoe.OneBot.Model.QuickReply;
using Milimoe.OneBot.Utility;
using Milimoe.RainBOT.Command;
using Milimoe.RainBOT.Settings;
namespace Milimoe.RainBOT.ListeningTask
{
public class FriendMessageTask
{
private static long dice = 0;
public static void ListeningTask_handler(FriendMessageEvent e, out FriendMsgEventQuickReply? quick_reply)
{
quick_reply = null;
try
{
Sender sender = e.sender;
if (e.user_id == 0 || e.sender.user_id == 0) return;
Console.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} P/{e.user_id}{(e.detail.Trim() == "" ? "" : " -> " + e.detail)}");
if (GeneralSettings.IsDebug)
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine($"DEBUG{e.original_msg}");
Console.ForegroundColor = ConsoleColor.Gray;
}
if (e.detail == "是")
{
if (e.user_id != GeneralSettings.Master && e.CheckThrow(10, out dice))
{
ColorfulCheckPass(sender, "反驳是", dice, 40);
_ = Post(e, "随机反驳是", "是你的头");
}
else if (e.user_id == GeneralSettings.Master)
{
_ = Post(e, "随机反驳是", "是你的头");
}
}
// OSM指令
if (e.detail.Length >= 4 && e.detail[..4] == ".osm")
{
if (GeneralSettings.IsRun && e.detail.Contains(".osm info"))
{
// OSM核心状态
string msg = "OSM插件运行状态" + "\r\n本群已启用OSM核心";
if (GeneralSettings.IsRepeat)
{
msg += "\r\n随机复读开启";
msg += $"\r\n随机复读概率{GeneralSettings.PRepeat}%" +
$"\r\n随机复读延迟区间{GeneralSettings.RepeatDelay[0]}至{GeneralSettings.RepeatDelay[1]}秒";
}
else msg += "\r\n随机复读关闭";
if (GeneralSettings.IsOSM)
{
msg += "\r\n随机OSM开启";
msg += $"\r\n随机OSM概率{GeneralSettings.POSM}%";
}
else msg += "\r\n随机OSM关闭";
if (GeneralSettings.IsSayNo)
{
msg += "\r\n随机反驳不开启";
msg += $"\r\n随机反驳不概率{GeneralSettings.PSayNo}%";
}
else msg += "\r\n随机反驳不关闭";
if (GeneralSettings.IsMute)
{
msg += "\r\n禁言抽奖开启";
msg += $"\r\n禁言抽奖时长区间{GeneralSettings.MuteTime[0]}至{GeneralSettings.MuteTime[1]}秒";
}
else msg += "\r\n禁言抽奖关闭";
_ = Post(e, "OSM状态", msg);
}
else if (GeneralSettings.IsRun && e.detail.Contains(".osm stop"))
{
if (e.user_id == GeneralSettings.Master)
{
string result = MasterCommand.Execute(".osm stop", "");
_ = Post(e, "OSM指令", result);
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else if (!GeneralSettings.IsRun && e.detail.Contains(".osm start"))
{
if (e.user_id == GeneralSettings.Master)
{
string result = MasterCommand.Execute(".osm start", "");
_ = Post(e, "OSM指令", result);
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else if (e.detail.Contains(".osm refresh"))
{
if (e.user_id == GeneralSettings.Master)
{
TaskUtility.NewTask(async () =>
{
await Bot.GetGroups();
await Bot.GetGroupMembers();
await Post(e, "OSM指令", "刷新缓存完成。");
});
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else if (e.detail.Contains(".osm set"))
{
if (e.user_id == GeneralSettings.Master)
{
string str = e.detail.Replace(".osm set", "").Trim();
string[] strs = Regex.Split(str, @"\s+");
string result = MasterCommand.Execute(".osm set", strs[0], strs.Length > 1 ? strs[1..] : []);
_ = Post(e, "OSM指令", result);
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else if (e.detail.Contains(".osm send"))
{
if (e.user_id == GeneralSettings.Master)
{
string str = e.detail.Replace(".osm send", "").Trim();
string[] strs = Regex.Split(str, @"\s+");
string result = MasterCommand.Execute(".osm send", strs[0], str.Replace(strs[0], "").Trim());
if (long.TryParse(strs[0], out long group_id))
{
GroupMessageContent content = new(group_id);
content.message.Add(new TextMessage(result));
_ = Post(SupportedAPI.send_group_msg, group_id, "OSM指令", content);
}
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else if (e.detail.Contains(".osm sendall"))
{
if (e.user_id == GeneralSettings.Master)
{
string str = e.detail.Replace(".osm send", "").Trim();
string[] strs = Regex.Split(str, @"\s+");
string result = MasterCommand.Execute(".osm sendall", strs[0]);
foreach (long group_id in Bot.Groups.Select(g => g.group_id))
{
GroupMessageContent content = new(group_id);
content.message.Add(new TextMessage(result));
_ = Post(SupportedAPI.send_group_msg, group_id, "OSM指令", content);
}
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else
{
// OSM核心信息
FriendMessageContent content = new(e.user_id);
content.message.Add(new TextMessage($"OSM Core {OSMCore.version} {OSMCore.version2}\r\nAuthor: Milimoe\r\nBuilt on {OSMCore.time}\r\nSee: https://github.com/milimoe"));
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\raincandy.jpg"));
_ = Post(e, "OSM核心", content);
return;
}
return;
}
if (GeneralSettings.IsMute && e.detail == "忏悔")
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
string msg = "";
foreach (long group_id in Bot.Groups.Select(g => g.group_id))
{
if (Bot.BotIsAdmin(group_id) && MuteRecall.Muted[group_id].TryGetValue(e.user_id, out long operator_id) && operator_id == Bot.BotQQ)
{
MuteRecall.Muted[group_id].Remove(e.user_id);
await GroupMessageTask.Post(SupportedAPI.set_group_ban, group_id, "忏悔", new SetGroupBanContent(group_id, e.user_id, 0));
if (msg != "") msg += "\r\n";
msg += $"[{group_id}] 忏悔成功!!希望你保持纯真,保持野性的美。";
}
}
if (msg == "") msg = "你无需忏悔。请注意:我不能帮你解除由管理员手动操作的禁言。";
await Post(e, "忏悔", msg);
});
return;
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
public static async Task<bool> CheckBlackList(FriendMessageEvent e)
{
// 黑名单
if (e.user_id == GeneralSettings.Master) return true;
if (!BlackList.Times.ContainsKey(e.user_id))
{
BlackList.Times.Add(e.user_id, 1);
return true;
}
else if (BlackList.Times.TryGetValue(e.user_id, out long bltimes) && bltimes > 5)
{
return false;
}
else if (++bltimes == 5)
{
BlackList.Times[e.user_id] = 6;
FriendMessageContent content = new(e.user_id);
content.message.Add(new AtMessage(e.user_id));
content.message.Add(new TextMessage("警告你已因短时间内频繁操作被禁止使用BOT指令" + (GeneralSettings.BlackFrozenTime / 60) + "分钟" + (GeneralSettings.BlackFrozenTime % 60) + "秒。"));
_ = Task.Run(async () =>
{
await Task.Delay(1000 * GeneralSettings.BlackFrozenTime);
BlackList.Times.Remove(e.user_id);
});
await Post(e, "黑名单", content);
return false;
}
else
{
BlackList.Times[e.user_id] = bltimes;
return true;
}
}
public static void ColorfulCheckPass(Sender sender, string function, long dice, long probability, int delay = 0)
{
Console.ForegroundColor = ConsoleColor.Green;
if (delay > 0)
{
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} ");
}
Console.Write($"{sender.user_id}{(sender.card != "" ? sender.card : sender.nickname)})的{function}检定通过:{dice} < {probability}");
if (delay > 0)
{
Console.Write(" -> " + delay + "秒后执行");
}
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Gray;
}
public static async Task Post(FriendMessageEvent e, string function, string text, int delay = 0)
{
string result = (await e.SendMessage(text, delay)).ReasonPhrase ?? "";
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} F/");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(function);
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine($" P/{e.user_id} <- {text} {result}");
}
public static async Task Post(FriendMessageEvent e, string function, FriendMessageContent content, int delay = 0)
{
string result = (await e.SendMessage(content, delay)).ReasonPhrase ?? "";
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} F/");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(function);
Console.ForegroundColor = ConsoleColor.Gray;
if (!GeneralSettings.IsDebug)
{
Console.WriteLine($" P/{e.user_id} <- {content.detail} {result}");
}
else
{
Console.WriteLine($" P/{e.user_id} <- {JsonTools.GetString(content)} {result}");
}
}
public static async Task Post(string api, long user_id, string function, IContent content)
{
string result = (await HTTPPost.Post(api, content)).ReasonPhrase ?? "";
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} F/");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(function);
Console.ForegroundColor = ConsoleColor.Gray;
if (!GeneralSettings.IsDebug)
{
Console.WriteLine($" P/{user_id} <- {content.detail} {result}");
}
else
{
Console.WriteLine($" P/{user_id} <- {HTTPHelper.GetJsonString(api, content)} {result}");
}
}
public static async Task Post(string api, long user_id, string function, IEnumerable<IContent> contents)
{
await HTTPPost.Post(api, contents);
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} F/");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(function);
Console.ForegroundColor = ConsoleColor.Gray;
if (!GeneralSettings.IsDebug)
{
Console.WriteLine($" P/{user_id} <- 已在后台执行");
}
else
{
Console.WriteLine($" P/{user_id} <- 已在后台执行");
}
}
}
}

View File

@ -0,0 +1,53 @@
using Milimoe.OneBot.Framework;
using Milimoe.OneBot.Model.Content;
using Milimoe.OneBot.Model.Event;
using Milimoe.OneBot.Model.Other;
using Milimoe.RainBOT.Settings;
namespace Milimoe.RainBOT.ListeningTask
{
public class GroupBanTask
{
public static async void ListeningTask_handler(GroupBanEvent e)
{
try
{
Console.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} N/Group_Ban G/{e.group_id}{(e.detail.Trim() == "" ? "" : " -> " + e.detail)}");
if (GeneralSettings.IsDebug)
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine($"DEBUG{e.original_msg}");
Console.ForegroundColor = ConsoleColor.Gray;
}
if (e.sub_type == "ban" && e.duration > 0 && e.user_id == GeneralSettings.Master && e.operator_id != GeneralSettings.BotQQ)
{
MuteRecall.Muted[e.group_id].Remove(e.user_id);
MuteRecall.Muted[e.group_id].Add(e.user_id, GeneralSettings.Master);
SetGroupBanContent content_unmute_master = new(e.group_id, GeneralSettings.Master, 0);
SetGroupBanContent content_mute_operator = new(e.group_id, e.operator_id, 60);
await GroupMessageTask.Post(SupportedAPI.set_group_ban, e.group_id, "反制禁言", [content_unmute_master, content_mute_operator]);
if (Bot.GroupMembers.TryGetValue(e.group_id, out List<Member>? list) && list != null)
{
Member? sender = list.Where(m => m.user_id == e.operator_id).FirstOrDefault();
if (sender != null)
{
await e.SendMessage($"检测到主人被{sender.user_id}{(sender.card != "" ? sender.card : sender.nickname)})禁言!");
}
}
}
else if (e.sub_type == "ban" && e.duration > 0)
{
MuteRecall.Muted[e.group_id].Remove(e.user_id);
MuteRecall.Muted[e.group_id].Add(e.user_id, e.operator_id);
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
}
}

View File

@ -0,0 +1,952 @@
using System.Linq;
using System.Text.RegularExpressions;
using Milimoe.OneBot.Framework;
using Milimoe.OneBot.Framework.Interface;
using Milimoe.OneBot.Framework.Utility;
using Milimoe.OneBot.Model.Content;
using Milimoe.OneBot.Model.Event;
using Milimoe.OneBot.Model.Message;
using Milimoe.OneBot.Model.Other;
using Milimoe.OneBot.Model.QuickReply;
using Milimoe.OneBot.Utility;
using Milimoe.RainBOT.Command;
using Milimoe.RainBOT.Settings;
namespace Milimoe.RainBOT.ListeningTask
{
public class GroupMessageTask
{
private static long dice = 0;
private readonly static string[] EEWords = ["ee", "鹅鹅", "呃呃", "谔谔", "饿饿"];
private readonly static string[] MuteCommands = ["禁言", "解禁"];
public static void ListeningTask_handler(GroupMessageEvent e, out GroupMsgEventQuickReply? quick_reply)
{
quick_reply = null;
try
{
Sender sender = e.sender;
if (e.user_id == 0 || e.sender.user_id == 0) return;
Console.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} G/{e.group_id}{(e.detail.Trim() == "" ? "" : " -> " + e.detail)} by {sender.user_id}{(sender.card != "" ? sender.card : sender.nickname)}");
if (GeneralSettings.IsDebug)
{
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine($"DEBUG{e.original_msg}");
Console.ForegroundColor = ConsoleColor.Gray;
}
MuteRecall.Muted[e.group_id].Remove(e.user_id);
// OSM指令
if (e.detail.Length >= 4 && e.detail[..4] == ".osm")
{
if (GeneralSettings.IsRun && e.detail.Contains(".osm info"))
{
// OSM核心状态
string msg = "OSM插件运行状态" + "\r\n本群已启用OSM核心";
if (GeneralSettings.IsRepeat)
{
msg += "\r\n随机复读开启";
msg += $"\r\n随机复读概率{GeneralSettings.PRepeat}%" +
$"\r\n随机复读延迟区间{GeneralSettings.RepeatDelay[0]}至{GeneralSettings.RepeatDelay[1]}秒";
}
else msg += "\r\n随机复读关闭";
if (GeneralSettings.IsOSM)
{
msg += "\r\n随机OSM开启";
msg += $"\r\n随机OSM概率{GeneralSettings.POSM}%";
}
else msg += "\r\n随机OSM关闭";
if (GeneralSettings.IsSayNo)
{
msg += "\r\n随机反驳不开启";
msg += $"\r\n随机反驳不概率{GeneralSettings.PSayNo}%";
}
else msg += "\r\n随机反驳不关闭";
if (GeneralSettings.IsMute)
{
msg += "\r\n禁言抽奖开启";
msg += $"\r\n禁言抽奖时长区间{GeneralSettings.MuteTime[0]}至{GeneralSettings.MuteTime[1]}秒";
}
else msg += "\r\n禁言抽奖关闭";
_ = Post(e, "OSM状态", msg);
}
else if (GeneralSettings.IsRun && e.detail.Contains(".osm stop"))
{
if (e.user_id == GeneralSettings.Master)
{
string result = MasterCommand.Execute(".osm stop", "");
_ = Post(e, "OSM指令", result);
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else if (!GeneralSettings.IsRun && e.detail.Contains(".osm start"))
{
if (e.user_id == GeneralSettings.Master)
{
string result = MasterCommand.Execute(".osm start", "");
_ = Post(e, "OSM指令", result);
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else if (e.detail.Contains(".osm set admin") || e.detail.Contains(".osm set unadmin"))
{
if (e.user_id == GeneralSettings.Master)
{
bool enable = !e.detail.Contains("unadmin");
string str = e.detail.Replace(".osm set admin", "").Replace(".osm set unadmin", "").Trim();
string[] strs = Regex.Split(str, @"\s+");
if (strs.Length > 0)
{
str = strs[0].Replace(@"@", "").Trim();
if (long.TryParse(str, out long qq))
{
SetGroupAdminContent content = new(e.group_id, qq, enable);
_ = Post(SupportedAPI.set_group_admin, e.group_id, "OSM指令", content);
}
else _ = Post(e, "OSM指令", MasterCommand.Execute(".osm set", "admin", strs.Length > 1 ? strs[1..] : []));
}
else _ = Post(e, "OSM指令", MasterCommand.Execute(".osm set", "admin", strs.Length > 1 ? strs[1..] : []));
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else if (e.detail.Contains(".osm mutegroup"))
{
TaskUtility.NewTask(async () => await MuteGroup(e));
}
else if (e.detail.Contains(".osm mute"))
{
TaskUtility.NewTask(async () => await Mute(e));
}
else if (e.detail.Contains(".osm refresh"))
{
if (e.user_id == GeneralSettings.Master)
{
TaskUtility.NewTask(async () =>
{
await Bot.GetGroups();
await Bot.GetGroupMembers();
await Post(e, "OSM指令", "刷新缓存完成。请注意,刷新缓存会导致正在禁言中的成员无法通过私聊忏悔命令解禁。");
});
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else if (e.detail.Contains(".osm reload"))
{
if (e.user_id == GeneralSettings.Master)
{
GeneralSettings.LoadSetting();
_ = Post(e, "OSM指令", "参数设定以及权限组重新加载完成。");
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else if (e.detail.Contains(".osm set"))
{
if (e.user_id == GeneralSettings.Master)
{
string str = e.detail.Replace(".osm set", "").Trim();
string[] strs = Regex.Split(str, @"\s+");
string result = MasterCommand.Execute(".osm set", strs[0], strs.Length > 1 ? strs[1..] : []);
_ = Post(e, "OSM指令", result);
}
else _ = Post(e, "OSM指令", "你没有权限使用此指令。");
}
else if (e.detail.Contains(".osm sendall"))
{
TaskUtility.NewTask(async () =>
{
if (e.user_id == GeneralSettings.Master)
{
string str = e.detail.Replace(".osm sendall", "").Trim();
string result = MasterCommand.Execute(".osm sendall", str);
foreach (long group_id in Bot.Groups.Select(g => g.group_id))
{
GroupMessageContent content = new(group_id);
content.message.Add(new TextMessage(result));
await Post(SupportedAPI.send_group_msg, group_id, "OSM指令", content);
}
}
else await Post(e, "OSM指令", "你没有权限使用此指令。");
});
}
else if (e.detail.Contains(".osm send"))
{
TaskUtility.NewTask(async () =>
{
if (e.user_id == GeneralSettings.Master)
{
string str = e.detail.Replace(".osm send", "").Trim();
string[] strs = Regex.Split(str, @"\s+");
string result = MasterCommand.Execute(".osm send", strs[0], str.Replace(strs[0], "").Trim());
if (long.TryParse(strs[0], out long group_id))
{
GroupMessageContent content = new(group_id);
content.message.Add(new TextMessage(result));
await Post(SupportedAPI.send_group_msg, group_id, "OSM指令", content);
}
}
else await Post(e, "OSM指令", "你没有权限使用此指令。");
});
}
else
{
// OSM核心信息
GroupMessageContent content = new(e.group_id);
content.message.Add(new TextMessage(OSMCore.Info));
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\raincandy.jpg"));
_ = Post(e, "OSM核心", content);
return;
}
return;
}
if (e.detail.Length >= 5 && (e.detail[..5] == "禁言所有人" || e.detail[..5] == "解禁所有人") && e.user_id == GeneralSettings.Master && Bot.GroupMembers.TryGetValue(e.group_id, out List<Member>? members) && members != null)
{
TaskUtility.NewTask(async () => await Mute(e, members.Where(m => m.user_id != GeneralSettings.Master).Select(m => m.user_id)));
return;
}
if (e.detail != "禁言抽奖" && e.detail.Length >= 2 && MuteCommands.Any(e.detail[..2].Contains))
{
TaskUtility.NewTask(async () => await Mute(e));
return;
}
if (e.detail.Length >= 4 && e.detail[..4] == "跨群禁言")
{
TaskUtility.NewTask(async () => await MuteGroup(e));
return;
}
// 撤回消息
if ((e.user_id == GeneralSettings.Master || GeneralSettings.RecallAccessGroup.Contains(e.user_id)) && e.detail.Contains("撤回;") && e.message.Any(m => m.type == "reply"))
{
ReplyMessage reply = (ReplyMessage)e.message.Where(m => m.type == "reply").First();
if (int.TryParse(reply.data.id, out int id))
{
TaskUtility.NewTask(async () => await Post(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(id)));
return;
}
}
if (!GeneralSettings.IsRun)
{
return;
}
// 发图API
if (e.detail == "来图")
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=random"));
await Post(e, "Image", content);
return;
});
}
if (e.detail.Contains("白毛"))
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=yin"));
await Post(e, "Image", content);
return;
});
}
if (e.detail == "猫耳")
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=cat"));
await Post(e, "Image", content);
return;
});
}
if (e.detail == "壁纸")
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=pc"));
await Post(e, "Image", content);
return;
});
}
if (e.detail == "新闻")
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("https://api.03c3.cn/api/zb"));
await Post(e, "Image", content);
return;
});
}
if (e.detail.Contains("来龙"))
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\long\long (" + (new Random().Next(1540) + 1) + ").jpg"));
await Post(e, "Image", content);
return;
});
}
if (e.detail.Contains("丁真") || e.detail == "一眼丁真" || e.detail == "一眼顶针")
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\dingzhen\dz" + (new Random().Next(82) + 1) + ".jpg"));
await Post(e, "Image", content);
return;
});
}
if (EEWords.Any(e.detail.Contains))
{
if (BlackList.Times.TryGetValue(e.user_id, out long bltimes) && bltimes > 5) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\ee.png"));
_ = Post(e, "Image", content);
return;
}
// 发音频API
if (e.detail.Contains("kun", StringComparison.CurrentCultureIgnoreCase))
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new RecordMessage(Music.MusicList["ikun"]));
await Post(e, "Record", content);
});
return;
}
if (e.detail.Contains("csgo", StringComparison.CurrentCultureIgnoreCase))
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new RecordMessage(Music.MusicList["懂CSGO"]));
await Post(e, "Record", content);
});
return;
}
if (e.detail.Contains("架不住") || e.detail.Contains("打不死") || e.detail.Contains("不玩了"))
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new RecordMessage(Music.MusicList["令人沮丧的游戏"]));
await Post(e, "Record", content);
});
}
if (e.detail.Contains("man", StringComparison.CurrentCultureIgnoreCase))
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new RecordMessage(Music.MusicList["man"]));
await Post(e, "Record", content);
});
return;
}
// 我的运势
if (e.detail == "我的运势")
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
GroupMessageContent content = new(e.group_id);
content.message.Add(new AtMessage(e.user_id));
if (Daily.UserDailys.TryGetValue(e.user_id, out string? value) && value != null && value.Trim() != "")
{
content.message.Add(new TextMessage("你已看过你的今日运势:\r\n"));
content.message.Add(new TextMessage(value));
await Post(e, "我的运势", content);
}
else
{
int seq = new Random().Next(Daily.DailyContent.Count);
string text = Daily.DailyContent[seq];
Daily.UserDailys.Add(e.user_id, text);
content.message.Add(new TextMessage("你的今日运势是:\r\n" + text));
await Post(e, "我的运势", content);
// 配图
content = new(e.group_id);
string img = "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\zi\";
if (seq >= 0 && seq <= 5)
{
img += "dj" + (new Random().Next(3) + 1) + ".png";
}
else if (seq >= 6 && seq <= 10)
{
img += "zj" + (new Random().Next(2) + 1) + ".png";
}
else if (seq >= 11 && seq <= 15)
{
img += "j" + (new Random().Next(4) + 1) + ".png";
}
else if (seq >= 16 && seq <= 22)
{
img += "mj" + (new Random().Next(2) + 1) + ".png";
}
else if (seq >= 23 && seq <= 25)
{
img += "dx" + (new Random().Next(2) + 1) + ".png";
}
else if (seq >= 26 && seq <= 29)
{
img += "x" + (new Random().Next(2) + 1) + ".png";
}
content.message.Add(new ImageMessage(img));
await Post(e, "我的运势配图", content);
}
});
return;
}
if (e.detail == "重置运势" && Daily.UserDailys.ContainsKey(e.user_id))
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
Daily.UserDailys.Remove(e.user_id);
GroupMessageContent content = new(e.group_id);
content.message.Add(new AtMessage(e.user_id));
content.message.Add(new TextMessage("你的今日运势已重置。"));
await Post(e, "重置运势", content);
});
return;
}
if (e.detail.Length > 4 && e.detail[..2] == "查看" && (e.detail[^2..] == "运势"))
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e)) return;
string[] strs = e.detail.Replace("查看", "").Replace("运势", "").Trim().Split(' ');
foreach (string str_qq in strs)
{
if (long.TryParse(str_qq.Trim().Replace("@", ""), out long qq))
{
if (qq == GeneralSettings.BotQQ && !Daily.UserDailys.ContainsKey(qq))
{
string text = Daily.DailyContent[new Random().Next(Daily.DailyContent.Count)];
Daily.UserDailys.Add(GeneralSettings.BotQQ, text);
}
if (Daily.UserDailys.TryGetValue(qq, out string? daily) && daily != null)
{
GroupMessageContent content = new(e.group_id);
content.message.Add(new TextMessage(qq + "的今日运势是:\r\n" + daily));
await Post(e, "查看运势", content);
}
else
{
await Post(e, "查看运势", "TA今天还没有抽取运势哦快去提醒TA");
}
}
}
});
return;
}
// 禁言抽奖
if (GeneralSettings.IsMute && e.detail == "禁言抽奖" && !MuteRecall.WillMute.ContainsKey(e.user_id))
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e) || !Bot.BotIsAdmin(e.group_id)) return;
if (e.user_id != GeneralSettings.Master)
{
await Post(e, "禁言抽奖", "2秒后开奖\r\n如需要忏悔请在开奖后3秒内发送忏悔开奖前发送无效。");
await Task.Delay(2000);
if (!MuteRecall.WillMute.ContainsKey(e.user_id)) MuteRecall.WillMute.Add(e.user_id, e.user_id);
long mute_time = GeneralSettings.MuteTime[0] + new Random().NextInt64(GeneralSettings.MuteTime[1] - GeneralSettings.MuteTime[0]);
await Post(e, "禁言抽奖", "开奖啦!禁言时长:" + (mute_time / 60) + "分钟" + (mute_time % 60) + "秒。\r\n" + "你现在有3秒时间发送忏悔拒绝领奖");
await Task.Delay(3200);
await Post(SupportedAPI.set_group_ban, e.group_id, "禁言抽奖", new SetGroupBanContent(e.group_id, e.user_id, mute_time));
MuteRecall.WillMute.Remove(e.user_id);
}
else
{
_ = Post(e, "禁言抽奖", "我不能禁言主人!");
}
});
return;
}
// 忏悔
else if (GeneralSettings.IsMute && e.detail == "忏悔" && MuteRecall.WillMute.ContainsKey(e.user_id))
{
TaskUtility.NewTask(async () =>
{
if (!await CheckBlackList(e) || !Bot.BotIsAdmin(e.group_id)) return;
await Task.Delay(3800);
MuteRecall.WillMute.Remove(e.user_id);
await Post(SupportedAPI.set_group_ban, e.group_id, "忏悔", new SetGroupBanContent(e.group_id, e.user_id, 0));
await Post(e, "忏悔", "忏悔成功!!希望你保持纯真,保持野性的美。");
});
return;
}
// 随机反驳是
if (e.detail == "是")
{
if (e.user_id != GeneralSettings.Master && e.CheckThrow(40, out dice))
{
ColorfulCheckPass(sender, "反驳是", dice, 40);
_ = Post(e, "随机反驳是", "是你的头");
}
else if (e.user_id == GeneralSettings.Master)
{
_ = Post(e, "随机反驳是", "是你的头");
}
}
// 随机反驳不
if (GeneralSettings.IsSayNo && SayNo.Trigger.Any(e.detail.Contains) && e.CheckThrow(GeneralSettings.PSayNo, out dice))
{
GroupMessageContent content = new(e.group_id);
// 获取关键词在其中的位置
Dictionary<string, int> where = SayNo.Trigger
.ToDictionary(trigger => trigger, e.detail.IndexOf)
.Where(kvp => kvp.Value != -1)
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
foreach (string keyword in where.Keys)
{
// 通常,只反驳第一个词,除非无可反驳才会找下一个词
int pos = where[keyword];
if (keyword == "不")
{
if (pos + 1 < e.detail.Length && !SayNo.IgnoreTriggerAfterNo.Any(e.detail[(pos + 1)..].Contains))
{
ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
content.message.Add(new TextMessage(string.Format(SayNo.SayNoWords[new Random().Next(SayNo.SayNoWords.Count)], e.detail[pos + 1])));
break;
}
}
else if (keyword == "没")
{
if (pos + 1 < e.detail.Length)
{
ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
if (e.detail[pos + 1] == '有')
{
content.message.Add(new TextMessage(string.Format(SayNo.SayDontHaveWords[new Random().Next(SayNo.SayDontHaveWords.Count - 3)], e.detail[pos + 1])));
break;
}
else
{
content.message.Add(new TextMessage(string.Format(SayNo.SayDontHaveWords[new Random().Next(SayNo.SayDontHaveWords.Count)], e.detail[pos + 1])));
break;
}
}
}
else if (keyword == "是")
{
if (pos + 1 < e.detail.Length && SayNo.TriggerAfterYes.Any(e.detail[(pos + 1)..].Contains))
{
ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
content.message.Add(new TextMessage(SayNo.SayNotYesWords[new Random().Next(SayNo.SayNotYesWords.Count)]));
break;
}
}
else if (keyword == "别")
{
if (pos + 1 < e.detail.Length && !SayNo.IgnoreTriggerAfterNo.Any(e.detail[(pos + 1)..].Contains) && !SayNo.WillNotSayNo.Any(e.detail[(pos + 1)..].Contains))
{
ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
content.message.Add(new TextMessage(string.Format(SayNo.SayDontWords[new Random().Next(SayNo.SayDontWords.Count)], e.detail[pos + 1])));
break;
}
}
}
if (content.message.Count > 0)
{
_ = Post(e, "随机反驳不", content);
}
}
else if (SayNo.TriggerBeforeNo.Any(e.detail.Contains) && GeneralSettings.IsSayNo && e.CheckThrow(GeneralSettings.PSayNo, out dice))
{
GroupMessageContent content = new(e.group_id);
// 获取关键词在其中的位置
Dictionary<string, int> where = SayNo.TriggerBeforeNo
.ToDictionary(trigger => trigger, e.detail.IndexOf)
.Where(kvp => kvp.Value != -1)
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
foreach (string keyword in where.Keys)
{
int pos = where[keyword];
string sayword = "";
if (keyword == "太")
{
if (pos + keyword.Length + 1 < e.detail.Length)
{
ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
if (e.detail[(pos + keyword.Length + 1)..].Contains('了'))
{
sayword = e.detail[pos..].Replace(keyword, "");
sayword = sayword.Replace("了", "");
}
else
{
sayword = e.detail.Replace(keyword, "");
}
if (sayword.Length > 2) sayword = sayword[..2];
content.message.Add(new TextMessage(SayNo.SaySpecialNoWords[new Random().Next(SayNo.SaySpecialNoWords.Count)] + sayword));
break;
}
}
else
{
if (pos + keyword.Length + 1 < e.detail.Length)
{
ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
sayword = e.detail[pos..].Replace(keyword, "");
if (sayword.Length > 2) sayword = sayword[..2];
List<string> NewSayWords = [];
NewSayWords.Add("太");
NewSayWords.AddRange(SayNo.SaySpecialNoWords);
NewSayWords.Remove(keyword);
sayword = NewSayWords[new Random().Next(NewSayWords.Count)] + sayword;
if (sayword[0] == '太') sayword += "了";
content.message.Add(new TextMessage(sayword));
}
}
}
if (content.message.Count > 0)
{
_ = Post(e, "随机反驳不", content);
}
}
else if (e.detail.Contains("可以") && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice))
{
ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
if (dice < 20)
{
_ = Post(e, "随机反驳不", "可以");
}
else
{
_ = Post(e, "随机反驳不", "不可以");
}
}
else if (e.detail.Contains('能') && !e.detail.Contains('不') && !e.detail.Contains('可') && e.CheckThrow(GeneralSettings.PSayNo, out dice))
{
ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
if (dice < 20)
{
_ = Post(e, "随机反驳不", "能");
}
else
{
_ = Post(e, "随机反驳不", "不能");
}
}
else if (e.detail.Contains("可能") && !e.detail.Contains('不') && e.CheckThrow(GeneralSettings.PSayNo, out dice))
{
ColorfulCheckPass(sender, "随机反驳不", dice, GeneralSettings.PSayNo);
if (dice < 20)
{
_ = Post(e, "随机反驳不", "可能");
}
else
{
_ = Post(e, "随机反驳不", "不可能");
}
}
// 反向艾特
IEnumerable<AtMessage> temp_at = e.message.Where(m => m.type == "at").Cast<AtMessage>().Where(m => m.data.qq == $"{GeneralSettings.BotQQ}");
if (temp_at.Any())
{
if (GeneralSettings.IsReverseAt && e.CheckThrow(GeneralSettings.PReverseAt, out dice))
{
ColorfulCheckPass(sender, "反向艾特", dice, GeneralSettings.PReverseAt);
foreach (AtMessage at in temp_at)
{
at.data.qq = e.user_id.ToString();
GroupMessageContent content = new(e.group_id);
content.message.AddRange(e.message);
_ = Post(e, "反向艾特", content);
}
}
return;
}
// 随机OSM
if (GeneralSettings.IsOSM && !Ignore.RepeatIgnore.Contains(e.detail) && e.CheckThrow(GeneralSettings.POSM, out dice))
{
ColorfulCheckPass(sender, "随机OSM", dice, GeneralSettings.POSM);
GroupMessageContent content = new(e.group_id);
string img = new Random().Next(3) switch
{
0 => "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\newosm.jpg",
1 => "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\osm.gif",
_ => "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\osm.jpg",
};
content.message.Add(new ImageMessage(img));
_ = Post(e, "Image", content);
return;
}
// 随机复读
if (GeneralSettings.IsRepeat && !Ignore.RepeatIgnore.Contains(e.detail) && e.CheckThrow(GeneralSettings.PRepeat, out dice))
{
int delay = GeneralSettings.RepeatDelay[0] + new Random().Next(GeneralSettings.RepeatDelay[1] - GeneralSettings.RepeatDelay[0]);
ColorfulCheckPass(sender, "随机复读", dice, GeneralSettings.PRepeat, delay);
GroupMessageContent content = new(e.group_id);
content.message.AddRange(e.message);
_ = Post(e, "随机复读", content, delay * 1000);
return;
}
// 随机叫哥
if (GeneralSettings.IsCallBrother && e.CheckThrow(GeneralSettings.PCallBrother, out dice))
{
int delay = GeneralSettings.RepeatDelay[0] + new Random().Next(GeneralSettings.RepeatDelay[1]);
ColorfulCheckPass(sender, "随机叫哥", dice, GeneralSettings.PCallBrother, delay);
string name = (sender.card != "" ? sender.card : sender.nickname).Trim();
int pos = new Random().Next(name.Length - 1);
GroupMessageContent content = new(e.group_id);
content.message.Add(new AtMessage(e.user_id));
content.message.Add(new TextMessage(string.Concat(name.AsSpan(pos, 2), "哥")));
_ = Post(e, "随机叫哥", content, delay * 1000);
return;
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
public static async Task<bool> CheckBlackList(GroupMessageEvent e)
{
// 黑名单
if (e.user_id == GeneralSettings.Master) return true;
if (!BlackList.Times.ContainsKey(e.user_id))
{
BlackList.Times.Add(e.user_id, 1);
return true;
}
else if (BlackList.Times.TryGetValue(e.user_id, out long bltimes) && bltimes > 5)
{
return false;
}
else if (++bltimes == 5)
{
BlackList.Times[e.user_id] = 6;
GroupMessageContent content = new(e.group_id);
content.message.Add(new AtMessage(e.user_id));
content.message.Add(new TextMessage("警告你已因短时间内频繁操作被禁止使用BOT指令" + (GeneralSettings.BlackFrozenTime / 60) + "分钟" + (GeneralSettings.BlackFrozenTime % 60) + "秒。"));
_ = Task.Run(async () =>
{
await Task.Delay(1000 * GeneralSettings.BlackFrozenTime);
BlackList.Times.Remove(e.user_id);
});
await Post(e, "黑名单", content);
return false;
}
else
{
BlackList.Times[e.user_id] = bltimes;
return true;
}
}
public static async Task Mute(GroupMessageEvent e)
{
if (!Bot.BotIsAdmin(e.group_id)) return;
bool unmute = e.detail.Contains("解禁");
string[] strs = Regex.Split(e.detail, @"\s+");
if (!unmute && strs.Length < 2) return;
if (e.user_id == GeneralSettings.Master || (unmute && GeneralSettings.UnMuteAccessGroup.Contains(e.user_id)) || (!unmute && GeneralSettings.MuteAccessGroup.Contains(e.user_id)))
{
strs = Regex.Split(e.detail.Replace(".osm mute", "").Replace("禁言", "").Replace("解禁", "").Replace("所有人", "").Trim(), @"\s+");
long time = 0;
if ((!unmute && strs.Length > 1 && long.TryParse(strs[^1], out time) && time >= 0 && time < 2592000) || unmute)
{
List<long> qqlist = [];
List<IContent> list = [];
foreach (string str in unmute ? strs : strs[..^1])
{
if (long.TryParse(str.Replace(@"@", "").Trim(), out long qq))
{
SetGroupBanContent content = new(e.group_id, qq, time);
list.Add(content);
qqlist.Add(qq);
}
}
await Post(SupportedAPI.set_group_ban, e.group_id, "禁言指令", list);
if (time > 0)
{
await Task.Delay(3000);
foreach (long qq in qqlist)
{
if (MuteRecall.Muted[e.group_id].ContainsKey(qq)) MuteRecall.Muted[e.group_id][qq] = GeneralSettings.Master;
else MuteRecall.Muted[e.group_id].Add(qq, GeneralSettings.Master);
}
}
return;
}
await Post(e, "OSM指令", MasterCommand.Execute(".osm mute", "", strs.Length > 1 ? strs[1..] : []));
}
else await Post(e, "OSM指令", "你没有权限使用此指令。");
}
public static async Task Mute(GroupMessageEvent e, IEnumerable<long> qqlist)
{
if (!Bot.BotIsAdmin(e.group_id)) return;
bool unmute = e.detail.Contains("解禁");
if (e.user_id == GeneralSettings.Master || (unmute && GeneralSettings.UnMuteAccessGroup.Contains(e.user_id)) || (!unmute && GeneralSettings.MuteAccessGroup.Contains(e.user_id)))
{
string[] strs = Regex.Split(e.detail.Replace("禁言", "").Replace("解禁", "").Replace("所有人", "").Trim(), @"\s+");
long mute_time = unmute ? 0 : GeneralSettings.MuteTime[0] + new Random().NextInt64(GeneralSettings.MuteTime[1] - GeneralSettings.MuteTime[0]);
if (long.TryParse(strs[^1], out long time) && time >= 0 && time < 2592000)
{
mute_time = time;
}
List<IContent> list = [];
foreach (long qq in qqlist)
{
SetGroupBanContent content = new(e.group_id, qq, mute_time);
list.Add(content);
}
await Post(SupportedAPI.set_group_ban, e.group_id, "批量禁言指令", list);
if (mute_time > 0)
{
await Task.Delay(3000);
foreach (long qq in qqlist)
{
if (MuteRecall.Muted[e.group_id].ContainsKey(qq)) MuteRecall.Muted[e.group_id][qq] = GeneralSettings.Master;
else MuteRecall.Muted[e.group_id].Add(qq, GeneralSettings.Master);
}
}
}
else await Post(e, "OSM指令", "你没有权限使用此指令。");
}
public static async Task MuteGroup(GroupMessageEvent e)
{
if (!Bot.BotIsAdmin(e.group_id)) return;
if (e.user_id == GeneralSettings.Master || GeneralSettings.MuteAccessGroup.Contains(e.user_id))
{
string str = e.detail.Replace(".osm mutegroup", "").Replace("跨群禁言", "").Trim();
string[] strs = Regex.Split(str, @"\s+");
if (strs.Length > 2)
{
string str_group = strs[0].Replace(@"@", "").Trim();
string str_qq = strs[1].Replace(@"@", "").Trim();
if (long.TryParse(str_group, out long group) && long.TryParse(str_qq, out long qq) && long.TryParse(strs[2], out long time) && time >= 0 && time < 2592000)
{
SetGroupBanContent content = new(group, qq, time);
await Post(SupportedAPI.set_group_ban, group, "OSM指令", content);
if (time > 0)
{
await Task.Delay(3000);
if (MuteRecall.Muted[e.group_id].ContainsKey(qq)) MuteRecall.Muted[e.group_id][qq] = GeneralSettings.Master;
else MuteRecall.Muted[e.group_id].Add(qq, GeneralSettings.Master);
}
}
else await Post(e, "OSM指令", MasterCommand.Execute(".osm mute", "", strs.Length > 1 ? strs[1..] : []));
}
else await Post(e, "OSM指令", MasterCommand.Execute(".osm mute", "", strs.Length > 1 ? strs[1..] : []));
}
else await Post(e, "OSM指令", "你没有权限使用此指令。");
}
public static void ColorfulCheckPass(Sender sender, string function, long dice, long probability, int delay = 0)
{
Console.ForegroundColor = ConsoleColor.Green;
if (delay > 0)
{
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} ");
}
Console.Write($"{sender.user_id}{(sender.card != "" ? sender.card : sender.nickname)})的{function}检定通过:{dice} < {probability}");
if (delay > 0)
{
Console.Write(" -> " + delay + "秒后执行");
}
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Gray;
}
public static async Task Post(GroupMessageEvent e, string function, string text, int delay = 0)
{
string result = (await e.SendMessage(text, delay)).ReasonPhrase ?? "";
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} F/");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(function);
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine($" G/{e.group_id} <- {text} {result}");
}
public static async Task Post(GroupMessageEvent e, string function, GroupMessageContent content, int delay = 0)
{
string result = (await e.SendMessage(content, delay)).ReasonPhrase ?? "";
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} F/");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(function);
Console.ForegroundColor = ConsoleColor.Gray;
if (!GeneralSettings.IsDebug)
{
Console.WriteLine($" G/{e.group_id} <- {content.detail} {result}");
}
else
{
Console.WriteLine($" G/{e.group_id} <- {JsonTools.GetString(content)} {result}");
}
}
public static async Task Post(string api, long group_id, string function, IContent content)
{
string result = (await HTTPPost.Post(api, content)).ReasonPhrase ?? "";
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} F/");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(function);
Console.ForegroundColor = ConsoleColor.Gray;
if (!GeneralSettings.IsDebug)
{
Console.WriteLine($" G/{group_id} <- {content.detail} {result}");
}
else
{
Console.WriteLine($" G/{group_id} <- {HTTPHelper.GetJsonString(api, content)} {result}");
}
}
public static async Task Post(string api, long group_id, string function, IEnumerable<IContent> contents)
{
await HTTPPost.Post(api, contents);
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} F/");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(function);
Console.ForegroundColor = ConsoleColor.Gray;
if (!GeneralSettings.IsDebug)
{
Console.WriteLine($" G/{group_id} <- 已在后台执行");
}
else
{
Console.WriteLine($" G/{group_id} <- 已在后台执行");
}
}
}
}

198
src/Main.cs Normal file
View File

@ -0,0 +1,198 @@
using Milimoe.OneBot.Framework;
using Milimoe.OneBot.Model.Content;
using Milimoe.OneBot.Model.Message;
using Milimoe.OneBot.Model.Other;
using Milimoe.RainBOT.ListeningTask;
using Milimoe.RainBOT.Settings;
try
{
// Debug模式启动项
if (args.Contains("--debug"))
{
GeneralSettings.IsDebug = true;
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("Debug模式");
Console.ForegroundColor = ConsoleColor.Gray;
}
HTTPListener? listener = default;
// 首先需要创建一个HTTP监听器
while (true)
{
try
{
listener = new();
if (listener.available)
{
break;
}
}
catch (Exception e_create_listener)
{
Console.WriteLine(e_create_listener);
Console.Write("你想继续吗?[y/n]");
ConsoleKeyInfo c = Console.ReadKey();
if (c.Key == ConsoleKey.N)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(" Stop");
Console.ForegroundColor = ConsoleColor.Gray;
break;
}
else
{
Console.WriteLine();
}
}
}
if (listener is null || !listener.available)
{
return;
}
Console.WriteLine("初始化参数设定...");
GeneralSettings.LoadSetting();
if (GeneralSettings.BotQQ == -1)
{
Console.Write("请设定BotQQ否则某些功能无法正常运行");
if (long.TryParse(Console.ReadLine(), out long bot_qq))
{
GeneralSettings.BotQQ = bot_qq;
}
}
if (GeneralSettings.Master == -1)
{
Console.Write("请设定MasterQQ否则某些功能无法正常运行");
if (long.TryParse(Console.ReadLine(), out long master_qq))
{
GeneralSettings.Master = master_qq;
}
}
Console.WriteLine("保存参数设定...");
GeneralSettings.SaveConfig();
try
{
Console.WriteLine("初始化机器人QQ群列表...");
await Bot.GetGroups();
Console.WriteLine("初始化机器人QQ群成员列表...");
await Bot.GetGroupMembers();
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e);
Console.ForegroundColor = ConsoleColor.Gray;
}
Console.WriteLine("初始化音频列表...");
Music.InitMusicList();
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("初始化完毕!");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine("开始监听 -> " + listener.address);
// 绑定监听事件
listener.GroupMessageListening += GroupMessageTask.ListeningTask_handler;
listener.GroupBanNoticeListening += GroupBanTask.ListeningTask_handler;
listener.FriendMessageListening += FriendMessageTask.ListeningTask_handler;
_ = Task.Factory.StartNew(async () =>
{
while (true)
{
try
{
DateTime now = DateTime.Now;
if (now.Hour == 8 && now.Minute == 30 && !Daily.DailyNews)
{
Daily.DailyNews = true;
// 发送每日新闻
foreach (Group g in Bot.Groups)
{
GroupMessageContent content = new(g.group_id);
content.message.Add(new ImageMessage("https://api.03c3.cn/api/zb"));
await g.SendMessage(content);
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("已向所有群推送今日新闻。");
Console.ForegroundColor = ConsoleColor.Gray;
}
}
if (now.Hour == 8 && now.Minute == 31)
{
Daily.DailyNews = false;
}
if (now.Hour == 0 && now.Minute == 0 && Daily.ClearDailys)
{
Daily.ClearDailys = false;
// 清空运势
Daily.UserDailys.Clear();
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("已重置所有人的今日运势。");
Console.ForegroundColor = ConsoleColor.Gray;
}
if (now.Hour == 0 && now.Minute == 1)
{
Daily.ClearDailys = true;
}
await Task.Delay(1000);
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
});
_ = Task.Factory.StartNew(async () =>
{
while (true)
{
try
{
await Task.Delay(1000 * 60);
foreach (long uid in BlackList.Times.Where(d => d.Value < 5).Select(d => d.Key))
{
BlackList.Times.Remove(uid);
}
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
});
// 循环接收消息,此线程会在没有请求时阻塞
while (true)
{
try
{
listener.GetContext();
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e);
Console.ForegroundColor = ConsoleColor.Gray;
}
}
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e);
Console.ForegroundColor = ConsoleColor.Gray;
}
Console.ReadKey();

View File

@ -0,0 +1,8 @@
{
"profiles": {
"RainBOT": {
"commandName": "Project",
"commandLineArgs": "--debug"
}
}
}

29
src/RainBOT.csproj Normal file
View File

@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Milimoe.RainBOT</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<BaseOutputPath>..\bin</BaseOutputPath>
<Authors>Milimoe</Authors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>embedded</DebugType>
<NoWarn>1701;1702;SYSLIB1045</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType>
<NoWarn>1701;1702;SYSLIB1045</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="OneBot-HTTPClient">
<HintPath>..\..\OneBot-HTTPClient\bin\Debug\net8.0\OneBot-HTTPClient.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@ -0,0 +1,7 @@
namespace Milimoe.RainBOT.Settings
{
public class BlackList
{
public static Dictionary<long, long> Times { get; } = [];
}
}

59
src/Settings/Bot.cs Normal file
View File

@ -0,0 +1,59 @@
using System.Text.Json;
using Milimoe.OneBot.Framework;
using Milimoe.OneBot.Framework.Utility;
using Milimoe.OneBot.Model.Content;
using Milimoe.OneBot.Model.Other;
namespace Milimoe.RainBOT.Settings
{
public class Bot
{
public static long BotQQ => GeneralSettings.BotQQ;
public static bool BotIsAdmin(long group_id) => IsAdmin(group_id, BotQQ);
public static List<Group> Groups { get; set; } = [];
public static Dictionary<long, List<Member>> GroupMembers { get; set; } = [];
public static bool IsAdmin(long group_id, long user_id)
{
if (GroupMembers.TryGetValue(group_id, out List<Member>? members) && members != null && members.Any(m => m.user_id == user_id && (m.role == "owner" || m.role == "admin")))
{
return true;
}
return false;
}
public static async Task GetGroups()
{
HttpResponseMessage msg = await HTTPPost.Post(SupportedAPI.get_group_list, new GroupMessageContent(0));
if (msg.IsSuccessStatusCode)
{
JsonDocument jsonDocument = JsonDocument.Parse(await msg.Content.ReadAsStringAsync());
JsonElement data = jsonDocument.RootElement.GetProperty("data");
Groups = data.Deserialize<List<Group>>(JsonTools.options) ?? [];
}
MuteRecall.Muted.Clear();
foreach (Group g in Groups)
{
MuteRecall.Muted.Add(g.group_id, []);
}
}
public static async Task GetGroupMembers()
{
GroupMembers.Clear();
foreach (Group g in Groups)
{
HttpResponseMessage msg = await HTTPPost.Post(SupportedAPI.get_group_member_list, new GetGroupMemberListContent(g.group_id));
if (msg.IsSuccessStatusCode)
{
JsonDocument jsonDocument = JsonDocument.Parse(await msg.Content.ReadAsStringAsync());
JsonElement data = jsonDocument.RootElement.GetProperty("data");
GroupMembers.Add(g.group_id, data.Deserialize<List<Member>>(JsonTools.options) ?? []);
}
}
}
}
}

44
src/Settings/Daily.cs Normal file
View File

@ -0,0 +1,44 @@
namespace Milimoe.RainBOT.Settings
{
public class Daily
{
public static bool DailyNews { get; set; } = false;
public static bool ClearDailys { get; set; } = true;
public static Dictionary<long, string> UserDailys { get; } = [];
public static List<string> DailyContent { get; } = [
"——大吉——\n会起风的日子无论干什么都会很顺利的一天。\n周围的人心情也非常愉快绝对不会发生冲突\n还可以吃到一直想吃但没机会吃的美味佳肴。\n无论是工作还是旅行都一定会十分顺利吧。\n那么应当在这样的好时辰里一鼓作气前进…\n\n今天的幸运物是茁壮成长的「鸣草」。\n许多人或许不知道鸣草是能预报雷暴的植物。\n向往着雷神大人的青睐只在稻妻列岛上生长。\n摘下鸣草时酥酥麻麻的触感据说和幸福的滋味很像。",
"——大吉——\n宝剑出匣来无往不利。出匣之光亦能照亮他人。\n今日能一箭射中空中的猎物能一击命中守卫要害。\n若没有目标不妨四处转转说不定会有意外之喜。\n同时也不要忘记和倒霉的同伴分享一下好运气哦。\n\n今天的幸运物是难得一见的「马尾」。\n马尾随大片荻草生长但却更为挺拔。\n与傲然挺立于此世的你一定很是相配。",
"——大吉——\n失而复得的一天。\n原本以为石沉大海的事情有了好的回应\n原本分道扬镳的朋友或许可以再度和好\n不经意间想起了原本已经忘记了的事情。\n世界上没有什么是永远无法挽回的\n今天就是能够挽回失去事物的日子。\n\n今天的幸运物是活蹦乱跳的「鬼兜虫」。\n鬼兜虫是爱好和平、不愿意争斗的小生物。\n这份追求平和的心一定能为你带来幸福吧。",
"——大吉——\n浮云散尽月当空逢此签者皆为上吉。\n明镜在心清如许所求之事心想则成。\n合适顺心而为的一天不管是想做的事情\n还是想见的人现在是行动起来的好时机。\n\n今天的幸运物是不断发热的「烈焰花花蕊」。\n烈焰花的炙热来自于火辣辣的花心。\n万事顺利是因为心中自有一条明路。",
"——大吉——\n今天是个上分的好日子啊好日子。\n顺手丢雷有可能炸死残血写意混烟没准会豪取五杀。\n如果情况允许不如试试盲狙说不定有意外之喜。\n今天的你手感火热s1mple来了也挡不住。\n不要忘记给失意的队友发枪分享你的好运气哦~\n\n今天的幸运来自带来好运的「高爆手雷」。\n总有人说运气来了谁都挡不住。\n殊不知运气也是实力的一部分。听说好运的人放出的烟火会有不一样的色彩。\n不如……",
"——大吉——\n晴朗无云的天气心情也变得轻松起来。\n今天不会有很多工作万事都顺顺利利。\n鼓起勇气去做一直想做却没做的事情吧\n向着目标不畏艰险而前进的人们终将会拥有胜利的果实。\n\n今天的幸运来自遇事不决「Rush B」。\n传统中不失革新简洁里蕴含变化。\n富有形式美感的战术最能激发人的潜力。",
"——中吉——\n天上有云飘过的日子天气令人十分舒畅。\n工作非常顺利连午睡时也会想到好点子。\n突然发现与老朋友还有其他的共同话题…\n——每一天每一天都要积极开朗地度过——\n\n今天的幸运物是色泽艳丽的「堇瓜」。\n人们常说表里如一是美德\n但堇瓜明艳的外貌下隐藏着的是谦卑而甘甜的内在。",
"——中吉——\n十年磨一剑今朝示霜刃。\n恶运已销身临否极泰来之时。\n苦练多年未能一显身手的才能\n现今有了大展身手的极好机会。\n若是遇到阻碍之事亦不必迷惘\n大胆地拔剑痛快地战斗一番吧。\n\n今天的幸运物是生长多年的「海灵芝」。\n弱小的海灵芝虫经历多年的风风雨雨才能结成海灵芝。\n为目标而努力前行的人们最终也必将拥有胜利的果实。",
"——中吉——\n今天会遇到比自己厉害的年轻人。\n请不要担心他对你没有恶意。\n时间带走了你曾经的辉煌反手把它们刻在了人生的计分板上。\n来不及感伤了我们还要继续走下去不是吗\n\n今天的幸运来自30岁的天才少年「f0rest」。\n瑞典CS的传奇人物至今依旧在为自己而发光发热。\nOld soldiers never die, they just fade away.",
"——中吉——\n平平淡淡的一天。\n生活最本真的味道就是无味。\n如果感到无聊的话不如来两把csgo。\n体会下游戏中的杂陈。\n\n今天的幸运来自一发致命的「AK47」。\n最平凡却最适用相信会符合你的小心思。",
"——中吉——\n如入林之深秋忽见叶卷清空徒留云影绰绰。\n今天也是如此清淡静雅却叫人欲罢不能。\n走出家门漫无目的地沉醉吧。\n只带那颗赤子之心足矣。\n\n今天的幸运来自精准而优雅的「M4A1-S」。\n冷静高效的杀手迷人却致命。\n最适合今天的你。",
"——吉——\n明明没有什么特别的事情却感到心情轻快的日子。\n在没注意过的角落可以找到本以为丢失已久的东西。\n食物比平时更加鲜美路上的风景也令人眼前一亮。\n——这个世界上充满了新奇的美好事物——\n\n今天的幸运物是散发暖意的「鸟蛋」。\n鸟蛋孕育着无限的可能性是未来之种。\n反过来这个世界对鸟蛋中的生命而言\n也充满了令其兴奋的未知事物吧。\n要温柔对待鸟蛋喔。",
"——吉——\n枯木逢春正当万物复苏之时。\n陷入困境时能得到解决办法。\n举棋不定时会有贵人来相助。\n可以整顿一番心情清理一番家装\n说不定能发现意外之财。\n\n今天的幸运物是节节高升的「竹笋」。\n竹笋拥有着无限的潜力\n没有人知道一颗竹笋到底能长成多高的竹子。\n看着竹笋会让人不由自主期待起未来吧。",
"——吉——\n一如既往的一天。身体和心灵都适应了的日常。\n出现了能替代弄丢的东西的物品令人很舒心。\n和常常遇见的人关系会变好可能会成为朋友。\n——无论是多寻常的日子都能成为宝贵的回忆——\n\n今天的幸运物是闪闪发亮的「晶核」。\n晶蝶是凝聚天地间的元素而长成的细小生物。\n而元素是这个世界许以天地当中的人们的祝福。",
"——吉——\n思维敏锐的一天很适合学习。\n学点道具学点思路学点知识学点能力。\n如果你正迷茫抛开一切去学习吧\n\n今天的幸运来自「开始努力的你」。\n千里之行始于足下。\n只要开始何时都不算晚。\n期待你成为那个能主宰自己一生的人。",
"——吉——\n明明没有什么特别的事情却依然会感到心情愉快。\n初次经历的事情也能做的十分优秀。\n游戏之前多开几张图吧也许正是扩充图池的好机会。\n\n今天的幸运来自「炼狱小镇的鸡」。\n你知道吗近距离对准小鸡按「e」可以让小鸡跟着你走。\n细心又温柔的人运气不会差。\n对了别忘了离那些拿着刀和手雷的队友远一点。",
"——末吉——\n云遮月半边雾起更迷离。\n抬头即是浮云遮月低头则是浓雾漫漫。\n虽然一时前路迷惘但也会有一切明了的时刻。\n现下不如趁此机会磨炼自我等待拨云见皎月。\n\n今天的幸运物是暗中发亮的「发光髓」。\n发光髓努力地发出微弱的光芒。\n虽然比不过其他光源但看清前路也够用了。",
"——末吉——\n空中的云层偏低并且仍有堆积之势\n不知何时雷雨会骤然从头顶倾盆而下。\n但是等雷雨过后还会有彩虹在等着。\n宜循于旧守于静若妄为则难成之。\n\n今天的幸运物是树上掉落的「松果」。\n并不是所有的松果都能长成高大的松树\n成长需要适宜的环境更需要一点运气。\n所以不用给自己过多压力耐心等待彩虹吧。",
"——末吉——\n平稳安详的一天。没有什么令人难过的事情会发生。\n适合和久未联系的朋友聊聊过去的事情一同欢笑。\n吃东西的时候会尝到很久以前体验过的过去的味道。\n——要珍惜身边的人与事——\n\n今天的幸运物是酥酥麻麻的「电气水晶」。\n电气水晶蕴含着无限的能量。\n如果能够好好导引这股能量说不定就能成就什么事业。",
"——末吉——\n气压稍微有点低是会令人想到遥远的过去的日子。\n早已过往的年轻岁月与再没联系过的故友的回忆\n会让人感到一丝平淡的怀念又稍微有一点点感伤。\n——偶尔怀念过去也很好。放松心情面对未来吧——\n\n今天的幸运物是清新怡人的「薄荷」。\n只要有草木生长的空间就一定有薄荷。\n这么看来薄荷是世界上最强韧的生灵。\n据说连蒙德的雪山上也长着薄荷呢。",
"——末吉——\n又是稀松平常的一天。\n萦绕在身旁的只有做不完的工作\n和幽冷的烟火气。\n抬头看看远方休息一下眼睛吧。\n\n今天的幸运来自A小道的挚友「格洛克-18」。\n它很小很不起眼。\n却是你重生时唯一的伙伴。\n格洛克很好快说谢谢格洛克。",
"——末吉——\n容易急躁的一天要稳住。\n高效率带来的可能会是漏洞记得复查。\n今天可能会有大把空闲时间注意合理安排。\n\n今天的幸运来自高风险高回报的「AWP」。\n蛰伏悄无声息一击毙命。\n希望狙击带来的等待与沉稳能中和你今天的火气。",
"——末吉——\n朝菌不知晦朔蟪蛄不知春秋。\n认为自己全知全能者大有人在。\n退让乃大智不要惩罚自己。\n\n今天的幸运来自火力十足的「内格夫」。\n一时的输出不是一世的胜利。\n当他弹尽粮绝时便是我反击之日。",
"——大凶——\n内心空落落的一天。可能会陷入深深的无力感之中。\n很多事情都无法理清头绪过于钻牛角尖则易生病。\n虽然一切皆陷于低潮谷底中但也不必因此而气馁。\n若能撑过一时困境他日必另有一番作为。\n\n今天的幸运物是弯弯曲曲的「蜥蜴尾巴」\n蜥蜴遇到潜在的危险时大多数会断尾求生。\n若是遇到无法整理的情绪那么该断则断吧。",
"——大凶——\n心情焦躁仿佛被所有负面情绪包裹着。\n感觉天空灰蒙蒙的也许很快就要下雨别忘记带伞。当然沙二除外。\n有些事情可能不会有结果手握16000不发枪也是他的自由要学会放手。\n身体是革命的本钱一定保重切记。\n\n今天的幸运来自神出鬼没的「自由人」。\n好的自由人能帮助队伍走向胜利别忘记检查对方出生点没准会有宝藏在等着你。",
"——大凶——\n感觉做什么都不顺利的一天。\n仿佛化身为Navi的电子哥本人对手的道具就没歪过。\n\n今天的幸运来自「生活」。\n即使是所谓的倒霉蛋现实生活中也有着幸福美满的家庭。\n多陪陪家人相信他们脸上的笑容会扫净一切阴霾。",
"——凶——\n珍惜的东西可能会遗失需要小心。\n如果身体有不适一定要注意休息。\n在做出决定之前一定要再三思考。\n\n今天的幸运物是冰凉冰凉的「冰雾花」。\n冰雾花散发着「生人勿进」的寒气。\n但有时冰冷的气质也能让人的心情与头脑冷静下来。\n据此采取正确的判断明智地行动。",
"——凶——\n隐约感觉会下雨的一天。可能会遇到不顺心的事情。\n应该的褒奖迟迟没有到来服务生也可能会上错菜。\n明明没什么大不了的事却总感觉有些心烦的日子。\n——难免有这样的日子——\n\n今天的幸运物是随波摇曳的「海草」。\n海草是相当温柔而坚强的植物\n即使在苦涩的海水中也不愿改变自己。\n即使在逆境中也不要放弃温柔的心灵。",
"——凶——\n余姚冬瓜强提醒您保护好您的显示器。\n人倒霉的时候喝凉水都能塞牙。\n在做出重要的决策之前请务必再三确认。\n\n今天的幸运来自700元大狙「沙漠之鹰」。\ncsgo不能失去700大狙就像西方不能失去耶路撒冷。\n在Nuke三楼使用沙鹰时请务必小心。",
"——凶——\n马枪有时在长时间游戏之后。\n手臂酸胀手腕僵硬好像肌肉被掏空。\n是不是太久没休息了\n想把失去的枪法练回来试试停稳再慢慢点射。\n你好队友也好。\n\n今天的幸运来自黑夜刺客「USP-S」。\nUSP之稳定在手枪中可以称得上无出其右。\n但是在古堡B包点却经常失灵至今无法解释。"
];
}
}

View File

@ -0,0 +1,168 @@
using Milimoe.OneBot.Framework.Utility;
namespace Milimoe.RainBOT.Settings
{
public class GeneralSettings
{
public static bool IsRun { get; set; } = true;
public static long BotQQ { get; set; } = -1;
public static long Master { get; set; } = -1;
public static bool IsRepeat { get; set; } = true;
public static long PRepeat { get; set; } = 7;
public static int[] RepeatDelay { get; } = [30, 80];
public static bool IsOSM { get; set; } = true;
public static long POSM { get; set; } = 2;
public static bool IsSayNo { get; set; } = true;
public static long PSayNo { get; set; } = 16;
public static bool IsMute { get; set; } = true;
public static int[] MuteTime { get; } = [1200, 12600];
public static bool IsReverseAt { get; set; } = true;
public static long PReverseAt { get; set; } = 70;
public static bool IsCallBrother { get; set; } = true;
public static long PCallBrother { get; set; } = 4;
public static bool IsDebug { get; set; } = false;
public static long BlackTimes { get; set; } = 5;
public static int BlackFrozenTime { get; set; } = 150;
public static List<long> MuteAccessGroup { get; set; } = [];
public static List<long> UnMuteAccessGroup { get; set; } = [];
public static List<long> RecallAccessGroup { get; set; } = [];
public static PluginConfig Configs { get; set; } = new("rainbot", "config");
public static void LoadSetting()
{
PluginConfig configs = new("rainbot", "config");
configs.Load();
if (configs.TryGetValue("BotQQ", out object? value) && value != null)
{
BotQQ = (long)value;
}
if (configs.TryGetValue("Master", out value) && value != null)
{
Master = (long)value;
}
if (configs.TryGetValue("IsRepeat", out value) && value != null)
{
IsRepeat = (bool)value;
}
if (configs.TryGetValue("PRepeat", out value) && value != null)
{
PRepeat = (long)value;
}
if (configs.TryGetValue("RepeatDelay", out value) && value != null)
{
long[] longs = [.. ((List<long>)value)];
RepeatDelay[0] = Convert.ToInt32(longs[0]);
RepeatDelay[1] = Convert.ToInt32(longs[1]);
}
if (configs.TryGetValue("IsOSM", out value) && value != null)
{
IsOSM = (bool)value;
}
if (configs.TryGetValue("POSM", out value) && value != null)
{
POSM = (long)value;
}
if (configs.TryGetValue("IsSayNo", out value) && value != null)
{
IsSayNo = (bool)value;
}
if (configs.TryGetValue("PSayNo", out value) && value != null)
{
PSayNo = (long)value;
}
if (configs.TryGetValue("IsMute", out value) && value != null)
{
IsMute = (bool)value;
}
if (configs.TryGetValue("MuteTime", out value) && value != null)
{
long[] longs = [.. ((List<long>)value)];
MuteTime[0] = Convert.ToInt32(longs[0]);
MuteTime[1] = Convert.ToInt32(longs[1]);
}
if (configs.TryGetValue("IsReverseAt", out value) && value != null)
{
IsReverseAt = (bool)value;
}
if (configs.TryGetValue("PReverseAt", out value) && value != null)
{
PReverseAt = (long)value;
}
if (configs.TryGetValue("IsCallBrother", out value) && value != null)
{
IsCallBrother = (bool)value;
}
if (configs.TryGetValue("PCallBrother", out value) && value != null)
{
PCallBrother = (long)value;
}
if (configs.TryGetValue("BlackTimes", out value) && value != null)
{
BlackTimes = (long)value;
}
if (configs.TryGetValue("BlackFrozenTime", out value) && value != null)
{
BlackFrozenTime = Convert.ToInt32((long)value);
}
if (configs.TryGetValue("MuteAccessGroup", out value) && value != null)
{
MuteAccessGroup = (List<long>)value;
}
if (configs.TryGetValue("UnMuteAccessGroup", out value) && value != null)
{
UnMuteAccessGroup = (List<long>)value;
}
if (configs.TryGetValue("RecallAccessGroup", out value) && value != null)
{
RecallAccessGroup = (List<long>)value;
}
}
public static void SaveConfig()
{
Configs.Add("BotQQ", BotQQ);
Configs.Add("Master", Master);
Configs.Add("IsRepeat", IsRepeat);
Configs.Add("PRepeat", PRepeat);
Configs.Add("RepeatDelay", RepeatDelay);
Configs.Add("IsOSM", IsOSM);
Configs.Add("POSM", POSM);
Configs.Add("IsSayNo", IsSayNo);
Configs.Add("PSayNo", PSayNo);
Configs.Add("IsMute", IsMute);
Configs.Add("MuteTime", MuteTime);
Configs.Add("IsReverseAt", IsReverseAt);
Configs.Add("PReverseAt", PReverseAt);
Configs.Add("IsCallBrother", IsCallBrother);
Configs.Add("PCallBrother", PCallBrother);
Configs.Add("BlackTimes", BlackTimes);
Configs.Add("BlackFrozenTime", BlackFrozenTime);
Configs.Add("MuteAccessGroup", MuteAccessGroup);
Configs.Add("UnMuteAccessGroup", UnMuteAccessGroup);
Configs.Add("RecallAccessGroup", RecallAccessGroup);
Configs.Save();
}
}
}

32
src/Settings/Ignore.cs Normal file
View File

@ -0,0 +1,32 @@
namespace Milimoe.RainBOT.Settings
{
public class Ignore
{
public static HashSet<string> RepeatIgnore { get; } = [
"我的运势",
"来图",
"白毛",
"猫耳",
"壁纸",
"新闻",
"菜单",
"白毛",
"http:",
"https:",
".com",
".cn",
".osm",
"[at=all]",
"[聊天记录]",
"禁言抽奖",
"撤回;",
"/撤回",
"白丝",
"黑丝"
];
public static List<long> IgnoreQQGroup { get; } = [
];
}
}

22
src/Settings/Music.cs Normal file
View File

@ -0,0 +1,22 @@
namespace Milimoe.RainBOT.Settings
{
public class Music
{
/// <summary>
/// 目前支持的语音包:<para/>
/// ikun<para/>
/// 懂CSGO<para/>
/// 令人沮丧的游戏<para/>
/// man<para/>
/// </summary>
public static Dictionary<string, string> MusicList { get; set; } = [];
public static void InitMusicList()
{
MusicList.Add("ikun", "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"music\ikun.mp3");
MusicList.Add("懂CSGO", "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"music\懂CSGO.mp3");
MusicList.Add("令人沮丧的游戏", "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"music\令人沮丧的游戏.mp3");
MusicList.Add("man", "file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"music\man.mp3");
}
}
}

View File

@ -0,0 +1,8 @@
namespace Milimoe.RainBOT.Settings
{
public class MuteRecall
{
public static Dictionary<long, long> WillMute { get; } = [];
public static Dictionary<long, Dictionary<long, long>> Muted { get; } = [];
}
}

11
src/Settings/OSMCore.cs Normal file
View File

@ -0,0 +1,11 @@
namespace Milimoe.RainBOT.Settings
{
public class OSMCore
{
public const string version = "v1.0";
public const string version2 = "EA Beta5";
public const string time = "Mar. 17th, 2024";
public static string Info => $"OSM Core {version} {version2}\r\nAuthor: Milimoe\r\nBuilt on {time}\r\nSee: https://github.com/milimoe";
}
}

169
src/Settings/SayNo.cs Normal file
View File

@ -0,0 +1,169 @@
namespace Milimoe.RainBOT.Settings
{
public class SayNo
{
public static HashSet<string> Trigger { get; } = [
"不",
"没",
"是",
"别"
];
public static HashSet<string> TriggerBeforeNo { get; } = [
"太",
"从来不",
"从来都",
"一直都",
"这很",
"这就是",
"实在是",
"必"
];
public static HashSet<string> IgnoreTriggerAfterNo { get; } = [
"了",
"就",
"都",
"过",
"太"
];
public static HashSet<string> TriggerAfterYes { get; } = [
"吗",
"呢",
"啊",
"么",
"吧",
"?",
""
];
public static HashSet<string> WillNotSayNo { get; } = [
"支",
"把",
"人"
];
public static List<string> SayNoWords { get; } = [
"你说不{0}就不{0}",
"不一定",
"不想{0}可以不{0}",
"这都{0}",
"不懂就问,{0}了又能怎样呢?",
"不{0}",
"必不{0}",
"我不好说",
"想{0}可以直接{0}",
"我觉得是别{0}",
"算了吧,最好别{0}",
"没出息的东西",
"没用的东西",
"纯fw",
"{0}不{0}就别来问群友了吧,成年人了可以自己拿主意",
"得了吧,没人在乎你{0}不{0}的",
"你说的这个东西跟我没关系啊,别问我了",
"从来不{0}",
"从来都{0}",
"这很{0}",
"这很不{0}",
"就这?",
"真没人{0}吧",
"为什么不{0}啊?",
"爱{0}不{0}",
"太{0}了",
"太能{0}了",
"你{0}不{0}影响我玩原神吗?",
"玩元神玩的",
"虾头",
"不会有人不{0}吧?",
"不会有人还没{0}吧?",
"看我心情",
"{0}又能怎样呢?",
"{0}不{0}又能怎样??",
"不{0}的人就像不玩原神,不用我多说了吧?",
"感觉……不如原神",
"你{0}不{0}都不影响我玩《原神》,懂吗?",
"确实",
"有一说一,确实",
"不是谁都{0}的",
"可是我{0}",
"我也不{0}",
"你不{0}不代表别人不{0}",
"{0}",
"我觉得最好别{0}吧",
"为什么不{0}?是有人拦着你吗?",
"{0}不{0}不是你说了算的",
"不是,你觉得{0}不{0}对我有什么影响呢?",
"不是很懂,你说下你为什么不想{0}吧",
"你为什么不想{0}你才20岁啊",
"笑了,真该{0}吧",
"笑了,真没人{0}吧",
"笑了,真没人在乎你{0}不{0}吧",
"好{0}",
"我就这么跟你说吧,骗哥们可以,别把你自己也骗到了就行。哥们被你骗了无所谓的,打个哈哈就过了,但希望你打完这段话后擦一下眼角,别让眼泪掉到手机屏幕上了就行。",
"只能说懂得都懂了兄弟们",
"你今天不{0}我看不起你啊",
"你凭啥不{0}啊??",
"真没人在乎你{0}不{0}吧",
"差不多得了,这不{0}等到啥时候{0}",
"我就不{0},怎么了?"
];
public static List<string> SayDontHaveWords { get; } = [
"什么年代了,还有人没{0}",
"我也没{0}",
"这很没{0}",
"你没{0}不代表别人没{0}",
"必没",
"我不好说",
"不会有人没{0}吧?",
"没{0}也就这样了",
"从来没有",
"爱有没有",
"你有没有都不影响我玩《原神》,懂吗?",
"太没{0}了",
"可是我有{0}",
"从来都有{0}",
"这还没{0}你想等到你80岁了才有{0}吗?"
];
public static List<string> SayNotYesWords { get; } = [
"是的",
"不是",
"是不是和我有关系吗?",
"我觉得最好不是",
"是不是又能怎样?",
"我觉得是",
"应该是吧",
"osm",
"你说是就是",
"从来不是",
"从来都是",
"这很不是",
"这很是",
"爱是不是"
];
public static List<string> SayDontWords { get; } = [
"算了吧,最好别{0}",
"从来不{0}",
"从来都{0}",
"想{0}可以直接{0}",
"必不{0}",
"必{0}",
"不{0}明智之举",
"我觉得{0}不{0}都那样",
"为什么不{0}啊?",
"太{0}了",
"爱{0}不{0}"
];
public static List<string> SaySpecialNoWords { get; } = [
"从来不",
"从来都",
"一直都",
"这很",
"必"
];
}
}