Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f399a14d97 | |||
| 89e64683bb | |||
| 7650bf13e4 | |||
| 832e121af5 | |||
| e9569545d8 | |||
| 39f9abd9de | |||
| 6453e42d06 | |||
| 9901077213 | |||
| 96b3241716 | |||
| 5433a2de0d | |||
| 0e0a280308 | |||
| aba9cf4037 | |||
| 06a021de49 | |||
| 89b4f2db92 | |||
| 468022ae0e | |||
| cb024e52ff | |||
| 5dbf7f4073 | |||
| d4a5d3d6ee | |||
| 233a67f2b0 |
@@ -1,674 +1,7 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
Copyright (c) 2026 RikitavTimur
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
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>.
|
|
||||||
@@ -8,6 +8,10 @@ Telegrator is a modern C# framework for building Telegram bots, inspired by AOP
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Learn and Docs
|
||||||
|
|
||||||
|
Learn Telegrator on [Official documentation site](https://rikitav.github.io/telegrator.docs).
|
||||||
|
|
||||||
The documentation may not be completely transparent, informative or even actual to latest version, so if you have any questions or problems, please write them in the [Telegram.Bot](https://t.me/joinchat/B35YY0QbLfd034CFnvCtCA) group. I am a member of this group and will notice you! If you have any suggestions or want to participate in building documentation, make push requests and open issues on this repository!
|
The documentation may not be completely transparent, informative or even actual to latest version, so if you have any questions or problems, please write them in the [Telegram.Bot](https://t.me/joinchat/B35YY0QbLfd034CFnvCtCA) group. I am a member of this group and will notice you! If you have any suggestions or want to participate in building documentation, make push requests and open issues on this repository!
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -124,7 +128,7 @@ bot.Handlers.AddHandler<StateKeepFirst>();
|
|||||||
|
|
||||||
## 📚 Documentation & Examples
|
## 📚 Documentation & Examples
|
||||||
|
|
||||||
- [Documentation](https://github.com/Rikitav/Telegrator/wiki/)
|
- [Documentation](https://rikitav.github.io/telegrator.docs)
|
||||||
- [Usage examples (WIP)](https://github.com/Rikitav/Telegrator/tree/master/examples)
|
- [Usage examples (WIP)](https://github.com/Rikitav/Telegrator/tree/master/examples)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<Project Path="src/Telegrator.Analyzers/Telegrator.Analyzers.csproj" />
|
<Project Path="src/Telegrator.Analyzers/Telegrator.Analyzers.csproj" />
|
||||||
<Project Path="src/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj" />
|
<Project Path="src/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj" />
|
||||||
<Project Path="src/Telegrator.Hosting/Telegrator.Hosting.csproj" />
|
<Project Path="src/Telegrator.Hosting/Telegrator.Hosting.csproj" />
|
||||||
|
<Project Path="src/Telegrator.Hosting.WideBot/Telegrator.Hosting.WideBot.csproj" />
|
||||||
<Project Path="src/Telegrator.Localized/Telegrator.Localized.csproj" />
|
<Project Path="src/Telegrator.Localized/Telegrator.Localized.csproj" />
|
||||||
<Project Path="src/Telegrator/Telegrator.csproj" />
|
<Project Path="src/Telegrator/Telegrator.csproj" />
|
||||||
<Project Path="tests/Telegrator.Tests/Telegrator.Tests.csproj" />
|
<Project Path="tests/Telegrator.Tests/Telegrator.Tests.csproj" />
|
||||||
|
|||||||
@@ -6,3 +6,4 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
[assembly: SuppressMessage("Style", "IDE0090")]
|
[assembly: SuppressMessage("Style", "IDE0090")]
|
||||||
|
[assembly: SuppressMessage("Roslynator", "RCS1037")]
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class ImplicitHandlerBuilderExtensionsGenerator : IIncrementalGenerator
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PrimaryConstructorBaseTypeSyntax primaryConstructor = (PrimaryConstructorBaseTypeSyntax)classDeclaration.BaseList.Types.ElementAt(0);
|
PrimaryConstructorBaseTypeSyntax primaryConstructor = (PrimaryConstructorBaseTypeSyntax)classDeclaration.BaseList.Types[0];
|
||||||
MethodDeclarationSyntax genExtension = GeneratedExtensionsMethod(classDeclaration, classDeclaration.ParameterList, primaryConstructor.ArgumentList, targeter);
|
MethodDeclarationSyntax genExtension = GeneratedExtensionsMethod(classDeclaration, classDeclaration.ParameterList, primaryConstructor.ArgumentList, targeter);
|
||||||
extensions.Add(genExtension);
|
extensions.Add(genExtension);
|
||||||
}
|
}
|
||||||
@@ -239,7 +239,7 @@ public class ImplicitHandlerBuilderExtensionsGenerator : IIncrementalGenerator
|
|||||||
if (targeters.TryGetValue(classDeclaration.Identifier.ValueText, out MethodDeclarationSyntax targeter))
|
if (targeters.TryGetValue(classDeclaration.Identifier.ValueText, out MethodDeclarationSyntax targeter))
|
||||||
return targeter;
|
return targeter;
|
||||||
|
|
||||||
if (classDeclaration.BaseList != null && targeters.TryGetValue(classDeclaration.BaseList.Types.ElementAt(0).Type.ToString(), out targeter))
|
if (classDeclaration.BaseList != null && targeters.TryGetValue(classDeclaration.BaseList.Types[0].Type.ToString(), out targeter))
|
||||||
return targeter;
|
return targeter;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,64 +1,63 @@
|
|||||||
namespace Telegrator.RoslynGenerators.RoslynExtensions
|
namespace Telegrator.RoslynGenerators.RoslynExtensions;
|
||||||
|
|
||||||
|
public static class CollectionsExtensions
|
||||||
{
|
{
|
||||||
public static class CollectionsExtensions
|
public static IEnumerable<TSource> Combine<TSource>(params IEnumerable<TSource>[] collections)
|
||||||
|
=> collections.SelectMany(x => x);
|
||||||
|
|
||||||
|
public static IEnumerable<TSource> IntersectBy<TSource, TValue>(this IEnumerable<TSource> first, IEnumerable<TValue> second, Func<TSource, TValue> selector)
|
||||||
{
|
{
|
||||||
public static IEnumerable<TSource> Combine<TSource>(params IEnumerable<TSource>[] collections)
|
foreach (TSource item in first)
|
||||||
=> collections.SelectMany(x => x);
|
|
||||||
|
|
||||||
public static IEnumerable<TSource> IntersectBy<TSource, TValue>(this IEnumerable<TSource> first, IEnumerable<TValue> second, Func<TSource, TValue> selector)
|
|
||||||
{
|
{
|
||||||
foreach (TSource item in first)
|
TValue value = selector(item);
|
||||||
{
|
if (second.Contains(value))
|
||||||
TValue value = selector(item);
|
yield return item;
|
||||||
if (second.Contains(value))
|
|
||||||
yield return item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IList<TValue> UnionAdd<TValue>(this IList<TValue> source, IEnumerable<TValue> toUnion, IEqualityComparer<TValue> comparer)
|
|
||||||
{
|
|
||||||
foreach (TValue toUnionValue in toUnion)
|
|
||||||
{
|
|
||||||
if (!source.Contains(toUnionValue, comparer))
|
|
||||||
source.Add(toUnionValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UnionAdd<TSource>(this ICollection<TSource> collection, IEnumerable<TSource> target)
|
|
||||||
{
|
|
||||||
foreach (TSource item in target)
|
|
||||||
{
|
|
||||||
if (!collection.Contains(item))
|
|
||||||
collection.Add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UnionAdd<TSource>(this SortedList<TSource, TSource> collection, IEnumerable<TSource> target)
|
|
||||||
{
|
|
||||||
foreach (TSource item in target)
|
|
||||||
{
|
|
||||||
if (!collection.Values.Contains(item))
|
|
||||||
collection.Add(item, item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int IndexOf<T>(this IEnumerable<T> source, Func<T, bool> predicate)
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
foreach (T item in source)
|
|
||||||
{
|
|
||||||
if (predicate.Invoke(item))
|
|
||||||
return index;
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<T> Repeat<T>(this T item, int times)
|
|
||||||
=> Enumerable.Range(0, times).Select(_ => item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IList<TValue> UnionAdd<TValue>(this IList<TValue> source, IEnumerable<TValue> toUnion, IEqualityComparer<TValue> comparer)
|
||||||
|
{
|
||||||
|
foreach (TValue toUnionValue in toUnion)
|
||||||
|
{
|
||||||
|
if (!source.Contains(toUnionValue, comparer))
|
||||||
|
source.Add(toUnionValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UnionAdd<TSource>(this ICollection<TSource> collection, IEnumerable<TSource> target)
|
||||||
|
{
|
||||||
|
foreach (TSource item in target)
|
||||||
|
{
|
||||||
|
if (!collection.Contains(item))
|
||||||
|
collection.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UnionAdd<TSource>(this SortedList<TSource, TSource> collection, IEnumerable<TSource> target)
|
||||||
|
{
|
||||||
|
foreach (TSource item in target)
|
||||||
|
{
|
||||||
|
if (!collection.Values.Contains(item))
|
||||||
|
collection.Add(item, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int IndexOf<T>(this IEnumerable<T> source, Func<T, bool> predicate)
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
foreach (T item in source)
|
||||||
|
{
|
||||||
|
if (predicate.Invoke(item))
|
||||||
|
return index;
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<T> Repeat<T>(this T item, int times)
|
||||||
|
=> Enumerable.Range(0, times).Select(_ => item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,12 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0">
|
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.3.0">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.14.0" />
|
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="5.3.0" />
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
+88
-203
@@ -4,191 +4,15 @@
|
|||||||
<name>Telegrator.Hosting.Web</name>
|
<name>Telegrator.Hosting.Web</name>
|
||||||
</assembly>
|
</assembly>
|
||||||
<members>
|
<members>
|
||||||
<member name="T:Telegrator.Hosting.Web.TelegramBotWebHost">
|
|
||||||
<summary>
|
|
||||||
Represents a web hosted telegram bot
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHost.Services">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHost.UpdateRouter">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHost.DataSources">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHost.Lifetime">
|
|
||||||
<summary>
|
|
||||||
Allows consumers to be notified of application lifetime events.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHost.Logger">
|
|
||||||
<summary>
|
|
||||||
This application's logger
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHost.Properties">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.#ctor(Microsoft.AspNetCore.Builder.WebApplicationBuilder)">
|
|
||||||
<summary>
|
|
||||||
Initializes a new instance of the <see cref="T:Microsoft.AspNetCore.Builder.WebApplicationBuilder"/> class.
|
|
||||||
</summary>
|
|
||||||
<param name="webApplicationBuilder">The proxied instance of host builder.</param>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.CreateBuilder(Microsoft.AspNetCore.Builder.WebApplicationOptions)">
|
|
||||||
<summary>
|
|
||||||
Creates new <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> with default services and webhook update receiving scheme
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.CreateSlimBuilder(Microsoft.AspNetCore.Builder.WebApplicationOptions)">
|
|
||||||
<summary>
|
|
||||||
Creates new SLIM <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> with default services and webhook update receiving scheme
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.CreateEmptyBuilder(Microsoft.AspNetCore.Builder.WebApplicationOptions)">
|
|
||||||
<summary>
|
|
||||||
Creates new EMPTY <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> WITHOUT any services or update receiving schemes
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.StartAsync(System.Threading.CancellationToken)">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.StopAsync(System.Threading.CancellationToken)">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.CreateApplicationBuilder">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.Use(System.Func{Microsoft.AspNetCore.Http.RequestDelegate,Microsoft.AspNetCore.Http.RequestDelegate})">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.New">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.Build">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.DisposeAsync">
|
|
||||||
<summary>
|
|
||||||
Disposes the host.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHost.Dispose">
|
|
||||||
<summary>
|
|
||||||
Disposes the host.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="T:Telegrator.Hosting.Web.TelegramBotWebHostBuilder">
|
|
||||||
<summary>
|
|
||||||
Represents a web hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Handlers">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Configuration">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Logging">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Services">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Environment">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Properties">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Metrics">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.#ctor(Microsoft.AspNetCore.Builder.WebApplicationBuilder,Microsoft.AspNetCore.Builder.WebApplicationOptions)">
|
|
||||||
<summary>
|
|
||||||
Initializes a new instance of the <see cref="T:Telegrator.Hosting.Web.TelegramBotWebHostBuilder"/> class.
|
|
||||||
</summary>
|
|
||||||
<param name="webApplicationBuilder"></param>
|
|
||||||
<param name="settings"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.#ctor(Microsoft.AspNetCore.Builder.WebApplicationBuilder,Telegrator.TelegratorOptions,Microsoft.AspNetCore.Builder.WebApplicationOptions)">
|
|
||||||
<summary>
|
|
||||||
Initializes a new instance of the <see cref="T:Telegrator.Hosting.Web.TelegramBotWebHostBuilder"/> class.
|
|
||||||
</summary>
|
|
||||||
<param name="webApplicationBuilder"></param>
|
|
||||||
<param name="options"></param>
|
|
||||||
<param name="settings"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.#ctor(Microsoft.AspNetCore.Builder.WebApplicationBuilder,Telegrator.Core.IHandlersCollection,Microsoft.AspNetCore.Builder.WebApplicationOptions)">
|
|
||||||
<summary>
|
|
||||||
Initializes a new instance of the <see cref="T:Telegrator.Hosting.Web.TelegramBotWebHostBuilder"/> class.
|
|
||||||
</summary>
|
|
||||||
<param name="webApplicationBuilder"></param>
|
|
||||||
<param name="handlers"></param>
|
|
||||||
<param name="settings"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.#ctor(Microsoft.AspNetCore.Builder.WebApplicationBuilder,Telegrator.Core.IHandlersCollection,Telegrator.TelegratorOptions,Microsoft.AspNetCore.Builder.WebApplicationOptions)">
|
|
||||||
<summary>
|
|
||||||
Initializes a new instance of the <see cref="T:Telegrator.Hosting.Web.TelegramBotWebHostBuilder"/> class.
|
|
||||||
</summary>
|
|
||||||
<param name="webApplicationBuilder"></param>
|
|
||||||
<param name="handlers"></param>
|
|
||||||
<param name="options"></param>
|
|
||||||
<param name="settings"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.Build">
|
|
||||||
<summary>
|
|
||||||
Builds the host.
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.Web.TelegramBotWebHostBuilder.ConfigureContainer``1(Microsoft.Extensions.DependencyInjection.IServiceProviderFactory{``0},System.Action{``0})">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="T:Telegrator.Hosting.Web.WebhookerOptions">
|
|
||||||
<summary>
|
|
||||||
Configuration options for Telegram bot behavior and execution settings.
|
|
||||||
Controls various aspects of bot operation including concurrency, routing, webhook receiving, and execution policies.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.WebhookerOptions.WebhookUri">
|
|
||||||
<summary>
|
|
||||||
Gets or sets HTTPS URL to send updates to. Use an empty string to remove webhook integration
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.WebhookerOptions.SecretToken">
|
|
||||||
<summary>
|
|
||||||
A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters.
|
|
||||||
Only characters A-Z, a-z, 0-9, _ and - are allowed.
|
|
||||||
The header is useful to ensure that the request comes from a webhook set by you.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.WebhookerOptions.MaxConnections">
|
|
||||||
<summary>
|
|
||||||
The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40.
|
|
||||||
Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.Web.WebhookerOptions.DropPendingUpdates">
|
|
||||||
<summary>
|
|
||||||
Pass true to drop all pending updates
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="T:Telegrator.Mediation.HostedUpdateWebhooker">
|
<member name="T:Telegrator.Mediation.HostedUpdateWebhooker">
|
||||||
<summary>
|
<summary>
|
||||||
Service for receiving updates for Hosted telegram bots via Webhooks
|
Service for receiving updates for Hosted telegram bots via Webhooks and queuing them to router
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Mediation.HostedUpdateWebhooker.#ctor(Telegram.Bot.ITelegramBotClient,Telegrator.Core.IUpdateRouter,Microsoft.Extensions.Options.IOptions{Telegrator.Hosting.Web.WebhookerOptions})">
|
<member name="M:Telegrator.Mediation.HostedUpdateWebhooker.#ctor(Telegram.Bot.ITelegramBotClient,Telegrator.Core.IUpdateRouter,Microsoft.Extensions.Options.IOptions{Telegrator.WebhookerOptions})">
|
||||||
<summary>
|
<summary>
|
||||||
Initiallizes new instance of <see cref="T:Telegrator.Mediation.HostedUpdateWebhooker"/>
|
Initiallizes new instance of <see cref="T:Telegrator.Mediation.HostedUpdateWebhooker"/>
|
||||||
</summary>
|
</summary>
|
||||||
<param name="botHost"></param>
|
|
||||||
<param name="botClient"></param>
|
<param name="botClient"></param>
|
||||||
<param name="updateRouter"></param>
|
<param name="updateRouter"></param>
|
||||||
<param name="options"></param>
|
<param name="options"></param>
|
||||||
@@ -200,57 +24,118 @@
|
|||||||
<member name="M:Telegrator.Mediation.HostedUpdateWebhooker.StopAsync(System.Threading.CancellationToken)">
|
<member name="M:Telegrator.Mediation.HostedUpdateWebhooker.StopAsync(System.Threading.CancellationToken)">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Telegrator.Mediation.HostedUpdateWebhooker.RemapWebhook(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder,System.String,System.Threading.CancellationToken)">
|
||||||
|
<summary>
|
||||||
|
Allows to remap receiving webhook endpoint and map new route to webhost.
|
||||||
|
</summary>
|
||||||
|
<param name="routeBuilder"></param>
|
||||||
|
<param name="webhookUri"></param>
|
||||||
|
<param name="cancellationToken"></param>
|
||||||
|
<returns></returns>
|
||||||
|
<exception cref="T:System.ArgumentException"></exception>
|
||||||
|
</member>
|
||||||
<member name="M:Telegrator.Mediation.HostedUpdateWebhooker.MapWebhook(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder)">
|
<member name="M:Telegrator.Mediation.HostedUpdateWebhooker.MapWebhook(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder)">
|
||||||
<summary>
|
<summary>
|
||||||
Maps bot webhook to application builder
|
Maps bot webhook to application builder
|
||||||
</summary>
|
</summary>
|
||||||
<param name="routeBuilder"></param>
|
<param name="routeBuilder"></param>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:Telegrator.ServicesCollectionExtensions">
|
<member name="T:Telegrator.WebHostBuilderExtensions">
|
||||||
|
<summary>
|
||||||
|
Provides extension methods for <see cref="T:Microsoft.Extensions.Hosting.IHostApplicationBuilder"/> to configure Telegrator.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WebHostBuilderExtensions.AddTelegratorWeb(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
|
||||||
|
<summary>
|
||||||
|
Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WebHostBuilderExtensions.AddTelegratorWeb(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection,System.Action{Telegrator.Hosting.ITelegramBotHostBuilder})">
|
||||||
|
<summary>
|
||||||
|
Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WebHostBuilderExtensions.AddTelegratorWebInternal(Microsoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.Configuration.IConfiguration,System.Collections.Generic.IDictionary{System.Object,System.Object},Telegrator.Core.IHandlersCollection@,Telegrator.TelegratorOptions)">
|
||||||
|
<summary>
|
||||||
|
Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="T:Telegrator.WebServicesCollectionExtensions">
|
||||||
<summary>
|
<summary>
|
||||||
Contains extensions for <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection"/>
|
Contains extensions for <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection"/>
|
||||||
Provides method to configure Telegram Bot WebHost
|
Provides method to configure Telegram Bot WebHost
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="F:Telegrator.ServicesCollectionExtensions.HandlersCollectionPropertyKey">
|
<member name="M:Telegrator.WebServicesCollectionExtensions.ConfigureWebhooker(Microsoft.Extensions.DependencyInjection.IServiceCollection,Telegrator.WebhookerOptions)">
|
||||||
<summary>
|
<summary>
|
||||||
The key used to store the <see cref="T:Telegrator.Core.IHandlersCollection"/> in the builder properties.
|
Adds WebhookerOptions to services
|
||||||
|
</summary>
|
||||||
|
<param name="services"></param>
|
||||||
|
<param name="options"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WebServicesCollectionExtensions.TryFindWebhooker(System.IServiceProvider,Telegrator.Mediation.HostedUpdateWebhooker@)">
|
||||||
|
<summary>
|
||||||
|
Searchs for <see cref="T:Telegrator.Mediation.HostedUpdateWebhooker"/> hosted service inside hosts services
|
||||||
|
</summary>
|
||||||
|
<param name="services"></param>
|
||||||
|
<param name="webhooker"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="T:Telegrator.WebTelegramBotHostExtensions">
|
||||||
|
<summary>
|
||||||
|
Provides useful methods to adjust Telegram bot Host
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.ServicesCollectionExtensions.get_Handlers(Microsoft.AspNetCore.Builder.WebApplicationBuilder)">
|
<member name="M:Telegrator.WebTelegramBotHostExtensions.UseTelegratorWeb``1(``0,System.Boolean)">
|
||||||
<inheritdoc cref="P:Telegrator.ServicesCollectionExtensions.<G>$41F16C2D39AF52899E745C9C9F42FF83.Handlers"/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.ServicesCollectionExtensions.AddTelegratorWeb(Telegrator.Hosting.ITelegramBotHostBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection,System.Action{Telegrator.Hosting.ITelegramBotHostBuilder})">
|
|
||||||
<summary>
|
|
||||||
Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.ServicesCollectionExtensions.AddTelegratorWeb(Microsoft.AspNetCore.Builder.WebApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection,System.Action{Telegrator.Hosting.ITelegramBotHostBuilder})">
|
|
||||||
<summary>
|
|
||||||
Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.ServicesCollectionExtensions.AddTelegratorWebInternal(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
|
|
||||||
<summary>
|
|
||||||
Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.ServicesCollectionExtensions.UseTelegratorWeb``1(``0)">
|
|
||||||
<summary>
|
<summary>
|
||||||
Replaces the initialization logic from TelegramBotWebHost constructor.
|
Replaces the initialization logic from TelegramBotWebHost constructor.
|
||||||
Initializes the bot and logs handlers on application startup.
|
Initializes the bot and logs handlers on application startup.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.ServicesCollectionExtensions.AddTelegramWebhook(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
|
<member name="M:Telegrator.WebTelegramBotHostExtensions.RemapWebhook``1(``0,System.String)">
|
||||||
|
<summary>
|
||||||
|
Allows to remap receiving webhook endpoint and map new route to webhost.
|
||||||
|
</summary>
|
||||||
|
<param name="app"></param>
|
||||||
|
<param name="webhookUri"></param>
|
||||||
|
<returns></returns>
|
||||||
|
<exception cref="T:System.ArgumentException"></exception>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WebTelegramBotHostExtensions.AddTelegramWebhook(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
|
||||||
<summary>
|
<summary>
|
||||||
Registers <see cref="T:Telegram.Bot.ITelegramBotClient"/> service with <see cref="T:Telegrator.Mediation.HostedUpdateWebhooker"/> to receive updates using webhook
|
Registers <see cref="T:Telegram.Bot.ITelegramBotClient"/> service with <see cref="T:Telegrator.Mediation.HostedUpdateWebhooker"/> to receive updates using webhook
|
||||||
</summary>
|
</summary>
|
||||||
<param name="services"></param>
|
<param name="services"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:Telegrator.ServicesCollectionExtensions.<G>$41F16C2D39AF52899E745C9C9F42FF83.Handlers">
|
<member name="T:Telegrator.WebhookerOptions">
|
||||||
<summary>
|
<summary>
|
||||||
Gets the <see cref="T:Telegrator.Core.IHandlersCollection"/> from the builder properties.
|
Configuration options for Telegram bot behavior and execution settings.
|
||||||
|
Controls various aspects of bot operation including concurrency, routing, webhook receiving, and execution policies.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WebhookerOptions.WebhookUri">
|
||||||
|
<summary>
|
||||||
|
Gets or sets HTTPS URL to send updates to. Use an empty string to remove webhook integration
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WebhookerOptions.SecretToken">
|
||||||
|
<summary>
|
||||||
|
A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters.
|
||||||
|
Only characters A-Z, a-z, 0-9, _ and - are allowed.
|
||||||
|
The header is useful to ensure that the request comes from a webhook set by you.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WebhookerOptions.MaxConnections">
|
||||||
|
<summary>
|
||||||
|
The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40.
|
||||||
|
Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WebhookerOptions.DropPendingUpdates">
|
||||||
|
<summary>
|
||||||
|
Pass true to drop all pending updates
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
</members>
|
</members>
|
||||||
|
|||||||
@@ -0,0 +1,205 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<doc>
|
||||||
|
<assembly>
|
||||||
|
<name>Telegrator.Hosting.WideBot</name>
|
||||||
|
</assembly>
|
||||||
|
<members>
|
||||||
|
<member name="T:Telegrator.Mediation.HostedWideBotUpdateReceiver">
|
||||||
|
<summary>
|
||||||
|
Service for receiving updates for Hosted wide telegram bots and queuing them to router
|
||||||
|
</summary>
|
||||||
|
<param name="logger"></param>
|
||||||
|
<param name="botClient"></param>
|
||||||
|
<param name="updateRouter"></param>
|
||||||
|
<param name="options"></param>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.Mediation.HostedWideBotUpdateReceiver.#ctor(Microsoft.Extensions.Logging.ILogger{Telegrator.Mediation.HostedWideBotUpdateReceiver},Telegram.Bot.ITelegramBotClient,Telegrator.Core.IUpdateRouter,Microsoft.Extensions.Options.IOptions{Telegrator.WideBotOptions})">
|
||||||
|
<summary>
|
||||||
|
Service for receiving updates for Hosted wide telegram bots and queuing them to router
|
||||||
|
</summary>
|
||||||
|
<param name="logger"></param>
|
||||||
|
<param name="botClient"></param>
|
||||||
|
<param name="updateRouter"></param>
|
||||||
|
<param name="options"></param>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.Mediation.HostedWideBotUpdateReceiver.ExecuteAsync(System.Threading.CancellationToken)">
|
||||||
|
<inheritdoc/>
|
||||||
|
</member>
|
||||||
|
<member name="T:Telegrator.Mediation.WideUpdateReceiver">
|
||||||
|
<summary>
|
||||||
|
Reactive implementation of <see cref="T:Telegrator.Core.IUpdateReceiver"/> for polling updates from Telegram.
|
||||||
|
Provides custom update receiving logic with error handling and configuration options.
|
||||||
|
</summary>
|
||||||
|
<param name="client">The Telegram bot client for making API requests.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.Mediation.WideUpdateReceiver.#ctor(Telegram.Bot.WTelegramBotClient)">
|
||||||
|
<summary>
|
||||||
|
Reactive implementation of <see cref="T:Telegrator.Core.IUpdateReceiver"/> for polling updates from Telegram.
|
||||||
|
Provides custom update receiving logic with error handling and configuration options.
|
||||||
|
</summary>
|
||||||
|
<param name="client">The Telegram bot client for making API requests.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.Mediation.WideUpdateReceiver.ReceiveAsync(Telegram.Bot.Polling.IUpdateHandler,System.Threading.CancellationToken)">
|
||||||
|
<inheritdoc/>
|
||||||
|
</member>
|
||||||
|
<member name="T:Telegrator.TelegratorWClient">
|
||||||
|
<summary>
|
||||||
|
Client class for the Telegrator library with Wider functionality, provided by WTelegramBotClient.
|
||||||
|
Extends TelegramBotClient with reactive capabilities for handling updates.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.TelegratorWClient.Options">
|
||||||
|
<inheritdoc/>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.TelegratorWClient.Handlers">
|
||||||
|
<inheritdoc/>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.TelegratorWClient.BotInfo">
|
||||||
|
<inheritdoc/>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.TelegratorWClient.UpdateRouter">
|
||||||
|
<inheritdoc/>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.TelegratorWClient.#ctor(Telegram.Bot.WTelegramBotClientOptions,Telegrator.TelegratorOptions,System.Net.Http.HttpClient,System.Threading.CancellationToken)">
|
||||||
|
<summary>
|
||||||
|
Initializes new instance of <see cref="T:Telegrator.TelegratorWClient"/>
|
||||||
|
</summary>
|
||||||
|
<param name="wOptions"></param>
|
||||||
|
<param name="telegratorOptions"></param>
|
||||||
|
<param name="httpClient"></param>
|
||||||
|
<param name="cancellationToken"></param>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.TelegratorWClient.StartReceiving(Telegram.Bot.Polling.ReceiverOptions,System.Threading.CancellationToken)">
|
||||||
|
<inheritdoc/>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.TelegratorWClient.StartReceivingAsync(Telegram.Bot.Polling.ReceiverOptions,System.Threading.CancellationToken)">
|
||||||
|
<inheritdoc/>
|
||||||
|
</member>
|
||||||
|
<member name="T:Telegrator.HandlersExtensions">
|
||||||
|
<summary>
|
||||||
|
Provides extensions memebrs for <see cref="T:Telegrator.Core.Handlers.UpdateHandlerBase"/> for easy access to Wider bot functions and update
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.HandlersExtensions.get_WClient``1(Telegrator.Core.Handlers.AbstractUpdateHandler{``0})">
|
||||||
|
<inheritdoc cref="P:Telegrator.HandlersExtensions.<G>$F89AF16C011F73161937A1614DCDDD7A`1.WClient"/>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.HandlersExtensions.get_WideUpdate``1(Telegrator.Core.Handlers.AbstractUpdateHandler{``0})">
|
||||||
|
<inheritdoc cref="P:Telegrator.HandlersExtensions.<G>$F89AF16C011F73161937A1614DCDDD7A`1.WideUpdate"/>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.HandlersExtensions.get_TLUpdate``1(Telegrator.Core.Handlers.AbstractUpdateHandler{``0})">
|
||||||
|
<inheritdoc cref="P:Telegrator.HandlersExtensions.<G>$F89AF16C011F73161937A1614DCDDD7A`1.TLUpdate"/>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.HandlersExtensions.AsWClient(Telegram.Bot.ITelegramBotClient)">
|
||||||
|
<summary>
|
||||||
|
Casts Update to <see cref="T:Telegram.Bot.WTelegramBotClient"/>
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.HandlersExtensions.AsWUpdate(Telegram.Bot.Types.Update)">
|
||||||
|
<summary>
|
||||||
|
Casts Update to <see cref="T:WTelegram.Types.Update"/>
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.HandlersExtensions.<G>$F89AF16C011F73161937A1614DCDDD7A`1.WClient">
|
||||||
|
<summary>
|
||||||
|
Casts Update to <see cref="T:Telegram.Bot.WTelegramBotClient"/>
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.HandlersExtensions.<G>$F89AF16C011F73161937A1614DCDDD7A`1.WideUpdate">
|
||||||
|
<summary>
|
||||||
|
Casts Update to <see cref="T:WTelegram.Types.Update"/>
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.HandlersExtensions.<G>$F89AF16C011F73161937A1614DCDDD7A`1.TLUpdate">
|
||||||
|
<summary>
|
||||||
|
Casts Update to <see cref="T:TL.Update"/>
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="T:Telegrator.WideHostBuilderExtensions">
|
||||||
|
<summary>
|
||||||
|
Provides extension methods for <see cref="T:Microsoft.Extensions.Hosting.IHostApplicationBuilder"/> to configure Telegrator.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WideHostBuilderExtensions.AddWideTelegrator(Microsoft.Extensions.Hosting.IHostApplicationBuilder,System.Func{System.IServiceProvider,System.Data.Common.DbConnection},System.Action{Telegrator.Hosting.ITelegramBotHostBuilder},Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
|
||||||
|
<summary>
|
||||||
|
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WideHostBuilderExtensions.AddWideTelegrator(Microsoft.Extensions.Hosting.IHostApplicationBuilder,System.Func{System.IServiceProvider,System.Data.Common.DbConnection},Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
|
||||||
|
<summary>
|
||||||
|
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WideHostBuilderExtensions.AddWideTelegratorInternal(Microsoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.Configuration.IConfiguration,System.Collections.Generic.IDictionary{System.Object,System.Object},System.Func{System.IServiceProvider,System.Data.Common.DbConnection},Telegrator.Core.IHandlersCollection@,Telegrator.TelegratorOptions)">
|
||||||
|
<summary>
|
||||||
|
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="T:Telegrator.WideBotServiceCollectionExtensions">
|
||||||
|
<summary>
|
||||||
|
Contains extensions for <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection"/>
|
||||||
|
Provides method to configure Telegram Bot WebHost
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WideBotServiceCollectionExtensions.ConfigureWideTelegram(Microsoft.Extensions.DependencyInjection.IServiceCollection,Telegram.Bot.WTelegramBotClientOptions)">
|
||||||
|
<summary>
|
||||||
|
Adds WTelegramBotClientOptions to services
|
||||||
|
</summary>
|
||||||
|
<param name="services"></param>
|
||||||
|
<param name="options"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WideBotServiceCollectionExtensions.ConfigureWideBot(Microsoft.Extensions.DependencyInjection.IServiceCollection,Telegrator.WideBotOptions)">
|
||||||
|
<summary>
|
||||||
|
Adds WTelegramBotClientOptions to services
|
||||||
|
</summary>
|
||||||
|
<param name="services"></param>
|
||||||
|
<param name="options"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WideBotServiceCollectionExtensions.AddMTProtoUpdateReceiver(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Boolean)">
|
||||||
|
<summary>
|
||||||
|
Adds WTelegramBotClient
|
||||||
|
</summary>
|
||||||
|
<param name="services"></param>
|
||||||
|
<param name="useHttp"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="T:Telegrator.WideTelegramBotHostExtensions">
|
||||||
|
<summary>
|
||||||
|
Provides useful methods to adjust Telegram bot Host
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.WideTelegramBotHostExtensions.UseWideTelegrator(Microsoft.Extensions.Hosting.IHost)">
|
||||||
|
<summary>
|
||||||
|
Replaces the initialization logic from TelegramBotWebHost constructor.
|
||||||
|
Initializes the bot and logs handlers on application startup.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="T:Telegrator.WideBotOptions">
|
||||||
|
<summary>
|
||||||
|
Represents configuration options for initializing and customizing the behavior of a WideBot instance.
|
||||||
|
</summary>
|
||||||
|
<remarks>Use this class to specify required API credentials, optional proxy settings, update handling
|
||||||
|
preferences, and SQL command detection for WideBot. All required properties must be set before using the options
|
||||||
|
with a WideBot instance.
|
||||||
|
</remarks>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WideBotOptions.ApiId">
|
||||||
|
<inheritdoc cref="P:Telegram.Bot.WTelegramBotClientOptions.ApiId"/>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WideBotOptions.ApiHash">
|
||||||
|
<inheritdoc cref="P:Telegram.Bot.WTelegramBotClientOptions.ApiHash"/>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WideBotOptions.MTProxy">
|
||||||
|
<inheritdoc cref="P:Telegram.Bot.WTelegramBotClientOptions.MTProxy"/>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WideBotOptions.SqlCommands">
|
||||||
|
<inheritdoc cref="P:Telegram.Bot.WTelegramBotClientOptions.SqlCommands"/>
|
||||||
|
</member>
|
||||||
|
<member name="P:Telegrator.WideBotOptions.DropPendingUpdates">
|
||||||
|
<summary>
|
||||||
|
Gets or sets a value indicating whether pending updates should be discarded.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
</members>
|
||||||
|
</doc>
|
||||||
+49
-110
@@ -35,68 +35,14 @@
|
|||||||
Provides access to configuration of this Hosted telegram bot
|
Provides access to configuration of this Hosted telegram bot
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:Telegrator.Hosting.TelegramBotHost">
|
<member name="T:Telegrator.Hosting.ITelegramBotHostBuilder">
|
||||||
<summary>
|
|
||||||
Represents a hosted telegram bot
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.TelegramBotHost.Services">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.TelegramBotHost.UpdateRouter">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Hosting.TelegramBotHost.Logger">
|
|
||||||
<summary>
|
|
||||||
This application's logger
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHost.#ctor(Microsoft.Extensions.Hosting.HostApplicationBuilder)">
|
|
||||||
<summary>
|
|
||||||
Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHost"/> class.
|
|
||||||
</summary>
|
|
||||||
<param name="hostApplicationBuilder">The proxied instance of host builder.</param>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHost.CreateBuilder">
|
|
||||||
<summary>
|
|
||||||
Creates new <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> with default configuration, services and long-polling update receiving scheme
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHost.CreateBuilder(Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)">
|
|
||||||
<summary>
|
|
||||||
Creates new <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> with default services and long-polling update receiving scheme
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHost.CreateEmptyBuilder">
|
|
||||||
<summary>
|
|
||||||
Creates new EMPTY <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> WITHOUT any services or update receiving schemes
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHost.CreateEmptyBuilder(Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)">
|
|
||||||
<summary>
|
|
||||||
Creates new EMPTY <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> WITHOUT any services or update receiving schemes
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHost.StartAsync(System.Threading.CancellationToken)">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHost.StopAsync(System.Threading.CancellationToken)">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHost.Dispose">
|
|
||||||
<summary>
|
|
||||||
Disposes the host.
|
|
||||||
</summary>
|
|
||||||
</member>
|
|
||||||
<member name="T:Telegrator.Hosting.TelegramBotHostBuilder">
|
|
||||||
<summary>
|
<summary>
|
||||||
Represents a hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more.
|
Represents a hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:Telegrator.Hosting.TelegramBotHostBuilder">
|
||||||
|
<inheritdoc/>
|
||||||
|
</member>
|
||||||
<member name="P:Telegrator.Hosting.TelegramBotHostBuilder.Handlers">
|
<member name="P:Telegrator.Hosting.TelegramBotHostBuilder.Handlers">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
</member>
|
</member>
|
||||||
@@ -118,43 +64,18 @@
|
|||||||
<member name="P:Telegrator.Hosting.TelegramBotHostBuilder.Metrics">
|
<member name="P:Telegrator.Hosting.TelegramBotHostBuilder.Metrics">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.HostApplicationBuilder,Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)">
|
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.IHostApplicationBuilder)">
|
||||||
<summary>
|
<summary>
|
||||||
Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class.
|
Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class.
|
||||||
</summary>
|
</summary>
|
||||||
<param name="hostApplicationBuilder"></param>
|
<param name="hostApplicationBuilder"></param>
|
||||||
<param name="settings"></param>
|
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.HostApplicationBuilder,Telegrator.TelegratorOptions,Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)">
|
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Telegrator.Core.IHandlersCollection)">
|
||||||
<summary>
|
|
||||||
Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class.
|
|
||||||
</summary>
|
|
||||||
<param name="hostApplicationBuilder"></param>
|
|
||||||
<param name="options"></param>
|
|
||||||
<param name="settings"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.HostApplicationBuilder,Telegrator.Core.IHandlersCollection,Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)">
|
|
||||||
<summary>
|
<summary>
|
||||||
Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class.
|
Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class.
|
||||||
</summary>
|
</summary>
|
||||||
<param name="hostApplicationBuilder"></param>
|
<param name="hostApplicationBuilder"></param>
|
||||||
<param name="handlers"></param>
|
<param name="handlers"></param>
|
||||||
<param name="settings"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.#ctor(Microsoft.Extensions.Hosting.HostApplicationBuilder,Telegrator.Core.IHandlersCollection,Telegrator.TelegratorOptions,Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)">
|
|
||||||
<summary>
|
|
||||||
Initializes a new instance of the <see cref="T:Telegrator.Hosting.TelegramBotHostBuilder"/> class.
|
|
||||||
</summary>
|
|
||||||
<param name="hostApplicationBuilder"></param>
|
|
||||||
<param name="handlers"></param>
|
|
||||||
<param name="options"></param>
|
|
||||||
<param name="settings"></param>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.Build">
|
|
||||||
<summary>
|
|
||||||
Builds the host.
|
|
||||||
</summary>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.ConfigureContainer``1(Microsoft.Extensions.DependencyInjection.IServiceProviderFactory{``0},System.Action{``0})">
|
<member name="M:Telegrator.Hosting.TelegramBotHostBuilder.ConfigureContainer``1(Microsoft.Extensions.DependencyInjection.IServiceProviderFactory{``0},System.Action{``0})">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
@@ -174,42 +95,42 @@
|
|||||||
<member name="M:Telegrator.Logging.MicrosoftLoggingAdapter.Log(Telegrator.Logging.LogLevel,System.String,System.Exception)">
|
<member name="M:Telegrator.Logging.MicrosoftLoggingAdapter.Log(Telegrator.Logging.LogLevel,System.String,System.Exception)">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:Telegrator.Polling.HostedUpdateReceiver">
|
<member name="T:Telegrator.Mediation.HostedUpdateReceiver">
|
||||||
<summary>
|
<summary>
|
||||||
Service for receiving updates for Hosted telegram bots
|
Service for receiving updates for Hosted telegram botsand queuing them to router
|
||||||
</summary>
|
</summary>
|
||||||
<param name="botClient"></param>
|
<param name="botClient"></param>
|
||||||
<param name="updateRouter"></param>
|
<param name="updateRouter"></param>
|
||||||
<param name="options"></param>
|
<param name="options"></param>
|
||||||
<param name="logger"></param>
|
<param name="logger"></param>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Polling.HostedUpdateReceiver.#ctor(Telegram.Bot.ITelegramBotClient,Telegrator.Core.IUpdateRouter,Microsoft.Extensions.Options.IOptions{Telegram.Bot.Polling.ReceiverOptions},Microsoft.Extensions.Logging.ILogger{Telegrator.Polling.HostedUpdateReceiver})">
|
<member name="M:Telegrator.Mediation.HostedUpdateReceiver.#ctor(Telegram.Bot.ITelegramBotClient,Telegrator.Core.IUpdateRouter,Microsoft.Extensions.Options.IOptions{Telegram.Bot.Polling.ReceiverOptions},Microsoft.Extensions.Logging.ILogger{Telegrator.Mediation.HostedUpdateReceiver})">
|
||||||
<summary>
|
<summary>
|
||||||
Service for receiving updates for Hosted telegram bots
|
Service for receiving updates for Hosted telegram botsand queuing them to router
|
||||||
</summary>
|
</summary>
|
||||||
<param name="botClient"></param>
|
<param name="botClient"></param>
|
||||||
<param name="updateRouter"></param>
|
<param name="updateRouter"></param>
|
||||||
<param name="options"></param>
|
<param name="options"></param>
|
||||||
<param name="logger"></param>
|
<param name="logger"></param>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Polling.HostedUpdateReceiver.ExecuteAsync(System.Threading.CancellationToken)">
|
<member name="M:Telegrator.Mediation.HostedUpdateReceiver.ExecuteAsync(System.Threading.CancellationToken)">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:Telegrator.Polling.HostUpdateRouter">
|
<member name="T:Telegrator.Mediation.HostUpdateRouter">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
</member>
|
</member>
|
||||||
<member name="F:Telegrator.Polling.HostUpdateRouter.Logger">
|
<member name="F:Telegrator.Mediation.HostUpdateRouter.Logger">
|
||||||
<summary>
|
<summary>
|
||||||
<see cref="T:Microsoft.Extensions.Logging.ILogger"/> of this router
|
<see cref="T:Microsoft.Extensions.Logging.ILogger"/> of this router
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Polling.HostUpdateRouter.#ctor(Telegrator.Core.IHandlersProvider,Telegrator.Core.IAwaitingProvider,Telegrator.Core.States.IStateStorage,Microsoft.Extensions.Options.IOptions{Telegrator.TelegratorOptions},Telegrator.Core.ITelegramBotInfo,Microsoft.Extensions.Logging.ILogger{Telegrator.Polling.HostUpdateRouter})">
|
<member name="M:Telegrator.Mediation.HostUpdateRouter.#ctor(Telegrator.Core.IHandlersProvider,Telegrator.Core.IAwaitingProvider,Telegrator.Core.States.IStateStorage,Microsoft.Extensions.Options.IOptions{Telegrator.TelegratorOptions},Telegrator.Core.ITelegramBotInfo,Microsoft.Extensions.Logging.ILogger{Telegrator.Mediation.HostUpdateRouter})">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Polling.HostUpdateRouter.HandleUpdateAsync(Telegram.Bot.ITelegramBotClient,Telegram.Bot.Types.Update,System.Threading.CancellationToken)">
|
<member name="M:Telegrator.Mediation.HostUpdateRouter.HandleUpdateAsync(Telegram.Bot.ITelegramBotClient,Telegram.Bot.Types.Update,System.Threading.CancellationToken)">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Polling.HostUpdateRouter.HandleException(Telegram.Bot.ITelegramBotClient,System.Exception,Telegram.Bot.Polling.HandleErrorSource,System.Threading.CancellationToken)">
|
<member name="M:Telegrator.Mediation.HostUpdateRouter.HandleException(Telegram.Bot.ITelegramBotClient,System.Exception,Telegram.Bot.Polling.HandleErrorSource,System.Threading.CancellationToken)">
|
||||||
<summary>
|
<summary>
|
||||||
Default exception handler of this router
|
Default exception handler of this router
|
||||||
</summary>
|
</summary>
|
||||||
@@ -255,36 +176,54 @@
|
|||||||
The key used to store the <see cref="T:Telegrator.Core.IHandlersCollection"/> in the builder properties.
|
The key used to store the <see cref="T:Telegrator.Core.IHandlersCollection"/> in the builder properties.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.HostBuilderExtensions.get_Handlers(Microsoft.Extensions.Hosting.HostApplicationBuilder)">
|
<member name="M:Telegrator.HostBuilderExtensions.AddTelegrator(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection,System.Action{Telegrator.Hosting.ITelegramBotHostBuilder})">
|
||||||
<inheritdoc cref="P:Telegrator.HostBuilderExtensions.<G>$BF7227490CCA365283B3A9274C9033C7.Handlers"/>
|
|
||||||
</member>
|
|
||||||
<member name="M:Telegrator.HostBuilderExtensions.AddTelegrator(Telegrator.Hosting.ITelegramBotHostBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection,System.Action{Telegrator.Hosting.ITelegramBotHostBuilder})">
|
|
||||||
<summary>
|
<summary>
|
||||||
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.HostBuilderExtensions.AddTelegrator(Microsoft.Extensions.Hosting.HostApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection,System.Action{Telegrator.Hosting.ITelegramBotHostBuilder})">
|
<member name="M:Telegrator.HostBuilderExtensions.AddTelegrator(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
|
||||||
<summary>
|
<summary>
|
||||||
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.HostBuilderExtensions.AddTelegratorInternal(Microsoft.Extensions.Hosting.IHostApplicationBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
|
<member name="M:Telegrator.HostBuilderExtensions.AddTelegrator(Microsoft.Extensions.Hosting.IHostBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection)">
|
||||||
<summary>
|
<summary>
|
||||||
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:Telegrator.HostBuilderExtensions.<G>$BF7227490CCA365283B3A9274C9033C7.Handlers">
|
<member name="M:Telegrator.HostBuilderExtensions.AddTelegrator(Microsoft.Extensions.Hosting.IHostBuilder,Telegrator.TelegratorOptions,Telegrator.Core.IHandlersCollection,System.Action{Telegrator.Core.IHandlersCollection})">
|
||||||
<summary>
|
<summary>
|
||||||
Gets the <see cref="T:Telegrator.Core.IHandlersCollection"/> from the builder properties.
|
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="T:Telegrator.ServicesCollectionExtensions">
|
<member name="M:Telegrator.HostBuilderExtensions.AddTelegratorInternal(Microsoft.Extensions.DependencyInjection.IServiceCollection,Microsoft.Extensions.Configuration.IConfiguration,System.Collections.Generic.IDictionary{System.Object,System.Object},Telegrator.Core.IHandlersCollection@,Telegrator.TelegratorOptions)">
|
||||||
|
<summary>
|
||||||
|
Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="T:Telegrator.HostServicesCollectionExtensions">
|
||||||
<summary>
|
<summary>
|
||||||
Contains extensions for <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection"/>
|
Contains extensions for <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection"/>
|
||||||
Provides method to configure Telegram Bot Host
|
Provides method to configure Telegram Bot Host
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.ServicesCollectionExtensions.AddStateStorage``1(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
|
<member name="M:Telegrator.HostServicesCollectionExtensions.ConfigureTelegram(Microsoft.Extensions.DependencyInjection.IServiceCollection,Telegram.Bot.TelegramBotClientOptions)">
|
||||||
|
<summary>
|
||||||
|
Adds TelegramBotClientOptions to services
|
||||||
|
</summary>
|
||||||
|
<param name="services"></param>
|
||||||
|
<param name="options"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.HostServicesCollectionExtensions.ConfigureReceiver(Microsoft.Extensions.DependencyInjection.IServiceCollection,Telegram.Bot.Polling.ReceiverOptions)">
|
||||||
|
<summary>
|
||||||
|
Adds ReceiverOptions to services
|
||||||
|
</summary>
|
||||||
|
<param name="services"></param>
|
||||||
|
<param name="options"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.HostServicesCollectionExtensions.AddStateStorage``1(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
|
||||||
<summary>
|
<summary>
|
||||||
Registers <see cref="T:Telegrator.Core.States.IStateStorage"/> service
|
Registers <see cref="T:Telegrator.Core.States.IStateStorage"/> service
|
||||||
</summary>
|
</summary>
|
||||||
@@ -292,21 +231,21 @@
|
|||||||
<param name="services"></param>
|
<param name="services"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.ServicesCollectionExtensions.AddTelegramBotHostDefaults(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
|
<member name="M:Telegrator.HostServicesCollectionExtensions.AddTelegramBotHostDefaults(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
|
||||||
<summary>
|
<summary>
|
||||||
Registers <see cref="T:Telegrator.Hosting.TelegramBotHost"/> default services
|
Registers <see cref="N:Telegrator"/> default services
|
||||||
</summary>
|
</summary>
|
||||||
<param name="services"></param>
|
<param name="services"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.ServicesCollectionExtensions.AddTelegramReceiver(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
|
<member name="M:Telegrator.HostServicesCollectionExtensions.AddTelegramReceiver(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
|
||||||
<summary>
|
<summary>
|
||||||
Registers <see cref="T:Telegram.Bot.ITelegramBotClient"/> service with <see cref="T:Telegrator.Polling.HostedUpdateReceiver"/> to receive updates using long polling
|
Registers <see cref="T:Telegram.Bot.ITelegramBotClient"/> service with <see cref="T:Telegrator.Mediation.HostedUpdateReceiver"/> to receive updates using long polling
|
||||||
</summary>
|
</summary>
|
||||||
<param name="services"></param>
|
<param name="services"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.ServicesCollectionExtensions.TypedTelegramBotClientFactory(System.Net.Http.HttpClient,System.IServiceProvider)">
|
<member name="M:Telegrator.HostServicesCollectionExtensions.TypedTelegramBotClientFactory(System.Net.Http.HttpClient,System.IServiceProvider)">
|
||||||
<summary>
|
<summary>
|
||||||
<see cref="T:Telegram.Bot.ITelegramBotClient"/> factory method
|
<see cref="T:Telegram.Bot.ITelegramBotClient"/> factory method
|
||||||
</summary>
|
</summary>
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<doc>
|
||||||
|
<assembly>
|
||||||
|
<name>Telegrator.Localized</name>
|
||||||
|
</assembly>
|
||||||
|
<members>
|
||||||
|
</members>
|
||||||
|
</doc>
|
||||||
+80
-19
@@ -2226,7 +2226,7 @@
|
|||||||
</member>
|
</member>
|
||||||
<member name="F:Telegrator.Core.Handlers.Building.HandlerBuilderBase.HandlerCollection">
|
<member name="F:Telegrator.Core.Handlers.Building.HandlerBuilderBase.HandlerCollection">
|
||||||
<summary>
|
<summary>
|
||||||
<see cref="T:Telegrator.Core.IHandlersCollection"/> to ehich new builded handlers is adding
|
<see cref="T:Telegrator.Core.IHandlersCollection"/> to which new builded handlers is adding
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="F:Telegrator.Core.Handlers.Building.HandlerBuilderBase.UpdateType">
|
<member name="F:Telegrator.Core.Handlers.Building.HandlerBuilderBase.UpdateType">
|
||||||
@@ -2749,6 +2749,14 @@
|
|||||||
<param name="updateType">The update type key.</param>
|
<param name="updateType">The update type key.</param>
|
||||||
<returns>The handler descriptor list for the given update type.</returns>
|
<returns>The handler descriptor list for the given update type.</returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Telegrator.Core.IHandlersCollection.TryGetDescriptorList(Telegram.Bot.Types.Enums.UpdateType,Telegrator.Core.Descriptors.HandlerDescriptorList@)">
|
||||||
|
<summary>
|
||||||
|
Tryes to get the <see cref="T:Telegrator.Core.Descriptors.HandlerDescriptorList"/> for the specified <see cref="T:Telegram.Bot.Types.Enums.UpdateType"/>.
|
||||||
|
</summary>
|
||||||
|
<param name="updateType"></param>
|
||||||
|
<param name="list"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:Telegrator.Core.IHandlersCollection.AddDescriptor(Telegrator.Core.Descriptors.HandlerDescriptor)">
|
<member name="M:Telegrator.Core.IHandlersCollection.AddDescriptor(Telegrator.Core.Descriptors.HandlerDescriptor)">
|
||||||
<summary>
|
<summary>
|
||||||
Adds a <see cref="T:Telegrator.Core.Descriptors.HandlerDescriptor"/> to the collection and returns the updated collection.
|
Adds a <see cref="T:Telegrator.Core.Descriptors.HandlerDescriptor"/> to the collection and returns the updated collection.
|
||||||
@@ -2774,7 +2782,7 @@
|
|||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Core.IHandlersProvider.TryGetDescriptorList(Telegram.Bot.Types.Enums.UpdateType,Telegrator.Core.Descriptors.HandlerDescriptorList@)">
|
<member name="M:Telegrator.Core.IHandlersProvider.TryGetDescriptorList(Telegram.Bot.Types.Enums.UpdateType,Telegrator.Core.Descriptors.HandlerDescriptorList@)">
|
||||||
<summary>
|
<summary>
|
||||||
|
Gets the collection of <see cref="T:Telegram.Bot.Types.Enums.UpdateType"/> keys for the handler lists.
|
||||||
</summary>
|
</summary>
|
||||||
<param name="updateType"></param>
|
<param name="updateType"></param>
|
||||||
<param name="list"></param>
|
<param name="list"></param>
|
||||||
@@ -4529,7 +4537,7 @@
|
|||||||
Gets the update that triggered this awaiter handler.
|
Gets the update that triggered this awaiter handler.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.Handlers.Building.AwaiterHandler.Wait(System.Threading.CancellationToken)">
|
<member name="M:Telegrator.Handlers.Building.AwaiterHandler.Await(System.Threading.CancellationToken)">
|
||||||
<summary>
|
<summary>
|
||||||
Waits for the specified update type to be received.
|
Waits for the specified update type to be received.
|
||||||
</summary>
|
</summary>
|
||||||
@@ -5475,6 +5483,14 @@
|
|||||||
Gets the update router for handling incoming updates.
|
Gets the update router for handling incoming updates.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Telegrator.ITelegratorBot.StartReceivingAsync(Telegram.Bot.Polling.ReceiverOptions,System.Threading.CancellationToken)">
|
||||||
|
<summary>
|
||||||
|
Initializes the update router and begins polling for updates asynchronously.
|
||||||
|
</summary>
|
||||||
|
<param name="receiverOptions">Optional receiver options for configuring update polling.</param>
|
||||||
|
<param name="cancellationToken">The cancellation token to stop receiving updates.</param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="T:Telegrator.Logging.ConsoleLogger">
|
<member name="T:Telegrator.Logging.ConsoleLogger">
|
||||||
<summary>
|
<summary>
|
||||||
Console logger implementation that writes to System.Console.
|
Console logger implementation that writes to System.Console.
|
||||||
@@ -6019,6 +6035,9 @@
|
|||||||
Manages the distribution of updates between regular handlers and awaiting handlers.
|
Manages the distribution of updates between regular handlers and awaiting handlers.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:Telegrator.Mediation.UpdateRouter.Options">
|
||||||
|
<inheritdoc/>
|
||||||
|
</member>
|
||||||
<member name="P:Telegrator.Mediation.UpdateRouter.HandlersProvider">
|
<member name="P:Telegrator.Mediation.UpdateRouter.HandlersProvider">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
</member>
|
</member>
|
||||||
@@ -6028,9 +6047,6 @@
|
|||||||
<member name="P:Telegrator.Mediation.UpdateRouter.StateStorage">
|
<member name="P:Telegrator.Mediation.UpdateRouter.StateStorage">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:Telegrator.Mediation.UpdateRouter.Options">
|
|
||||||
<inheritdoc/>
|
|
||||||
</member>
|
|
||||||
<member name="P:Telegrator.Mediation.UpdateRouter.HandlersPool">
|
<member name="P:Telegrator.Mediation.UpdateRouter.HandlersPool">
|
||||||
<inheritdoc/>
|
<inheritdoc/>
|
||||||
</member>
|
</member>
|
||||||
@@ -6237,6 +6253,9 @@
|
|||||||
<param name="descriptor">The handler descriptor to check for command aliases.</param>
|
<param name="descriptor">The handler descriptor to check for command aliases.</param>
|
||||||
<exception cref="T:System.Exception">Thrown when intersecting command aliases are found and ExceptIntersectingCommandAliases is enabled.</exception>
|
<exception cref="T:System.Exception">Thrown when intersecting command aliases are found and ExceptIntersectingCommandAliases is enabled.</exception>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Telegrator.Providers.HandlersCollection.TryGetDescriptorList(Telegram.Bot.Types.Enums.UpdateType,Telegrator.Core.Descriptors.HandlerDescriptorList@)">
|
||||||
|
<inheritdoc/>
|
||||||
|
</member>
|
||||||
<member name="T:Telegrator.Providers.HandlersManagerBase">
|
<member name="T:Telegrator.Providers.HandlersManagerBase">
|
||||||
<summary>
|
<summary>
|
||||||
Provides functionality of incrementally collecting, organizing and resolving handlers instances.
|
Provides functionality of incrementally collecting, organizing and resolving handlers instances.
|
||||||
@@ -6366,14 +6385,14 @@
|
|||||||
Represents handler results, allowing to communicate with router and control aspect execution
|
Represents handler results, allowing to communicate with router and control aspect execution
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:Telegrator.Result.Positive">
|
<member name="P:Telegrator.Result.Success">
|
||||||
<summary>
|
<summary>
|
||||||
Is result positive
|
Tell router to stop describing
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:Telegrator.Result.RouteNext">
|
<member name="P:Telegrator.Result.RouteNext">
|
||||||
<summary>
|
<summary>
|
||||||
Should router search for next matching handler
|
Tell router to continue describing
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="P:Telegrator.Result.NextType">
|
<member name="P:Telegrator.Result.NextType">
|
||||||
@@ -6438,6 +6457,14 @@
|
|||||||
<param name="keySelector"></param>
|
<param name="keySelector"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Telegrator.ColletionsExtensions.Squeeze``1(System.Collections.Generic.IEnumerable{``0})">
|
||||||
|
<summary>
|
||||||
|
Remove all <see langword="null"/> values and returns collection without nullable type.
|
||||||
|
</summary>
|
||||||
|
<typeparam name="T"></typeparam>
|
||||||
|
<param name="source"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:Telegrator.ColletionsExtensions.ForEach``1(System.Collections.Generic.IEnumerable{``0},System.Action{``0})">
|
<member name="M:Telegrator.ColletionsExtensions.ForEach``1(System.Collections.Generic.IEnumerable{``0},System.Action{``0})">
|
||||||
<summary>
|
<summary>
|
||||||
Enumerates objects in a <paramref name="source"/> and executes an <paramref name="action"/> on each one
|
Enumerates objects in a <paramref name="source"/> and executes an <paramref name="action"/> on each one
|
||||||
@@ -6502,7 +6529,7 @@
|
|||||||
<param name="predicate"></param>
|
<param name="predicate"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.ColletionsExtensions.SingleSafe``1(System.Collections.Generic.IEnumerable{``0})">
|
<member name="M:Telegrator.ColletionsExtensions.SingleOrNothing``1(System.Collections.Generic.IEnumerable{``0})">
|
||||||
<summary>
|
<summary>
|
||||||
Returns the only element of a sequence, or a default value if the sequence is empty.
|
Returns the only element of a sequence, or a default value if the sequence is empty.
|
||||||
This method returns default if there is more than one element in the sequence.
|
This method returns default if there is more than one element in the sequence.
|
||||||
@@ -6511,7 +6538,7 @@
|
|||||||
<param name="source"></param>
|
<param name="source"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.ColletionsExtensions.SingleSafe``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})">
|
<member name="M:Telegrator.ColletionsExtensions.SingleOrNothing``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})">
|
||||||
<summary>
|
<summary>
|
||||||
Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists.
|
Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists.
|
||||||
This method return default if more than one element satisfies the condition.
|
This method return default if more than one element satisfies the condition.
|
||||||
@@ -6547,7 +6574,7 @@
|
|||||||
<param name="type"></param>
|
<param name="type"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.ReflectionExtensions.IsHandlerRealization(System.Type)">
|
<member name="M:Telegrator.ReflectionExtensions.IsHandlerImplementation(System.Type)">
|
||||||
<summary>
|
<summary>
|
||||||
Checks if <paramref name="type"/> is an implementation of <see cref="T:Telegrator.Core.Handlers.UpdateHandlerBase"/> class or its descendants
|
Checks if <paramref name="type"/> is an implementation of <see cref="T:Telegrator.Core.Handlers.UpdateHandlerBase"/> class or its descendants
|
||||||
</summary>
|
</summary>
|
||||||
@@ -6785,13 +6812,8 @@
|
|||||||
<param name="httpClient">Optional HTTP client for making requests.</param>
|
<param name="httpClient">Optional HTTP client for making requests.</param>
|
||||||
<param name="cancellationToken">The cancellation token.</param>
|
<param name="cancellationToken">The cancellation token.</param>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.TelegratorClient.StartReceiving(Telegram.Bot.Polling.ReceiverOptions,System.Threading.CancellationToken)">
|
<member name="M:Telegrator.TelegratorClient.StartReceivingAsync(Telegram.Bot.Polling.ReceiverOptions,System.Threading.CancellationToken)">
|
||||||
<summary>
|
<inheritdoc/>
|
||||||
Starts receiving updates from Telegram.
|
|
||||||
Initializes the update router and begins polling for updates.
|
|
||||||
</summary>
|
|
||||||
<param name="receiverOptions">Optional receiver options for configuring update polling.</param>
|
|
||||||
<param name="cancellationToken">The cancellation token to stop receiving updates.</param>
|
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Telegrator.TelegratorClient.StartReceivingInternal(Telegram.Bot.Polling.ReceiverOptions,System.Threading.CancellationToken)">
|
<member name="M:Telegrator.TelegratorClient.StartReceivingInternal(Telegram.Bot.Polling.ReceiverOptions,System.Threading.CancellationToken)">
|
||||||
<summary>
|
<summary>
|
||||||
@@ -6852,6 +6874,19 @@
|
|||||||
Gets or sets the global cancellation token for all bot operations.
|
Gets or sets the global cancellation token for all bot operations.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:Telegrator.TelegratorBotExtensions">
|
||||||
|
<summary>
|
||||||
|
Provides usefull helper methods for TelegratorBot
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Telegrator.TelegratorBotExtensions.StartReceiving(Telegrator.ITelegratorBot,Telegram.Bot.Polling.ReceiverOptions,System.Threading.CancellationToken)">
|
||||||
|
<summary>
|
||||||
|
Initializes the update router and begins polling for updates synchronously (Blocking calling thread).
|
||||||
|
</summary>
|
||||||
|
<param name="bot"></param>
|
||||||
|
<param name="receiverOptions">Optional receiver options for configuring update polling.</param>
|
||||||
|
<param name="cancellationToken">The cancellation token to stop receiving updates.</param>
|
||||||
|
</member>
|
||||||
<member name="T:Telegrator.MessageExtensions">
|
<member name="T:Telegrator.MessageExtensions">
|
||||||
<summary>
|
<summary>
|
||||||
Provides usefull helper methods for messages
|
Provides usefull helper methods for messages
|
||||||
@@ -6976,6 +7011,16 @@
|
|||||||
<param name="handlingUpdate">The update that triggered the awaiter creation.</param>
|
<param name="handlingUpdate">The update that triggered the awaiter creation.</param>
|
||||||
<returns>An awaiter handler builder for the specified update type.</returns>
|
<returns>An awaiter handler builder for the specified update type.</returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Telegrator.AwaitingProviderExtensions.CreateDeleting``1(Telegrator.Core.IAwaitingProvider,Telegram.Bot.Types.Enums.UpdateType,Telegram.Bot.Types.Update)">
|
||||||
|
<summary>
|
||||||
|
Creates an awaiter handler builder for a specific update type that will delete the awaiting handler after awaiting is completed.
|
||||||
|
</summary>
|
||||||
|
<typeparam name="TUpdate"></typeparam>
|
||||||
|
<param name="awaitingProvider"></param>
|
||||||
|
<param name="updateType"></param>
|
||||||
|
<param name="handlingUpdate"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:Telegrator.AwaitingProviderExtensions.AwaitAny(Telegrator.Core.IAwaitingProvider,Telegram.Bot.Types.Update)">
|
<member name="M:Telegrator.AwaitingProviderExtensions.AwaitAny(Telegrator.Core.IAwaitingProvider,Telegram.Bot.Types.Update)">
|
||||||
<summary>
|
<summary>
|
||||||
Creates an awaiter builder for any update type.
|
Creates an awaiter builder for any update type.
|
||||||
@@ -7000,6 +7045,14 @@
|
|||||||
<param name="handlingUpdate"></param>
|
<param name="handlingUpdate"></param>
|
||||||
<returns>An awaiter builder for callback query updates.</returns>
|
<returns>An awaiter builder for callback query updates.</returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Telegrator.AwaitingProviderExtensions.CancellAllCallbacks(Telegrator.Core.IAwaitingProvider,Telegram.Bot.Types.Update)">
|
||||||
|
<summary>
|
||||||
|
Deletes all awaiting handlers for callback query updates.
|
||||||
|
</summary>
|
||||||
|
<param name="awaitingProvider"></param>
|
||||||
|
<param name="handlingUpdate"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="T:Telegrator.HandlersProviderExtensions">
|
<member name="T:Telegrator.HandlersProviderExtensions">
|
||||||
<summary>
|
<summary>
|
||||||
Extesions method for handlers providers
|
Extesions method for handlers providers
|
||||||
@@ -7084,6 +7137,14 @@
|
|||||||
Provides convenient methods for creating implicit handlers.
|
Provides convenient methods for creating implicit handlers.
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Telegrator.HandlersCollectionExtensions.CollectHandlers(Telegrator.Core.IHandlersCollection)">
|
||||||
|
<summary>
|
||||||
|
Collects all handlers from current app domain.
|
||||||
|
Scans for handlers exported by analyzer into class `Telegrator.Analyzers.AnalyzerExport` in each assembly and registers them to the collection.
|
||||||
|
</summary>
|
||||||
|
<param name="handlers"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:Telegrator.HandlersCollectionExtensions.CollectHandlersDomainWide(Telegrator.Core.IHandlersCollection)">
|
<member name="M:Telegrator.HandlersCollectionExtensions.CollectHandlersDomainWide(Telegrator.Core.IHandlersCollection)">
|
||||||
<summary>
|
<summary>
|
||||||
Collects all public handlers from the current app domain.
|
Collects all public handlers from the current app domain.
|
||||||
|
|||||||
@@ -13,9 +13,12 @@
|
|||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
<Title>Telegrator.RedisStateStorage</Title>
|
<Title>Telegrator.RedisStateStorage</Title>
|
||||||
<Version>1.16.6</Version>
|
<Version>1.17.2</Version>
|
||||||
<Authors>Rikitav Tim4ik</Authors>
|
<Authors>Rikitav Tim4ik</Authors>
|
||||||
<Company>Rikitav Tim4ik</Company>
|
<Company>Rikitav Tim4ik</Company>
|
||||||
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
|
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
|
||||||
@@ -31,7 +34,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="StackExchange.Redis" Version="2.11.8" />
|
<PackageReference Include="StackExchange.Redis" Version="2.12.14" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ namespace Telegrator.Analyzers;
|
|||||||
[Generator(LanguageNames.CSharp)]
|
[Generator(LanguageNames.CSharp)]
|
||||||
public class DeveloperHelperAnalyzer : IIncrementalGenerator
|
public class DeveloperHelperAnalyzer : IIncrementalGenerator
|
||||||
{
|
{
|
||||||
|
internal record class HandlerDeclarationModel(string ClassName, string NamespaceName, string? AttributeName, string? BaseClassName, Location Location);
|
||||||
|
|
||||||
private static readonly DiagnosticDescriptor MissingBaseClassWarning = new(
|
private static readonly DiagnosticDescriptor MissingBaseClassWarning = new(
|
||||||
id: "TLG101",
|
id: "TLG101",
|
||||||
title: "Missing handlers base class",
|
title: "Missing handlers base class",
|
||||||
@@ -131,9 +133,8 @@ public class DeveloperHelperAnalyzer : IIncrementalGenerator
|
|||||||
|
|
||||||
private static FieldDeclarationSyntax GenerateTypeField(HandlerDeclarationModel handler)
|
private static FieldDeclarationSyntax GenerateTypeField(HandlerDeclarationModel handler)
|
||||||
{
|
{
|
||||||
string fullTypeName = handler.Namespace == "Global"
|
string fullTypeName = handler.NamespaceName == "Global"
|
||||||
? handler.ClassName
|
? handler.ClassName : $"{handler.NamespaceName}.{handler.ClassName}";
|
||||||
: $"{handler.Namespace}.{handler.ClassName}";
|
|
||||||
|
|
||||||
TypeOfExpressionSyntax typeofExpression = SyntaxFactory.TypeOfExpression(SyntaxFactory.ParseTypeName(fullTypeName));
|
TypeOfExpressionSyntax typeofExpression = SyntaxFactory.TypeOfExpression(SyntaxFactory.ParseTypeName(fullTypeName));
|
||||||
VariableDeclaratorSyntax variableDeclarator = SyntaxFactory.VariableDeclarator(SyntaxFactory.Identifier($"{handler.ClassName}Type"))
|
VariableDeclaratorSyntax variableDeclarator = SyntaxFactory.VariableDeclarator(SyntaxFactory.Identifier($"{handler.ClassName}Type"))
|
||||||
@@ -149,15 +150,6 @@ public class DeveloperHelperAnalyzer : IIncrementalGenerator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class HandlerDeclarationModel(string className, string namespaceName, string? attributeName, string? baseClassName, Location location)
|
|
||||||
{
|
|
||||||
public readonly string ClassName = className;
|
|
||||||
public readonly string Namespace = namespaceName;
|
|
||||||
public readonly string? AttributeName = attributeName;
|
|
||||||
public readonly string? BaseClassName = baseClassName;
|
|
||||||
public readonly Location Location = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static class DeveloperHelperAnalyzerExtensions
|
internal static class DeveloperHelperAnalyzerExtensions
|
||||||
{
|
{
|
||||||
private static readonly string[] HandlersNames =
|
private static readonly string[] HandlersNames =
|
||||||
|
|||||||
+5
-27
@@ -8,8 +8,12 @@ using System.Text;
|
|||||||
namespace Telegrator.Analyzers;
|
namespace Telegrator.Analyzers;
|
||||||
|
|
||||||
[Generator(LanguageNames.CSharp)]
|
[Generator(LanguageNames.CSharp)]
|
||||||
public class GeneratedKeyboardMarkupGenerator : IIncrementalGenerator
|
public class KeyboardMarkupGenerator : IIncrementalGenerator
|
||||||
{
|
{
|
||||||
|
// Records
|
||||||
|
private record class GeneratedMarkupMethodModel(MethodDeclarationSyntax OriginalMethod, FieldDeclarationSyntax GeneratedField, MethodDeclarationSyntax GeneratedMethod);
|
||||||
|
private record class GeneratedMarkupPropertyModel(PropertyDeclarationSyntax OriginalProperty, PropertyDeclarationSyntax GeneratedProperty);
|
||||||
|
|
||||||
// Return types
|
// Return types
|
||||||
private const string InlineReturnType = "InlineKeyboardMarkup";
|
private const string InlineReturnType = "InlineKeyboardMarkup";
|
||||||
private const string ReplyReturnType = "ReplyKeyboardMarkup";
|
private const string ReplyReturnType = "ReplyKeyboardMarkup";
|
||||||
@@ -459,30 +463,4 @@ public class GeneratedKeyboardMarkupGenerator : IIncrementalGenerator
|
|||||||
SyntaxFactory.IdentifierName(className),
|
SyntaxFactory.IdentifierName(className),
|
||||||
SyntaxFactory.IdentifierName(methodName));
|
SyntaxFactory.IdentifierName(methodName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GeneratedMarkupMethodModel
|
|
||||||
{
|
|
||||||
public MethodDeclarationSyntax OriginalMethod { get; }
|
|
||||||
public FieldDeclarationSyntax GeneratedField { get; }
|
|
||||||
public MethodDeclarationSyntax GeneratedMethod { get; }
|
|
||||||
|
|
||||||
public GeneratedMarkupMethodModel(MethodDeclarationSyntax originalMethod, FieldDeclarationSyntax generatedField, MethodDeclarationSyntax generatedMethod)
|
|
||||||
{
|
|
||||||
OriginalMethod = originalMethod;
|
|
||||||
GeneratedField = generatedField;
|
|
||||||
GeneratedMethod = generatedMethod;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class GeneratedMarkupPropertyModel
|
|
||||||
{
|
|
||||||
public PropertyDeclarationSyntax OriginalProperty { get; }
|
|
||||||
public PropertyDeclarationSyntax GeneratedProperty { get; }
|
|
||||||
|
|
||||||
public GeneratedMarkupPropertyModel(PropertyDeclarationSyntax originalProperty, PropertyDeclarationSyntax generatedProperty)
|
|
||||||
{
|
|
||||||
OriginalProperty = originalProperty;
|
|
||||||
GeneratedProperty = generatedProperty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace Telegrator.Analyzers.RoslynExtensions;
|
namespace Telegrator.Analyzers.RoslynExtensions;
|
||||||
|
|
||||||
public class TargteterNotFoundException() : Exception() { }
|
#pragma warning disable RCS1194 // Implement exception constructors
|
||||||
|
public class TargteterNotFoundException() : Exception();
|
||||||
public class BaseClassTypeNotFoundException() : Exception() { }
|
public class BaseClassTypeNotFoundException() : Exception();
|
||||||
|
public class AncestorNotFoundException() : Exception();
|
||||||
public class AncestorNotFoundException : Exception { }
|
#pragma warning restore RCS1194 // Implement exception constructors
|
||||||
|
|||||||
@@ -9,12 +9,12 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0">
|
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.3.0">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.14.0" />
|
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="5.3.0" />
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0" />
|
||||||
|
|
||||||
<PackageReference Include="PolySharp" Version="1.15.0">
|
<PackageReference Include="PolySharp" Version="1.15.0">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
|||||||
@@ -10,3 +10,5 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
[assembly: SuppressMessage("Usage", "CA2254")]
|
[assembly: SuppressMessage("Usage", "CA2254")]
|
||||||
[assembly: SuppressMessage("Maintainability", "CA1510")]
|
[assembly: SuppressMessage("Maintainability", "CA1510")]
|
||||||
[assembly: SuppressMessage("Style", "IDE0270")]
|
[assembly: SuppressMessage("Style", "IDE0270")]
|
||||||
|
[assembly: SuppressMessage("Roslynator", "RCS1037")]
|
||||||
|
[assembly: SuppressMessage("Roslynator", "RCS1224")]
|
||||||
|
|||||||
@@ -1,159 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
|
||||||
using Microsoft.AspNetCore.Routing;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Telegrator.Core;
|
|
||||||
|
|
||||||
namespace Telegrator.Hosting.Web;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a web hosted telegram bot
|
|
||||||
/// </summary>
|
|
||||||
public class TelegramBotWebHost : IHost, IApplicationBuilder, IEndpointRouteBuilder, IAsyncDisposable
|
|
||||||
{
|
|
||||||
private readonly WebApplication _innerApp;
|
|
||||||
private readonly IUpdateRouter _updateRouter;
|
|
||||||
private readonly ILogger<TelegramBotWebHost> _logger;
|
|
||||||
|
|
||||||
private bool _disposed;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IServiceProvider Services => _innerApp.Services;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IUpdateRouter UpdateRouter => _updateRouter;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ICollection<EndpointDataSource> DataSources => ((IEndpointRouteBuilder)_innerApp).DataSources;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Allows consumers to be notified of application lifetime events.
|
|
||||||
/// </summary>
|
|
||||||
public IHostApplicationLifetime Lifetime => _innerApp.Lifetime;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This application's logger
|
|
||||||
/// </summary>
|
|
||||||
public ILogger<TelegramBotWebHost> Logger => _logger;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IDictionary<string, object?> Properties => ((IApplicationBuilder)_innerApp).Properties;
|
|
||||||
|
|
||||||
// Private interface fields
|
|
||||||
IServiceProvider IEndpointRouteBuilder.ServiceProvider => Services;
|
|
||||||
IServiceProvider IApplicationBuilder.ApplicationServices { get => Services; set => throw new NotImplementedException(); }
|
|
||||||
IFeatureCollection IApplicationBuilder.ServerFeatures => ((IApplicationBuilder)_innerApp).ServerFeatures;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="WebApplicationBuilder"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="webApplicationBuilder">The proxied instance of host builder.</param>
|
|
||||||
public TelegramBotWebHost(WebApplicationBuilder webApplicationBuilder)
|
|
||||||
{
|
|
||||||
// Building proxy application
|
|
||||||
_innerApp = webApplicationBuilder.Build();
|
|
||||||
|
|
||||||
// Reruesting services for this host
|
|
||||||
_updateRouter = Services.GetRequiredService<IUpdateRouter>();
|
|
||||||
_logger = Services.GetRequiredService<ILogger<TelegramBotWebHost>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates new <see cref="TelegramBotHostBuilder"/> with default services and webhook update receiving scheme
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static TelegramBotWebHostBuilder CreateBuilder(WebApplicationOptions settings)
|
|
||||||
{
|
|
||||||
ArgumentNullException.ThrowIfNull(settings, nameof(settings));
|
|
||||||
WebApplicationBuilder innerApp = WebApplication.CreateBuilder(settings);
|
|
||||||
TelegramBotWebHostBuilder builder = new TelegramBotWebHostBuilder(innerApp, settings);
|
|
||||||
builder.AddTelegratorWeb();
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates new SLIM <see cref="TelegramBotHostBuilder"/> with default services and webhook update receiving scheme
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static TelegramBotWebHostBuilder CreateSlimBuilder(WebApplicationOptions settings)
|
|
||||||
{
|
|
||||||
ArgumentNullException.ThrowIfNull(settings, nameof(settings));
|
|
||||||
WebApplicationBuilder innerApp = WebApplication.CreateSlimBuilder(settings);
|
|
||||||
TelegramBotWebHostBuilder builder = new TelegramBotWebHostBuilder(innerApp, settings);
|
|
||||||
builder.AddTelegratorWeb();
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates new EMPTY <see cref="TelegramBotHostBuilder"/> WITHOUT any services or update receiving schemes
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static TelegramBotWebHostBuilder CreateEmptyBuilder(WebApplicationOptions settings)
|
|
||||||
{
|
|
||||||
ArgumentNullException.ThrowIfNull(settings, nameof(settings));
|
|
||||||
WebApplicationBuilder innerApp = WebApplication.CreateEmptyBuilder(settings);
|
|
||||||
TelegramBotWebHostBuilder builder = new TelegramBotWebHostBuilder(innerApp, settings);
|
|
||||||
builder.AddTelegratorWeb();
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public async Task StartAsync(CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
await _innerApp.StartAsync(cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public async Task StopAsync(CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
await _innerApp.StopAsync(cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IApplicationBuilder CreateApplicationBuilder()
|
|
||||||
=> ((IEndpointRouteBuilder)_innerApp).CreateApplicationBuilder();
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware)
|
|
||||||
=> _innerApp.Use(middleware);
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IApplicationBuilder New()
|
|
||||||
=> ((IApplicationBuilder)_innerApp).New();
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public RequestDelegate Build()
|
|
||||||
=> ((IApplicationBuilder)_innerApp).Build();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disposes the host.
|
|
||||||
/// </summary>
|
|
||||||
public async ValueTask DisposeAsync()
|
|
||||||
{
|
|
||||||
if (_disposed)
|
|
||||||
return;
|
|
||||||
|
|
||||||
await _innerApp.DisposeAsync();
|
|
||||||
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
_disposed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disposes the host.
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (_disposed)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ValueTask disposeTask = _innerApp.DisposeAsync();
|
|
||||||
disposeTask.AsTask().Wait();
|
|
||||||
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
_disposed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Diagnostics.Metrics;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Telegrator.Core;
|
|
||||||
|
|
||||||
#pragma warning disable IDE0001
|
|
||||||
namespace Telegrator.Hosting.Web;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a web hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more.
|
|
||||||
/// </summary>
|
|
||||||
public class TelegramBotWebHostBuilder : ITelegramBotHostBuilder
|
|
||||||
{
|
|
||||||
private readonly WebApplicationBuilder _innerBuilder;
|
|
||||||
private readonly WebApplicationOptions _settings;
|
|
||||||
internal IHandlersCollection _handlers = null!;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IHandlersCollection Handlers => _handlers;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IConfigurationManager Configuration => _innerBuilder.Configuration;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public ILoggingBuilder Logging => _innerBuilder.Logging;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IServiceCollection Services => _innerBuilder.Services;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IHostEnvironment Environment => _innerBuilder.Environment;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IDictionary<object, object> Properties => ((IHostApplicationBuilder)_innerBuilder).Properties;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IMetricsBuilder Metrics => _innerBuilder.Metrics;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="TelegramBotWebHostBuilder"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="webApplicationBuilder"></param>
|
|
||||||
/// <param name="settings"></param>
|
|
||||||
public TelegramBotWebHostBuilder(WebApplicationBuilder webApplicationBuilder, WebApplicationOptions? settings = null)
|
|
||||||
{
|
|
||||||
_innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder));
|
|
||||||
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="TelegramBotWebHostBuilder"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="webApplicationBuilder"></param>
|
|
||||||
/// <param name="options"></param>
|
|
||||||
/// <param name="settings"></param>
|
|
||||||
public TelegramBotWebHostBuilder(WebApplicationBuilder webApplicationBuilder, TelegratorOptions? options, WebApplicationOptions? settings)
|
|
||||||
{
|
|
||||||
_innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder));
|
|
||||||
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="TelegramBotWebHostBuilder"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="webApplicationBuilder"></param>
|
|
||||||
/// <param name="handlers"></param>
|
|
||||||
/// <param name="settings"></param>
|
|
||||||
public TelegramBotWebHostBuilder(WebApplicationBuilder webApplicationBuilder, IHandlersCollection handlers, WebApplicationOptions settings)
|
|
||||||
{
|
|
||||||
_innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder));
|
|
||||||
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="TelegramBotWebHostBuilder"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="webApplicationBuilder"></param>
|
|
||||||
/// <param name="handlers"></param>
|
|
||||||
/// <param name="options"></param>
|
|
||||||
/// <param name="settings"></param>
|
|
||||||
public TelegramBotWebHostBuilder(WebApplicationBuilder webApplicationBuilder, IHandlersCollection handlers, TelegratorOptions? options, WebApplicationOptions settings)
|
|
||||||
{
|
|
||||||
_innerBuilder = webApplicationBuilder ?? throw new ArgumentNullException(nameof(webApplicationBuilder));
|
|
||||||
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Builds the host.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public TelegramBotWebHost Build()
|
|
||||||
{
|
|
||||||
TelegramBotWebHost host = new TelegramBotWebHost(_innerBuilder);
|
|
||||||
host.UseTelegratorWeb();
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public void ConfigureContainer<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder> factory, Action<TContainerBuilder>? configure = null) where TContainerBuilder : notnull
|
|
||||||
{
|
|
||||||
((IHostApplicationBuilder)_innerBuilder).ConfigureContainer(factory, configure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,12 +8,11 @@ using System.Text.Json;
|
|||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Telegrator.Core;
|
using Telegrator.Core;
|
||||||
using Telegrator.Hosting.Web;
|
|
||||||
|
|
||||||
namespace Telegrator.Mediation;
|
namespace Telegrator.Mediation;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Service for receiving updates for Hosted telegram bots via Webhooks
|
/// Service for receiving updates for Hosted telegram bots via Webhooks and queuing them to router
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class HostedUpdateWebhooker : IHostedService
|
public class HostedUpdateWebhooker : IHostedService
|
||||||
{
|
{
|
||||||
@@ -26,7 +25,6 @@ public class HostedUpdateWebhooker : IHostedService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initiallizes new instance of <see cref="HostedUpdateWebhooker"/>
|
/// Initiallizes new instance of <see cref="HostedUpdateWebhooker"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="botHost"></param>
|
|
||||||
/// <param name="botClient"></param>
|
/// <param name="botClient"></param>
|
||||||
/// <param name="updateRouter"></param>
|
/// <param name="updateRouter"></param>
|
||||||
/// <param name="options"></param>
|
/// <param name="options"></param>
|
||||||
@@ -48,17 +46,6 @@ public class HostedUpdateWebhooker : IHostedService
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void StartInternal(CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
await _botClient.SetWebhook(
|
|
||||||
url: _options.WebhookUri,
|
|
||||||
maxConnections: _options.MaxConnections,
|
|
||||||
allowedUpdates: _updateRouter.HandlersProvider.AllowedTypes,
|
|
||||||
dropPendingUpdates: _options.DropPendingUpdates,
|
|
||||||
secretToken: _options.SecretToken,
|
|
||||||
cancellationToken: cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Task StopAsync(CancellationToken cancellationToken)
|
public Task StopAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@@ -66,16 +53,50 @@ public class HostedUpdateWebhooker : IHostedService
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allows to remap receiving webhook endpoint and map new route to webhost.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="routeBuilder"></param>
|
||||||
|
/// <param name="webhookUri"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentException"></exception>
|
||||||
|
public async Task RemapWebhook(IEndpointRouteBuilder routeBuilder, string webhookUri, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
if (!Uri.TryCreate(webhookUri, UriKind.Absolute, out Uri? result))
|
||||||
|
throw new ArgumentException("invalid URL");
|
||||||
|
|
||||||
|
_options.WebhookUri = result.ToString();
|
||||||
|
await SetWebhook(cancellationToken);
|
||||||
|
MapWebhook(routeBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maps bot webhook to application builder
|
/// Maps bot webhook to application builder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="routeBuilder"></param>
|
/// <param name="routeBuilder"></param>
|
||||||
public void MapWebhook(IEndpointRouteBuilder routeBuilder)
|
internal void MapWebhook(IEndpointRouteBuilder routeBuilder)
|
||||||
{
|
{
|
||||||
string pattern = new UriBuilder(_options.WebhookUri).Path;
|
string pattern = new UriBuilder(_options.WebhookUri).Path;
|
||||||
routeBuilder.MapPost(pattern, (Delegate)ReceiveUpdate);
|
routeBuilder.MapPost(pattern, (Delegate)ReceiveUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void StartInternal(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await SetWebhook(cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SetWebhook(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
await _botClient.SetWebhook(
|
||||||
|
url: _options.WebhookUri,
|
||||||
|
maxConnections: _options.MaxConnections,
|
||||||
|
allowedUpdates: _updateRouter.HandlersProvider.AllowedTypes,
|
||||||
|
dropPendingUpdates: _options.DropPendingUpdates,
|
||||||
|
secretToken: _options.SecretToken,
|
||||||
|
cancellationToken: cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<IResult> ReceiveUpdate(HttpContext ctx)
|
private async Task<IResult> ReceiveUpdate(HttpContext ctx)
|
||||||
{
|
{
|
||||||
if (_options.SecretToken != null)
|
if (_options.SecretToken != null)
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Telegrator.Hosting;
|
|
||||||
using Telegrator.Hosting.Web;
|
|
||||||
|
|
||||||
namespace Telegrator;
|
|
||||||
|
|
||||||
internal class Program
|
|
||||||
{
|
|
||||||
public static void TelegramBotWebHostBuilder_Example(string[] args)
|
|
||||||
{
|
|
||||||
TelegramBotWebHostBuilder builder = TelegramBotWebHost.CreateBuilder(new WebApplicationOptions()
|
|
||||||
{
|
|
||||||
Args = args,
|
|
||||||
ApplicationName = "TelegramBotWebHost example",
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.Handlers.CollectHandlersAssemblyWide();
|
|
||||||
|
|
||||||
builder.Build()
|
|
||||||
.AddLoggingAdapter()
|
|
||||||
.SetBotCommands()
|
|
||||||
.Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void WebApplicationBuilder_Example(string[] args)
|
|
||||||
{
|
|
||||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(new WebApplicationOptions()
|
|
||||||
{
|
|
||||||
Args = args,
|
|
||||||
ApplicationName = "WebApplication example",
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.AddTelegratorWeb();
|
|
||||||
builder.Handlers.CollectHandlersAssemblyWide();
|
|
||||||
|
|
||||||
builder.Build()
|
|
||||||
.UseTelegratorWeb()
|
|
||||||
.AddLoggingAdapter()
|
|
||||||
.SetBotCommands()
|
|
||||||
.Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void TelegramBotHostBuilder_Example(string[] args)
|
|
||||||
{
|
|
||||||
ConfigurationManager configuration = new ConfigurationManager();
|
|
||||||
configuration.AddJsonFile("appsettings.json");
|
|
||||||
|
|
||||||
TelegramBotHostBuilder builder = TelegramBotHost.CreateBuilder(new HostApplicationBuilderSettings()
|
|
||||||
{
|
|
||||||
Args = args,
|
|
||||||
ApplicationName = "TelegramBotHost example",
|
|
||||||
Configuration = configuration
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.Handlers.CollectHandlersAssemblyWide();
|
|
||||||
|
|
||||||
builder.Build()
|
|
||||||
.AddLoggingAdapter()
|
|
||||||
.SetBotCommands()
|
|
||||||
.Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HostApplicationBuilder_Example(string[] args)
|
|
||||||
{
|
|
||||||
HostApplicationBuilder builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings()
|
|
||||||
{
|
|
||||||
Args = args,
|
|
||||||
ApplicationName = "Host example",
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.AddTelegrator();
|
|
||||||
builder.Handlers.CollectHandlersAssemblyWide();
|
|
||||||
|
|
||||||
builder.Build()
|
|
||||||
.UseTelegrator()
|
|
||||||
.AddLoggingAdapter()
|
|
||||||
.SetBotCommands()
|
|
||||||
.Run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,9 +13,12 @@
|
|||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
<Title>Telegrator.Hosting.Web</Title>
|
<Title>Telegrator.Hosting.Web</Title>
|
||||||
<Version>1.16.7</Version>
|
<Version>1.17.2</Version>
|
||||||
<Authors>Rikitav Tim4ik</Authors>
|
<Authors>Rikitav Tim4ik</Authors>
|
||||||
<Company>Rikitav Tim4ik</Company>
|
<Company>Rikitav Tim4ik</Company>
|
||||||
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
|
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
|
||||||
@@ -40,4 +43,5 @@
|
|||||||
<None Include="..\..\LICENSE" Pack="True" PackagePath="\" />
|
<None Include="..\..\LICENSE" Pack="True" PackagePath="\" />
|
||||||
<None Include="..\..\resources\telegrator_nuget.png" Pack="True" PackagePath="\" />
|
<None Include="..\..\resources\telegrator_nuget.png" Pack="True" PackagePath="\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,163 +1,195 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.AspNetCore.Routing;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegrator.Core;
|
using Telegrator.Core;
|
||||||
using Telegrator.Hosting;
|
using Telegrator.Hosting;
|
||||||
using Telegrator.Hosting.Web;
|
|
||||||
using Telegrator.Mediation;
|
using Telegrator.Mediation;
|
||||||
using Telegrator.Providers;
|
using Telegrator.Providers;
|
||||||
|
|
||||||
namespace Telegrator
|
namespace Telegrator;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides extension methods for <see cref="IHostApplicationBuilder"/> to configure Telegrator.
|
||||||
|
/// </summary>
|
||||||
|
public static class WebHostBuilderExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains extensions for <see cref="IServiceCollection"/>
|
/// Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
||||||
/// Provides method to configure Telegram Bot WebHost
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ServicesCollectionExtensions
|
public static IHostApplicationBuilder AddTelegratorWeb(this IHostApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
|
||||||
{
|
{
|
||||||
/// <summary>
|
AddTelegratorWebInternal(builder.Services, builder.Configuration, builder.Properties, ref handlers, options);
|
||||||
/// The key used to store the <see cref="IHandlersCollection"/> in the builder properties.
|
return builder;
|
||||||
/// </summary>
|
}
|
||||||
public const string HandlersCollectionPropertyKey = nameof(IHandlersCollection);
|
|
||||||
|
|
||||||
extension(WebApplicationBuilder builder)
|
/// <summary>
|
||||||
|
/// Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
||||||
|
/// </summary>
|
||||||
|
public static IHostApplicationBuilder AddTelegratorWeb(this IHostApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null, Action<ITelegramBotHostBuilder>? action = null)
|
||||||
|
{
|
||||||
|
AddTelegratorWebInternal(builder.Services, builder.Configuration, builder.Properties, ref handlers, options);
|
||||||
|
action?.Invoke(new TelegramBotHostBuilder(builder, handlers));
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
||||||
|
/// </summary>
|
||||||
|
internal static void AddTelegratorWebInternal(IServiceCollection services, IConfiguration configuration, IDictionary<object, object> properties, [NotNull] ref IHandlersCollection? handlers, TelegratorOptions? options = null)
|
||||||
|
{
|
||||||
|
if (services.Any(srvc => srvc.ServiceType == typeof(HostedUpdateReceiver)))
|
||||||
|
throw new InvalidOperationException("`HostedUpdateReceiver` found in services. WebHost extension is not compatible with long-polling receiving. Please, remove `AddTelegrator` invocation from your WebApp configuration.");
|
||||||
|
|
||||||
|
if (options is null)
|
||||||
{
|
{
|
||||||
/// <summary>
|
options = configuration.GetSection(nameof(TelegratorOptions)).Get<TelegratorOptions>();
|
||||||
/// Gets the <see cref="IHandlersCollection"/> from the builder properties.
|
if (options is null)
|
||||||
/// </summary>
|
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'TelegratorOptions' was registered. This configuration is runtime required!");
|
||||||
public IHandlersCollection Handlers
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return (IHandlersCollection)builder.Host.Properties[HandlersCollectionPropertyKey];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
CancellationTokenSource globallCancell = new CancellationTokenSource();
|
||||||
/// Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
options.GlobalCancellationToken = globallCancell.Token;
|
||||||
/// </summary>
|
services.AddSingleton(Options.Create(options));
|
||||||
public static ITelegramBotHostBuilder AddTelegratorWeb(this ITelegramBotHostBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null, Action<ITelegramBotHostBuilder>? action = null)
|
services.AddKeyedSingleton("cancell", globallCancell);
|
||||||
|
|
||||||
|
if (handlers is not null && handlers is IHandlersManager manager)
|
||||||
{
|
{
|
||||||
builder.AddTelegratorWebInternal(options, handlers);
|
ServiceDescriptor descriptor = new ServiceDescriptor(typeof(IHandlersProvider), manager);
|
||||||
action?.Invoke(builder);
|
services.Replace(descriptor);
|
||||||
return builder;
|
services.AddSingleton(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
handlers ??= new HostHandlersCollection(services, options);
|
||||||
/// Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
services.AddSingleton(handlers);
|
||||||
/// </summary>
|
properties.Add(HostBuilderExtensions.HandlersCollectionPropertyKey, handlers);
|
||||||
public static IHostApplicationBuilder AddTelegratorWeb(this WebApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null, Action<ITelegramBotHostBuilder>? action = null)
|
|
||||||
|
if (!services.Any(srvc => srvc.ServiceType == typeof(IOptions<WebhookerOptions>)))
|
||||||
{
|
{
|
||||||
builder.AddTelegratorWebInternal(options, handlers);
|
WebhookerOptions? webhookerOptions = configuration.GetSection(nameof(WebhookerOptions)).Get<WebhookerOptions>();
|
||||||
action?.Invoke(new TelegramBotWebHostBuilder(builder));
|
if (webhookerOptions == null)
|
||||||
return builder;
|
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'WebhookerOptions' was registered. This configuration is runtime required!");
|
||||||
|
|
||||||
|
services.AddSingleton(Options.Create(webhookerOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
if (!services.Any(srvc => srvc.ImplementationType == typeof(IOptions<TelegramBotClientOptions>)))
|
||||||
/// Replaces TelegramBotWebHostBuilder. Configures DI, options, and handlers.
|
|
||||||
/// </summary>
|
|
||||||
internal static IHostApplicationBuilder AddTelegratorWebInternal(this IHostApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
|
|
||||||
{
|
{
|
||||||
IServiceCollection services = builder.Services;
|
services.AddSingleton(Options.Create(new TelegramBotClientOptions(options.Token, options.BaseUrl, options.UseTestEnvironment)
|
||||||
IConfigurationManager configuration = builder.Configuration;
|
|
||||||
|
|
||||||
if (options == null)
|
|
||||||
{
|
{
|
||||||
options = configuration.GetSection(nameof(TelegratorOptions)).Get<TelegratorOptions>();
|
RetryCount = options.RetryCount,
|
||||||
if (options == null)
|
RetryThreshold = options.RetryThreshold
|
||||||
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'TelegratorOptions' wasn't registered. This configuration is runtime required!");
|
}));
|
||||||
}
|
|
||||||
|
|
||||||
CancellationTokenSource globallCancell = new CancellationTokenSource();
|
|
||||||
options.GlobalCancellationToken = globallCancell.Token;
|
|
||||||
services.AddSingleton(Options.Create(options));
|
|
||||||
services.AddKeyedSingleton("cancell", globallCancell);
|
|
||||||
|
|
||||||
if (handlers != null)
|
|
||||||
{
|
|
||||||
if (handlers is IHandlersManager manager)
|
|
||||||
{
|
|
||||||
ServiceDescriptor descriptor = new ServiceDescriptor(typeof(IHandlersProvider), manager);
|
|
||||||
services.Replace(descriptor);
|
|
||||||
services.AddSingleton(manager);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handlers ??= new HostHandlersCollection(services, options);
|
|
||||||
services.AddSingleton(handlers);
|
|
||||||
|
|
||||||
builder.Properties.Add(HandlersCollectionPropertyKey, handlers);
|
|
||||||
if (builder is TelegramBotWebHostBuilder botHostBuilder)
|
|
||||||
botHostBuilder._handlers = handlers;
|
|
||||||
|
|
||||||
if (!services.Any(srvc => srvc.ImplementationType == typeof(IOptions<WebhookerOptions>)))
|
|
||||||
{
|
|
||||||
WebhookerOptions? webhookerOptions = configuration.GetSection(nameof(WebhookerOptions)).Get<WebhookerOptions>();
|
|
||||||
if (webhookerOptions == null)
|
|
||||||
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'WebhookerOptions' wasn't registered. This configuration is runtime required!");
|
|
||||||
|
|
||||||
services.AddSingleton(Options.Create(webhookerOptions));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!services.Any(srvc => srvc.ImplementationType == typeof(IOptions<TelegramBotClientOptions>)))
|
|
||||||
{
|
|
||||||
services.AddSingleton(Options.Create(new TelegramBotClientOptions(options.Token, options.BaseUrl, options.UseTestEnvironment)
|
|
||||||
{
|
|
||||||
RetryCount = options.RetryCount,
|
|
||||||
RetryThreshold = options.RetryThreshold
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
services.AddTelegramBotHostDefaults();
|
|
||||||
services.AddTelegramWebhook();
|
|
||||||
return builder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
services.AddTelegramBotHostDefaults();
|
||||||
/// Replaces the initialization logic from TelegramBotWebHost constructor.
|
services.AddTelegramWebhook();
|
||||||
/// Initializes the bot and logs handlers on application startup.
|
|
||||||
/// </summary>
|
|
||||||
public static T UseTelegratorWeb<T>(this T app) where T : IEndpointRouteBuilder, IHost
|
|
||||||
{
|
|
||||||
if (app.ServiceProvider.GetServices<IHostedService>().FirstOrDefault(s => s is HostedUpdateWebhooker) is not HostedUpdateWebhooker webhooker)
|
|
||||||
throw new InvalidOperationException("No service for type 'Telegrator.Mediation.HostedUpdateWebhooker' has been registered.");
|
|
||||||
|
|
||||||
ITelegramBotInfo info = app.ServiceProvider.GetRequiredService<ITelegramBotInfo>();
|
|
||||||
IHandlersCollection handlers = app.ServiceProvider.GetRequiredService<IHandlersCollection>();
|
|
||||||
ILoggerFactory loggerFactory = app.ServiceProvider.GetRequiredService<ILoggerFactory>();
|
|
||||||
ILogger logger = loggerFactory.CreateLogger("Telegrator.Hosting.Web.TelegratorHost");
|
|
||||||
|
|
||||||
if (logger.IsEnabled(LogLevel.Information))
|
|
||||||
{
|
|
||||||
logger.LogInformation("Telegrator Bot ASP.NET WebHost started");
|
|
||||||
logger.LogInformation("Telegram Bot : {firstname}, @{usrname}, id:{id},", info.User.FirstName ?? "[NULL]", info.User.Username ?? "[NULL]", info.User.Id);
|
|
||||||
logger.LogHandlers(handlers);
|
|
||||||
}
|
|
||||||
|
|
||||||
webhooker.MapWebhook(app);
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Registers <see cref="ITelegramBotClient"/> service with <see cref="HostedUpdateWebhooker"/> to receive updates using webhook
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="services"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static IServiceCollection AddTelegramWebhook(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddHttpClient<ITelegramBotClient>("tgwebhook").RemoveAllLoggers().AddTypedClient(TypedTelegramBotClientFactory);
|
|
||||||
services.AddHostedService<HostedUpdateWebhooker>();
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ITelegramBotClient TypedTelegramBotClientFactory(HttpClient httpClient, IServiceProvider provider)
|
|
||||||
=> new TelegramBotClient(provider.GetRequiredService<IOptions<TelegramBotClientOptions>>().Value, httpClient);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains extensions for <see cref="IServiceCollection"/>
|
||||||
|
/// Provides method to configure Telegram Bot WebHost
|
||||||
|
/// </summary>
|
||||||
|
public static class WebServicesCollectionExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Adds WebhookerOptions to services
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IServiceCollection ConfigureWebhooker(this IServiceCollection services, WebhookerOptions options)
|
||||||
|
{
|
||||||
|
services.RemoveAll<IOptions<WebhookerOptions>>();
|
||||||
|
services.AddSingleton(Options.Create(options));
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Searchs for <see cref="HostedUpdateWebhooker"/> hosted service inside hosts services
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="webhooker"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool TryFindWebhooker(this IServiceProvider services, [NotNullWhen(true)] out HostedUpdateWebhooker? webhooker)
|
||||||
|
{
|
||||||
|
webhooker = services.GetServices<IHostedService>().FirstOrDefault(s => s is HostedUpdateWebhooker) as HostedUpdateWebhooker;
|
||||||
|
return webhooker != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides useful methods to adjust Telegram bot Host
|
||||||
|
/// </summary>
|
||||||
|
public static class WebTelegramBotHostExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces the initialization logic from TelegramBotWebHost constructor.
|
||||||
|
/// Initializes the bot and logs handlers on application startup.
|
||||||
|
/// </summary>
|
||||||
|
public static T UseTelegratorWeb<T>(this T botHost, bool dontMap = false) where T : IEndpointRouteBuilder, IHost
|
||||||
|
{
|
||||||
|
if (!botHost.ServiceProvider.TryFindWebhooker(out HostedUpdateWebhooker? webhooker))
|
||||||
|
throw new InvalidOperationException("No service for type 'Telegrator.Mediation.HostedUpdateWebhooker' has been registered.");
|
||||||
|
|
||||||
|
ITelegramBotInfo info = botHost.ServiceProvider.GetRequiredService<ITelegramBotInfo>();
|
||||||
|
IHandlersCollection handlers = botHost.ServiceProvider.GetRequiredService<IHandlersCollection>();
|
||||||
|
ILoggerFactory loggerFactory = botHost.ServiceProvider.GetRequiredService<ILoggerFactory>();
|
||||||
|
ILogger logger = loggerFactory.CreateLogger("Telegrator.Hosting.Web.TelegratorHost");
|
||||||
|
|
||||||
|
if (logger.IsEnabled(LogLevel.Information))
|
||||||
|
{
|
||||||
|
logger.LogInformation("Telegrator Bot Host started (ASP.NET WebHost)");
|
||||||
|
logger.LogInformation("Receiving mode : WEB-HOOKING");
|
||||||
|
logger.LogInformation("Telegram Bot : {firstname}, @{usrname}, id:{id},", info.User.FirstName ?? "[NULL]", info.User.Username ?? "[NULL]", info.User.Id);
|
||||||
|
logger.LogHandlers(handlers);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dontMap)
|
||||||
|
webhooker.MapWebhook(botHost);
|
||||||
|
|
||||||
|
botHost.AddLoggingAdapter();
|
||||||
|
botHost.SetBotCommands();
|
||||||
|
return botHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allows to remap receiving webhook endpoint and map new route to webhost.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="app"></param>
|
||||||
|
/// <param name="webhookUri"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentException"></exception>
|
||||||
|
public static T RemapWebhook<T>(this T app, string webhookUri) where T : IEndpointRouteBuilder, IHost
|
||||||
|
{
|
||||||
|
if (!app.ServiceProvider.TryFindWebhooker(out HostedUpdateWebhooker? webhooker))
|
||||||
|
throw new InvalidOperationException("No service for type 'Telegrator.Mediation.HostedUpdateWebhooker' has been registered.");
|
||||||
|
|
||||||
|
webhooker.RemapWebhook(app, webhookUri, default).GetAwaiter().GetResult();
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers <see cref="ITelegramBotClient"/> service with <see cref="HostedUpdateWebhooker"/> to receive updates using webhook
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IServiceCollection AddTelegramWebhook(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.RemoveAll<IOptions<HostedUpdateWebhooker>>();
|
||||||
|
services.RemoveAll<ITelegramBotClient>();
|
||||||
|
|
||||||
|
services.AddHttpClient<ITelegramBotClient>("tgwebhook").RemoveAllLoggers().AddTypedClient(TypedTelegramBotClientFactory);
|
||||||
|
services.AddHostedService<HostedUpdateWebhooker>();
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ITelegramBotClient TypedTelegramBotClientFactory(HttpClient httpClient, IServiceProvider provider)
|
||||||
|
=> new TelegramBotClient(provider.GetRequiredService<IOptions<TelegramBotClientOptions>>().Value, httpClient);
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Telegrator.Hosting.Web;
|
namespace Telegrator;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configuration options for Telegram bot behavior and execution settings.
|
/// Configuration options for Telegram bot behavior and execution settings.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// This file is used by Code Analysis to maintain SuppressMessage
|
||||||
|
// attributes that are applied to this project.
|
||||||
|
// Project-level suppressions either have no target or are given
|
||||||
|
// a specific target and scoped to a namespace, type, member, etc.
|
||||||
|
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
|
[assembly: SuppressMessage("Roslynator", "RCS1037")]
|
||||||
|
[assembly: SuppressMessage("Style", "IDE0090")]
|
||||||
|
[assembly: SuppressMessage("Style", "IDE0270")]
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Telegram.Bot;
|
||||||
|
using Telegram.Bot.Polling;
|
||||||
|
using Telegrator.Core;
|
||||||
|
|
||||||
|
namespace Telegrator.Mediation;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Service for receiving updates for Hosted wide telegram bots and queuing them to router
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger"></param>
|
||||||
|
/// <param name="botClient"></param>
|
||||||
|
/// <param name="updateRouter"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
|
public class HostedWideBotUpdateReceiver(ILogger<HostedWideBotUpdateReceiver> logger, ITelegramBotClient botClient, IUpdateRouter updateRouter, IOptions<WideBotOptions>? options) : BackgroundService
|
||||||
|
{
|
||||||
|
/// <inheritdoc/>
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
if (botClient is not WTelegramBotClient wideBotClient)
|
||||||
|
throw new Exception("Registered ITelegramBotClient was not a wide client (WTelegramBotClient)! Please, use `AddWideTelegrator` instead.");
|
||||||
|
|
||||||
|
if (options?.Value.DropPendingUpdates is true)
|
||||||
|
await wideBotClient.DropPendingUpdates();
|
||||||
|
|
||||||
|
logger.LogInformation("Starting receiving updates via MTProto");
|
||||||
|
|
||||||
|
// UIP (understanding in progress)
|
||||||
|
//_receiverOptions.AllowedUpdates = updateRouter.HandlersProvider.AllowedTypes.ToArray();
|
||||||
|
|
||||||
|
botClient.DeleteWebhook(options?.Value.DropPendingUpdates ?? false, cancellationToken: stoppingToken)
|
||||||
|
.ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
|
|
||||||
|
WideUpdateReceiver updateReceiver = new WideUpdateReceiver(wideBotClient);
|
||||||
|
await updateReceiver.ReceiveAsync(updateRouter, stoppingToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Telegram.Bot;
|
||||||
|
using Telegram.Bot.Polling;
|
||||||
|
using Telegrator.Core;
|
||||||
|
using WUpdate = WTelegram.Types.Update;
|
||||||
|
|
||||||
|
namespace Telegrator.Mediation;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reactive implementation of <see cref="IUpdateReceiver"/> for polling updates from Telegram.
|
||||||
|
/// Provides custom update receiving logic with error handling and configuration options.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client">The Telegram bot client for making API requests.</param>
|
||||||
|
// <param name="options">Optional receiver options for configuring update polling behavior.</param>
|
||||||
|
public class WideUpdateReceiver(WTelegramBotClient client) : IUpdateReceiver
|
||||||
|
{
|
||||||
|
private readonly WTelegramBotClient _client = client;
|
||||||
|
private IUpdateHandler? _updateHandler = null;
|
||||||
|
private CancellationToken _cancellation = default;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task ReceiveAsync(IUpdateHandler updateHandler, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
_updateHandler = updateHandler;
|
||||||
|
_cancellation = cancellationToken;
|
||||||
|
|
||||||
|
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
await using CancellationTokenRegistration registration = cancellationToken.Register(() => tcs.TrySetResult(null!));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_client.OnUpdate += OnUpdate;
|
||||||
|
await tcs.Task.ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_client.OnUpdate -= OnUpdate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnUpdate(WUpdate update)
|
||||||
|
{
|
||||||
|
if (_updateHandler == null)
|
||||||
|
throw new Exception("Router not initialized (got null)");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _updateHandler.HandleUpdateAsync(_client, update, _cancellation).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _updateHandler.HandleErrorAsync(_client, ex, HandleErrorSource.HandleUpdateError, _cancellation).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<RootNamespace>Telegrator</RootNamespace>
|
||||||
|
<BaseOutputPath>..\..\bin</BaseOutputPath>
|
||||||
|
<DocumentationFile>..\..\docs\$(AssemblyName).xml</DocumentationFile>
|
||||||
|
|
||||||
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
|
<Title>Telegrator.Hosting.WideBot</Title>
|
||||||
|
<Version>1.17.2</Version>
|
||||||
|
<Authors>Rikitav Tim4ik</Authors>
|
||||||
|
<Company>Rikitav Tim4ik</Company>
|
||||||
|
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
|
||||||
|
<PackageTags>telegram;bot;mediator;attributes;aspect;hosting;host;framework;easy;simple;handlers;wtelegrambot;userbot</PackageTags>
|
||||||
|
|
||||||
|
<PackageIcon>telegrator_nuget.png</PackageIcon>
|
||||||
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="WTelegramBot" Version="9.6.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\Telegrator.Hosting\Telegrator.Hosting.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include=".\README.md" Pack="True" PackagePath="\" />
|
||||||
|
<None Include="..\..\LICENSE" Pack="True" PackagePath="\" />
|
||||||
|
<None Include="..\..\resources\telegrator_nuget.png" Pack="True" PackagePath="\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
|
using System;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading;
|
||||||
|
using Telegram.Bot;
|
||||||
|
using Telegram.Bot.Polling;
|
||||||
|
using Telegrator.Core;
|
||||||
|
using Telegrator.Logging;
|
||||||
|
using Telegrator.Mediation;
|
||||||
|
using Telegrator.Providers;
|
||||||
|
using Telegrator.States;
|
||||||
|
|
||||||
|
namespace Telegrator;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Client class for the Telegrator library with Wider functionality, provided by WTelegramBotClient.
|
||||||
|
/// Extends TelegramBotClient with reactive capabilities for handling updates.
|
||||||
|
/// </summary>
|
||||||
|
public class TelegratorWClient : WTelegramBotClient, ITelegratorBot, ICollectingProvider
|
||||||
|
{
|
||||||
|
private IUpdateRouter? _updateRouter = null;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public TelegratorOptions Options { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public IHandlersCollection Handlers { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public ITelegramBotInfo BotInfo { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public IUpdateRouter UpdateRouter => _updateRouter ?? throw new InvalidOperationException("Router's not created yet. Invoke `StartReceiving` to initialize this property.");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes new instance of <see cref="TelegratorWClient"/>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="wOptions"></param>
|
||||||
|
/// <param name="telegratorOptions"></param>
|
||||||
|
/// <param name="httpClient"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
public TelegratorWClient(WTelegramBotClientOptions wOptions, TelegratorOptions? telegratorOptions = null, HttpClient? httpClient = null, CancellationToken cancellationToken = default)
|
||||||
|
: base(wOptions, httpClient, cancellationToken)
|
||||||
|
{
|
||||||
|
Options = telegratorOptions ?? new TelegratorOptions();
|
||||||
|
Handlers = new HandlersCollection(default);
|
||||||
|
BotInfo = new TelegramBotInfo(GetMe(cancellationToken).Result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public void StartReceiving(ReceiverOptions? _, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
if (Options.GlobalCancellationToken == CancellationToken.None)
|
||||||
|
Options.GlobalCancellationToken = cancellationToken;
|
||||||
|
|
||||||
|
HandlersProvider handlerProvider = new HandlersProvider(Handlers, Options);
|
||||||
|
AwaitingProvider awaitingProvider = new AwaitingProvider(Options);
|
||||||
|
DefaultStateStorage stateStorage = new DefaultStateStorage();
|
||||||
|
|
||||||
|
_updateRouter = new UpdateRouter(handlerProvider, awaitingProvider, stateStorage, Options, BotInfo);
|
||||||
|
TelegratorLogging.LogInformation($"TelegratorW bot starting up - BotId: {BotInfo.User.Id}, Username: {BotInfo.User.Username}");
|
||||||
|
|
||||||
|
StartReceivingInternal(Options.GlobalCancellationToken)
|
||||||
|
.ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task StartReceivingAsync(ReceiverOptions? receiverOptions = null,CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
if (Options.GlobalCancellationToken == CancellationToken.None)
|
||||||
|
Options.GlobalCancellationToken = cancellationToken;
|
||||||
|
|
||||||
|
HandlersProvider handlerProvider = new HandlersProvider(Handlers, Options);
|
||||||
|
AwaitingProvider awaitingProvider = new AwaitingProvider(Options);
|
||||||
|
DefaultStateStorage stateStorage = new DefaultStateStorage();
|
||||||
|
|
||||||
|
_updateRouter = new UpdateRouter(handlerProvider, awaitingProvider, stateStorage, Options, BotInfo);
|
||||||
|
TelegratorLogging.LogInformation($"TelegratorW bot starting up - BotId: {BotInfo.User.Id}, Username: {BotInfo.User.Username}");
|
||||||
|
|
||||||
|
await StartReceivingInternal(Options.GlobalCancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task StartReceivingInternal(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await new HostedWideBotUpdateReceiver(NullLoggerFactory.Instance.CreateLogger<HostedWideBotUpdateReceiver>(), this, UpdateRouter, null)
|
||||||
|
.StartAsync(cancellationToken)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
await UpdateRouter
|
||||||
|
.HandleErrorAsync(this, exception, HandleErrorSource.FatalError, cancellationToken)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (OperationCanceledException)
|
||||||
|
{
|
||||||
|
// Cancelled
|
||||||
|
TelegratorLogging.LogInformation("Telegrator bot stopped (cancelled)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,298 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using Telegram.Bot;
|
||||||
|
using Telegram.Bot.Types;
|
||||||
|
using Telegrator.Core;
|
||||||
|
using Telegrator.Core.Handlers;
|
||||||
|
using Telegrator.Hosting;
|
||||||
|
using Telegrator.Mediation;
|
||||||
|
using Telegrator.Providers;
|
||||||
|
|
||||||
|
using WUpdate = WTelegram.Types.Update;
|
||||||
|
using TLUpdate = TL.Update;
|
||||||
|
using System.Data.Common;
|
||||||
|
|
||||||
|
namespace Telegrator;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides extensions memebrs for <see cref="UpdateHandlerBase"/> for easy access to Wider bot functions and update
|
||||||
|
/// </summary>
|
||||||
|
public static class HandlersExtensions
|
||||||
|
{
|
||||||
|
extension<TUpdate>(AbstractUpdateHandler<TUpdate> handler) where TUpdate : class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Casts Update to <see cref="WTelegramBotClient"/>
|
||||||
|
/// </summary>
|
||||||
|
public WTelegramBotClient WClient
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
object? client = handler.GetType().GetField("Client")?.GetValue(handler);
|
||||||
|
if (client is not WTelegramBotClient wideClient)
|
||||||
|
throw new InvalidCastException("Client is not assignable to `WTelegram.Bot.WTelegramBotClient`");
|
||||||
|
|
||||||
|
return wideClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Casts Update to <see cref="WUpdate"/>
|
||||||
|
/// </summary>
|
||||||
|
public WUpdate WideUpdate
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
object? update = handler.GetType().GetField("HandlingUpdate")?.GetValue(handler);
|
||||||
|
if (update is not WUpdate wUpdate)
|
||||||
|
throw new InvalidCastException("Update is not assignable to `WTelegram.Types.Update`");
|
||||||
|
|
||||||
|
return wUpdate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Casts Update to <see cref="TLUpdate"/>
|
||||||
|
/// </summary>
|
||||||
|
public TLUpdate? TLUpdate
|
||||||
|
{
|
||||||
|
get => handler.WideUpdate.TLUpdate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Casts Update to <see cref="WTelegramBotClient"/>
|
||||||
|
/// </summary>
|
||||||
|
public static WTelegramBotClient AsWClient(this ITelegramBotClient client)
|
||||||
|
{
|
||||||
|
return client as WTelegramBotClient
|
||||||
|
?? throw new InvalidCastException("Client is not assignable to `WTelegram.Bot.WTelegramBotClient`");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Casts Update to <see cref="WUpdate"/>
|
||||||
|
/// </summary>
|
||||||
|
public static WUpdate AsWUpdate(this Update update)
|
||||||
|
{
|
||||||
|
return update as WUpdate
|
||||||
|
?? throw new InvalidCastException("Update is not assignable to `WTelegram.Types.Update`");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides extension methods for <see cref="IHostApplicationBuilder"/> to configure Telegrator.
|
||||||
|
/// </summary>
|
||||||
|
public static class WideHostBuilderExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
|
/// </summary>
|
||||||
|
public static IHostApplicationBuilder AddWideTelegrator(this IHostApplicationBuilder builder, Func<IServiceProvider, DbConnection> dbConnectionFactory, Action<ITelegramBotHostBuilder>? action = null, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
|
||||||
|
{
|
||||||
|
AddWideTelegratorInternal(builder.Services, builder.Configuration, builder.Properties, dbConnectionFactory, ref handlers, options);
|
||||||
|
action?.Invoke(new TelegramBotHostBuilder(builder, handlers));
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
|
/// </summary>
|
||||||
|
public static IHostApplicationBuilder AddWideTelegrator(this IHostApplicationBuilder builder, Func<IServiceProvider, DbConnection> dbConnectionFactory, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
|
||||||
|
{
|
||||||
|
AddWideTelegratorInternal(builder.Services, builder.Configuration, builder.Properties, dbConnectionFactory, ref handlers, options);
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
|
/// </summary>
|
||||||
|
internal static void AddWideTelegratorInternal(IServiceCollection services, IConfiguration configuration, IDictionary<object, object> properties, Func<IServiceProvider, DbConnection> dbConnectionFactory, [NotNull] ref IHandlersCollection? handlers, TelegratorOptions? options = null)
|
||||||
|
{
|
||||||
|
if (services.Any(srvc => srvc.ServiceType == typeof(HostedUpdateReceiver)))
|
||||||
|
throw new InvalidOperationException("`HostedUpdateReceiver` found in services. WideHost extension is not compatible with default long-polling receiver. Please, remove `AddTelegrator` invocation from your Host configuration.");
|
||||||
|
|
||||||
|
if (services.Any(srvc => srvc.ServiceType.Name == "HostedUpdateWebhooker"))
|
||||||
|
throw new InvalidOperationException("`HostedUpdateWebhooker` found in services. WideHost extension is not compatible with webhooking yet. Please, remove `AddWebTelegrator` invocation from your Host configuration.");
|
||||||
|
|
||||||
|
if (options == null)
|
||||||
|
{
|
||||||
|
options = configuration.GetSection(nameof(TelegratorOptions)).Get<TelegratorOptions>();
|
||||||
|
if (options == null)
|
||||||
|
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'TelegratorOptions' was registered. This configuration is runtime required!");
|
||||||
|
}
|
||||||
|
|
||||||
|
CancellationTokenSource globallCancell = new CancellationTokenSource();
|
||||||
|
options.GlobalCancellationToken = globallCancell.Token;
|
||||||
|
services.AddSingleton(Options.Create(options));
|
||||||
|
services.AddKeyedSingleton("cancell", globallCancell);
|
||||||
|
|
||||||
|
if (handlers != null)
|
||||||
|
{
|
||||||
|
if (handlers is IHandlersManager manager)
|
||||||
|
{
|
||||||
|
ServiceDescriptor descriptor = new ServiceDescriptor(typeof(IHandlersProvider), manager);
|
||||||
|
services.Replace(descriptor);
|
||||||
|
services.AddSingleton(manager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handlers ??= new HostHandlersCollection(services, options);
|
||||||
|
services.AddSingleton(handlers);
|
||||||
|
properties.Add(HostBuilderExtensions.HandlersCollectionPropertyKey, handlers);
|
||||||
|
|
||||||
|
if (!services.Any(srvc => srvc.ServiceType == typeof(IOptions<WTelegramBotClientOptions>)))
|
||||||
|
{
|
||||||
|
WideBotOptions? wideBotOptions = configuration.GetSection(nameof(WideBotOptions)).Get<WideBotOptions>();
|
||||||
|
if (wideBotOptions == null)
|
||||||
|
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'WideBotOptions' was registered. This configuration is runtime required!");
|
||||||
|
|
||||||
|
services.AddSingleton(provider =>
|
||||||
|
{
|
||||||
|
IHostApplicationLifetime lifetime = provider.GetRequiredService<IHostApplicationLifetime>();
|
||||||
|
|
||||||
|
DbConnection dbConnection = dbConnectionFactory.Invoke(provider);
|
||||||
|
lifetime.ApplicationStopping.Register(() => dbConnection.Dispose());
|
||||||
|
|
||||||
|
WTelegramBotClientOptions wideOptions = new WTelegramBotClientOptions(
|
||||||
|
token: options.Token,
|
||||||
|
apiId: wideBotOptions.ApiId,
|
||||||
|
apiHash: wideBotOptions.ApiHash,
|
||||||
|
dbConnection: dbConnection,
|
||||||
|
sqlCommands: wideBotOptions.SqlCommands,
|
||||||
|
useTestEnvironment: options.UseTestEnvironment,
|
||||||
|
mtproxy: wideBotOptions.MTProxy)
|
||||||
|
{
|
||||||
|
RetryCount = options.RetryCount,
|
||||||
|
RetryThreshold = options.RetryThreshold
|
||||||
|
};
|
||||||
|
|
||||||
|
return Options.Create(wideOptions);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
services.AddTelegramBotHostDefaults();
|
||||||
|
services.AddMTProtoUpdateReceiver();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains extensions for <see cref="IServiceCollection"/>
|
||||||
|
/// Provides method to configure Telegram Bot WebHost
|
||||||
|
/// </summary>
|
||||||
|
public static class WideBotServiceCollectionExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Adds WTelegramBotClientOptions to services
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IServiceCollection ConfigureWideTelegram(this IServiceCollection services, WTelegramBotClientOptions options)
|
||||||
|
{
|
||||||
|
services.RemoveAll<IOptions<WTelegramBotClientOptions>>();
|
||||||
|
services.AddSingleton(Options.Create(options));
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds WTelegramBotClientOptions to services
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IServiceCollection ConfigureWideBot(this IServiceCollection services, WideBotOptions options)
|
||||||
|
{
|
||||||
|
services.RemoveAll<IOptions<WideBotOptions>>();
|
||||||
|
services.AddSingleton(Options.Create(options));
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds WTelegramBotClient
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="useHttp"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IServiceCollection AddMTProtoUpdateReceiver(this IServiceCollection services, bool useHttp = false)
|
||||||
|
{
|
||||||
|
services.RemoveAll<ITelegramBotClient>();
|
||||||
|
services.RemoveAll<HostedWideBotUpdateReceiver>();
|
||||||
|
|
||||||
|
if (useHttp)
|
||||||
|
{
|
||||||
|
services.AddHttpClient<WTelegramBotClient>("tgmtproto").RemoveAllLoggers().AddTypedClient(TypedTelegramBotClientFactory);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
services.AddSingleton(TypedTelegramBotClientFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
services.AddSingleton<ITelegramBotClient>(sp => sp.GetRequiredService<WTelegramBotClient>());
|
||||||
|
services.AddHostedService<HostedWideBotUpdateReceiver>();
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable CA2254
|
||||||
|
private static WTelegramBotClient TypedTelegramBotClientFactory(HttpClient httpClient, IServiceProvider provider)
|
||||||
|
{
|
||||||
|
ILogger<WTelegramBotClient> logger = provider.GetRequiredService<ILogger<WTelegramBotClient>>();
|
||||||
|
WTelegramBotClient client = new WTelegramBotClient(provider.GetRequiredService<IOptions<WTelegramBotClientOptions>>().Value, httpClient);
|
||||||
|
|
||||||
|
WTelegram.Helpers.Log = (lvl, str) => logger.Log((LogLevel)lvl, str);
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WTelegramBotClient TypedTelegramBotClientFactory(IServiceProvider provider)
|
||||||
|
{
|
||||||
|
ILogger<WTelegramBotClient> logger = provider.GetRequiredService<ILogger<WTelegramBotClient>>();
|
||||||
|
WTelegramBotClient client = new WTelegramBotClient(provider.GetRequiredService<IOptions<WTelegramBotClientOptions>>().Value);
|
||||||
|
|
||||||
|
WTelegram.Helpers.Log = (lvl, str) => logger.Log((LogLevel)lvl, str);
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
#pragma warning restore CA2254
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides useful methods to adjust Telegram bot Host
|
||||||
|
/// </summary>
|
||||||
|
public static class WideTelegramBotHostExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces the initialization logic from TelegramBotWebHost constructor.
|
||||||
|
/// Initializes the bot and logs handlers on application startup.
|
||||||
|
/// </summary>
|
||||||
|
public static IHost UseWideTelegrator(this IHost botHost)
|
||||||
|
{
|
||||||
|
if (!botHost.Services.TryFindWTelegramBotClient())
|
||||||
|
throw new InvalidOperationException("No service for type 'Telegram.Bot.WTelegramBotClient' has been registered. Invoke `AddWideTelegrator`");
|
||||||
|
|
||||||
|
ITelegramBotInfo info = botHost.Services.GetRequiredService<ITelegramBotInfo>();
|
||||||
|
IHandlersCollection handlers = botHost.Services.GetRequiredService<IHandlersCollection>();
|
||||||
|
ILoggerFactory loggerFactory = botHost.Services.GetRequiredService<ILoggerFactory>();
|
||||||
|
ILogger logger = loggerFactory.CreateLogger("Telegrator.Hosting.Web.TelegratorHost");
|
||||||
|
|
||||||
|
if (logger.IsEnabled(LogLevel.Information))
|
||||||
|
{
|
||||||
|
logger.LogInformation("Telegrator WIDE Bot Host started (Generic Host)");
|
||||||
|
logger.LogInformation("Receiving mode : MTProto");
|
||||||
|
logger.LogInformation("Telegram Bot : {firstname}, @{usrname}, id:{id},", info.User.FirstName ?? "[NULL]", info.User.Username ?? "[NULL]", info.User.Id);
|
||||||
|
logger.LogHandlers(handlers);
|
||||||
|
}
|
||||||
|
|
||||||
|
botHost.AddLoggingAdapter();
|
||||||
|
botHost.SetBotCommands();
|
||||||
|
return botHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryFindWTelegramBotClient(this IServiceProvider services)
|
||||||
|
{
|
||||||
|
return services.GetServices<IHostedService>().Any(s => s is HostedWideBotUpdateReceiver);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using Telegram.Bot;
|
||||||
|
using WTelegram;
|
||||||
|
|
||||||
|
namespace Telegrator;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents configuration options for initializing and customizing the behavior of a WideBot instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Use this class to specify required API credentials, optional proxy settings, update handling
|
||||||
|
/// preferences, and SQL command detection for WideBot. All required properties must be set before using the options
|
||||||
|
/// with a WideBot instance.
|
||||||
|
/// </remarks>
|
||||||
|
public class WideBotOptions
|
||||||
|
{
|
||||||
|
/// <inheritdoc cref="WTelegramBotClientOptions.ApiId"/>
|
||||||
|
public required int ApiId { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="WTelegramBotClientOptions.ApiHash"/>
|
||||||
|
public required string ApiHash { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="WTelegramBotClientOptions.MTProxy"/>
|
||||||
|
public string? MTProxy { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="WTelegramBotClientOptions.SqlCommands"/>
|
||||||
|
public SqlCommands SqlCommands { get; set; } = WTelegram.SqlCommands.Detect;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether pending updates should be discarded.
|
||||||
|
/// </summary>
|
||||||
|
public bool DropPendingUpdates { get; set; }
|
||||||
|
}
|
||||||
@@ -10,3 +10,4 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
[assembly: SuppressMessage("Usage", "CA2254")]
|
[assembly: SuppressMessage("Usage", "CA2254")]
|
||||||
[assembly: SuppressMessage("Maintainability", "CA1510")]
|
[assembly: SuppressMessage("Maintainability", "CA1510")]
|
||||||
[assembly: SuppressMessage("Style", "IDE0270")]
|
[assembly: SuppressMessage("Style", "IDE0270")]
|
||||||
|
[assembly: SuppressMessage("Roslynator", "RCS1037")]
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Telegrator.Core;
|
using Telegrator.Core;
|
||||||
|
|
||||||
namespace Telegrator.Hosting;
|
namespace Telegrator.Hosting;
|
||||||
|
|
||||||
public interface ITelegramBotHostBuilder : IHostApplicationBuilder, ICollectingProvider
|
/// <summary>
|
||||||
{
|
/// Represents a hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more.
|
||||||
|
/// </summary>
|
||||||
}
|
public interface ITelegramBotHostBuilder : IHostApplicationBuilder, ICollectingProvider;
|
||||||
|
|||||||
@@ -1,114 +0,0 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Telegrator.Core;
|
|
||||||
|
|
||||||
namespace Telegrator.Hosting;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a hosted telegram bot
|
|
||||||
/// </summary>
|
|
||||||
public class TelegramBotHost : IHost, ITelegratorBot
|
|
||||||
{
|
|
||||||
private readonly IHost _innerHost;
|
|
||||||
private readonly IUpdateRouter _updateRouter;
|
|
||||||
private readonly ILogger<TelegramBotHost> _logger;
|
|
||||||
|
|
||||||
private bool _disposed;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IServiceProvider Services => _innerHost.Services;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IUpdateRouter UpdateRouter => _updateRouter;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This application's logger
|
|
||||||
/// </summary>
|
|
||||||
public ILogger<TelegramBotHost> Logger => _logger;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="TelegramBotHost"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hostApplicationBuilder">The proxied instance of host builder.</param>
|
|
||||||
public TelegramBotHost(HostApplicationBuilder hostApplicationBuilder)
|
|
||||||
{
|
|
||||||
// Registering this host in services for easy access
|
|
||||||
hostApplicationBuilder.Services.AddSingleton<ITelegratorBot>(this);
|
|
||||||
|
|
||||||
// Building proxy hoster
|
|
||||||
_innerHost = hostApplicationBuilder.Build();
|
|
||||||
|
|
||||||
// Reruesting services for this host
|
|
||||||
_updateRouter = Services.GetRequiredService<IUpdateRouter>();
|
|
||||||
_logger = Services.GetRequiredService<ILogger<TelegramBotHost>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates new <see cref="TelegramBotHostBuilder"/> with default configuration, services and long-polling update receiving scheme
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static TelegramBotHostBuilder CreateBuilder()
|
|
||||||
{
|
|
||||||
HostApplicationBuilder innerBuilder = new HostApplicationBuilder(settings: null);
|
|
||||||
TelegramBotHostBuilder builder = new TelegramBotHostBuilder(innerBuilder, null);
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates new <see cref="TelegramBotHostBuilder"/> with default services and long-polling update receiving scheme
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static TelegramBotHostBuilder CreateBuilder(HostApplicationBuilderSettings? settings)
|
|
||||||
{
|
|
||||||
HostApplicationBuilder innerBuilder = new HostApplicationBuilder(settings);
|
|
||||||
TelegramBotHostBuilder builder = new TelegramBotHostBuilder(innerBuilder, settings);
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates new EMPTY <see cref="TelegramBotHostBuilder"/> WITHOUT any services or update receiving schemes
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static TelegramBotHostBuilder CreateEmptyBuilder()
|
|
||||||
{
|
|
||||||
HostApplicationBuilder innerBuilder = Host.CreateEmptyApplicationBuilder(null);
|
|
||||||
return new TelegramBotHostBuilder(innerBuilder, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates new EMPTY <see cref="TelegramBotHostBuilder"/> WITHOUT any services or update receiving schemes
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static TelegramBotHostBuilder CreateEmptyBuilder(HostApplicationBuilderSettings? settings)
|
|
||||||
{
|
|
||||||
HostApplicationBuilder innerBuilder = Host.CreateEmptyApplicationBuilder(null);
|
|
||||||
return new TelegramBotHostBuilder(innerBuilder, settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public async Task StartAsync(CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
await _innerHost.StartAsync(cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public async Task StopAsync(CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
await _innerHost.StopAsync(cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disposes the host.
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (_disposed)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_innerHost.Dispose();
|
|
||||||
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
_disposed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,13 +8,10 @@ using Telegrator.Core;
|
|||||||
#pragma warning disable IDE0001
|
#pragma warning disable IDE0001
|
||||||
namespace Telegrator.Hosting;
|
namespace Telegrator.Hosting;
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc/>
|
||||||
/// Represents a hosted telegram bots and services builder that helps manage configuration, logging, lifetime, and more.
|
|
||||||
/// </summary>
|
|
||||||
public class TelegramBotHostBuilder : ITelegramBotHostBuilder
|
public class TelegramBotHostBuilder : ITelegramBotHostBuilder
|
||||||
{
|
{
|
||||||
private readonly HostApplicationBuilder _innerBuilder;
|
private readonly IHostApplicationBuilder _innerBuilder;
|
||||||
private readonly HostApplicationBuilderSettings _settings;
|
|
||||||
internal IHandlersCollection _handlers = null!;
|
internal IHandlersCollection _handlers = null!;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -33,7 +30,7 @@ public class TelegramBotHostBuilder : ITelegramBotHostBuilder
|
|||||||
public IHostEnvironment Environment => _innerBuilder.Environment;
|
public IHostEnvironment Environment => _innerBuilder.Environment;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IDictionary<object, object> Properties => ((IHostApplicationBuilder)_innerBuilder).Properties;
|
public IDictionary<object, object> Properties => _innerBuilder.Properties;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IMetricsBuilder Metrics => _innerBuilder.Metrics;
|
public IMetricsBuilder Metrics => _innerBuilder.Metrics;
|
||||||
@@ -42,23 +39,9 @@ public class TelegramBotHostBuilder : ITelegramBotHostBuilder
|
|||||||
/// Initializes a new instance of the <see cref="TelegramBotHostBuilder"/> class.
|
/// Initializes a new instance of the <see cref="TelegramBotHostBuilder"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hostApplicationBuilder"></param>
|
/// <param name="hostApplicationBuilder"></param>
|
||||||
/// <param name="settings"></param>
|
public TelegramBotHostBuilder(IHostApplicationBuilder hostApplicationBuilder)
|
||||||
public TelegramBotHostBuilder(HostApplicationBuilder hostApplicationBuilder, HostApplicationBuilderSettings? settings = null)
|
|
||||||
{
|
{
|
||||||
_innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder));
|
_innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder));
|
||||||
_settings = settings ?? new HostApplicationBuilderSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="TelegramBotHostBuilder"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hostApplicationBuilder"></param>
|
|
||||||
/// <param name="options"></param>
|
|
||||||
/// <param name="settings"></param>
|
|
||||||
public TelegramBotHostBuilder(HostApplicationBuilder hostApplicationBuilder, TelegratorOptions? options, HostApplicationBuilderSettings? settings)
|
|
||||||
{
|
|
||||||
_innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder));
|
|
||||||
_settings = settings ?? new HostApplicationBuilderSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -66,35 +49,10 @@ public class TelegramBotHostBuilder : ITelegramBotHostBuilder
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hostApplicationBuilder"></param>
|
/// <param name="hostApplicationBuilder"></param>
|
||||||
/// <param name="handlers"></param>
|
/// <param name="handlers"></param>
|
||||||
/// <param name="settings"></param>
|
public TelegramBotHostBuilder(IHostApplicationBuilder hostApplicationBuilder, IHandlersCollection handlers)
|
||||||
public TelegramBotHostBuilder(HostApplicationBuilder hostApplicationBuilder, IHandlersCollection handlers, HostApplicationBuilderSettings? settings)
|
|
||||||
{
|
{
|
||||||
_innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder));
|
_innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder));
|
||||||
_settings = settings ?? new HostApplicationBuilderSettings();
|
_handlers = handlers ?? throw new ArgumentNullException(nameof(handlers));
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="TelegramBotHostBuilder"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hostApplicationBuilder"></param>
|
|
||||||
/// <param name="handlers"></param>
|
|
||||||
/// <param name="options"></param>
|
|
||||||
/// <param name="settings"></param>
|
|
||||||
public TelegramBotHostBuilder(HostApplicationBuilder hostApplicationBuilder, IHandlersCollection handlers, TelegratorOptions? options, HostApplicationBuilderSettings? settings)
|
|
||||||
{
|
|
||||||
_innerBuilder = hostApplicationBuilder ?? throw new ArgumentNullException(nameof(hostApplicationBuilder));
|
|
||||||
_settings = settings ?? new HostApplicationBuilderSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Builds the host.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public TelegramBotHost Build()
|
|
||||||
{
|
|
||||||
TelegramBotHost host = new TelegramBotHost(_innerBuilder);
|
|
||||||
host.UseTelegrator();
|
|
||||||
return host;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -32,11 +32,13 @@ public class MicrosoftLoggingAdapter : ITelegratorLogger
|
|||||||
|
|
||||||
if (exception != null)
|
if (exception != null)
|
||||||
{
|
{
|
||||||
_logger.Log(msLogLevel, default, message, exception, (str, exc) => string.Format("{0} : {1}", str, exc));
|
_logger.Log(msLogLevel, default, message, exception,
|
||||||
|
(str, exc) => string.Format("{0} : {1}", str, exc));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Log(msLogLevel, default, message, null, (str, _) => str);
|
_logger.Log(msLogLevel, default, message, null,
|
||||||
|
(str, _) => str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -5,9 +5,8 @@ using Telegram.Bot.Polling;
|
|||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Telegrator.Core;
|
using Telegrator.Core;
|
||||||
using Telegrator.Core.States;
|
using Telegrator.Core.States;
|
||||||
using Telegrator.Mediation;
|
|
||||||
|
|
||||||
namespace Telegrator.Polling;
|
namespace Telegrator.Mediation;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public class HostUpdateRouter : UpdateRouter
|
public class HostUpdateRouter : UpdateRouter
|
||||||
+6
-3
@@ -4,12 +4,11 @@ using Microsoft.Extensions.Options;
|
|||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Polling;
|
using Telegram.Bot.Polling;
|
||||||
using Telegrator.Core;
|
using Telegrator.Core;
|
||||||
using Telegrator.Mediation;
|
|
||||||
|
|
||||||
namespace Telegrator.Polling;
|
namespace Telegrator.Mediation;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Service for receiving updates for Hosted telegram bots
|
/// Service for receiving updates for Hosted telegram botsand queuing them to router
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="botClient"></param>
|
/// <param name="botClient"></param>
|
||||||
/// <param name="updateRouter"></param>
|
/// <param name="updateRouter"></param>
|
||||||
@@ -25,6 +24,10 @@ public class HostedUpdateReceiver(ITelegramBotClient botClient, IUpdateRouter up
|
|||||||
{
|
{
|
||||||
logger.LogInformation("Starting receiving updates via long-polling");
|
logger.LogInformation("Starting receiving updates via long-polling");
|
||||||
_receiverOptions.AllowedUpdates = _updateRouter.HandlersProvider.AllowedTypes.ToArray();
|
_receiverOptions.AllowedUpdates = _updateRouter.HandlersProvider.AllowedTypes.ToArray();
|
||||||
|
|
||||||
|
botClient.DeleteWebhook(options.Value.DropPendingUpdates, cancellationToken: stoppingToken)
|
||||||
|
.ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
|
|
||||||
DefaultUpdateReceiver updateReceiver = new DefaultUpdateReceiver(botClient, _receiverOptions);
|
DefaultUpdateReceiver updateReceiver = new DefaultUpdateReceiver(botClient, _receiverOptions);
|
||||||
await updateReceiver.ReceiveAsync(_updateRouter, stoppingToken).ConfigureAwait(false);
|
await updateReceiver.ReceiveAsync(_updateRouter, stoppingToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@@ -17,41 +17,60 @@ public class HostHandlersCollection(IServiceCollection hostServiceColletion, Tel
|
|||||||
{
|
{
|
||||||
switch (descriptor.Type)
|
switch (descriptor.Type)
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
|
throw new Exception("Unknown descriptor type");
|
||||||
|
|
||||||
case DescriptorType.General:
|
case DescriptorType.General:
|
||||||
{
|
{
|
||||||
if (descriptor.InstanceFactory != null)
|
if (descriptor.InstanceFactory != null)
|
||||||
|
{
|
||||||
Services.AddScoped(descriptor.HandlerType, _ => descriptor.InstanceFactory.Invoke());
|
Services.AddScoped(descriptor.HandlerType, _ => descriptor.InstanceFactory.Invoke());
|
||||||
else
|
break;
|
||||||
Services.AddScoped(descriptor.HandlerType);
|
}
|
||||||
|
|
||||||
|
Services.AddScoped(descriptor.HandlerType);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DescriptorType.Keyed:
|
case DescriptorType.Keyed:
|
||||||
{
|
{
|
||||||
if (descriptor.InstanceFactory != null)
|
if (descriptor.InstanceFactory != null)
|
||||||
|
{
|
||||||
Services.AddKeyedScoped(descriptor.HandlerType, descriptor.ServiceKey, (_, _) => descriptor.InstanceFactory.Invoke());
|
Services.AddKeyedScoped(descriptor.HandlerType, descriptor.ServiceKey, (_, _) => descriptor.InstanceFactory.Invoke());
|
||||||
else
|
break;
|
||||||
Services.AddKeyedScoped(descriptor.HandlerType, descriptor.ServiceKey);
|
}
|
||||||
|
|
||||||
|
Services.AddKeyedScoped(descriptor.HandlerType, descriptor.ServiceKey);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DescriptorType.Singleton:
|
case DescriptorType.Singleton:
|
||||||
{
|
{
|
||||||
Services.AddSingleton(descriptor.HandlerType, descriptor.SingletonInstance ?? (descriptor.InstanceFactory != null
|
if (descriptor.SingletonInstance != null)
|
||||||
? descriptor.InstanceFactory.Invoke()
|
{
|
||||||
: throw new Exception()));
|
Services.AddSingleton(descriptor.HandlerType, descriptor.SingletonInstance);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (descriptor.InstanceFactory == null)
|
||||||
|
throw new InvalidOperationException("Singleton handler descriptor without singleton instance should implement `InstanceFactory`");
|
||||||
|
|
||||||
|
Services.AddSingleton(descriptor.HandlerType, descriptor.InstanceFactory.Invoke());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DescriptorType.Implicit:
|
case DescriptorType.Implicit:
|
||||||
{
|
{
|
||||||
Services.AddKeyedSingleton(descriptor.HandlerType, descriptor.ServiceKey, descriptor.SingletonInstance ?? (descriptor.InstanceFactory != null
|
if (descriptor.SingletonInstance != null)
|
||||||
? descriptor.InstanceFactory.Invoke()
|
{
|
||||||
: throw new Exception()));
|
Services.AddKeyedSingleton(descriptor.HandlerType, descriptor.ServiceKey, descriptor.SingletonInstance);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (descriptor.InstanceFactory == null)
|
||||||
|
throw new InvalidOperationException("Implicit handler descriptor without singleton instance should implement `InstanceFactory`");
|
||||||
|
|
||||||
|
Services.AddKeyedSingleton(descriptor.HandlerType, descriptor.ServiceKey, descriptor.InstanceFactory.Invoke());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,12 @@
|
|||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
<Title>Telegrator.Hosting</Title>
|
<Title>Telegrator.Hosting</Title>
|
||||||
<Version>1.16.7</Version>
|
<Version>1.17.2</Version>
|
||||||
<Authors>Rikitav Tim4ik</Authors>
|
<Authors>Rikitav Tim4ik</Authors>
|
||||||
<Company>Rikitav Tim4ik</Company>
|
<Company>Rikitav Tim4ik</Company>
|
||||||
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
|
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
|
||||||
@@ -31,8 +34,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.3" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.7" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.3" />
|
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.7" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Polling;
|
using Telegram.Bot.Polling;
|
||||||
@@ -14,7 +15,7 @@ using Telegrator.Core.Descriptors;
|
|||||||
using Telegrator.Core.States;
|
using Telegrator.Core.States;
|
||||||
using Telegrator.Hosting;
|
using Telegrator.Hosting;
|
||||||
using Telegrator.Logging;
|
using Telegrator.Logging;
|
||||||
using Telegrator.Polling;
|
using Telegrator.Mediation;
|
||||||
using Telegrator.Providers;
|
using Telegrator.Providers;
|
||||||
using Telegrator.States;
|
using Telegrator.States;
|
||||||
|
|
||||||
@@ -30,53 +31,54 @@ public static class HostBuilderExtensions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string HandlersCollectionPropertyKey = nameof(IHandlersCollection);
|
public const string HandlersCollectionPropertyKey = nameof(IHandlersCollection);
|
||||||
|
|
||||||
extension (HostApplicationBuilder builder)
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the <see cref="IHandlersCollection"/> from the builder properties.
|
|
||||||
/// </summary>
|
|
||||||
public IHandlersCollection Handlers
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return (IHandlersCollection)((IHostApplicationBuilder)builder).Properties[HandlersCollectionPropertyKey];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static ITelegramBotHostBuilder AddTelegrator(this ITelegramBotHostBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null, Action<ITelegramBotHostBuilder>? action = null)
|
public static IHostApplicationBuilder AddTelegrator(this IHostApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null, Action<ITelegramBotHostBuilder>? action = null)
|
||||||
{
|
{
|
||||||
builder.AddTelegratorInternal(options, handlers);
|
AddTelegratorInternal(builder.Services, builder.Configuration, ((IHostApplicationBuilder)builder).Properties, ref handlers, options);
|
||||||
action?.Invoke(builder);
|
action?.Invoke(new TelegramBotHostBuilder(builder, handlers));
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IHostApplicationBuilder AddTelegrator(this HostApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null, Action<ITelegramBotHostBuilder>? action = null)
|
public static IHostApplicationBuilder AddTelegrator(this IHostApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
|
||||||
{
|
{
|
||||||
builder.AddTelegratorInternal(options, handlers);
|
AddTelegratorInternal(builder.Services, builder.Configuration, builder.Properties, ref handlers, options);
|
||||||
action?.Invoke(new TelegramBotHostBuilder(builder));
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IHostApplicationBuilder AddTelegratorInternal(this IHostApplicationBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
|
public static IHostBuilder AddTelegrator(this IHostBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null)
|
||||||
{
|
{
|
||||||
IServiceCollection services = builder.Services;
|
builder.ConfigureServices((ctx, sp) => AddTelegratorInternal(sp, ctx.Configuration, builder.Properties, ref handlers, options));
|
||||||
IConfigurationManager configuration = builder.Configuration;
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
|
/// </summary>
|
||||||
|
public static IHostBuilder AddTelegrator(this IHostBuilder builder, TelegratorOptions? options = null, IHandlersCollection? handlers = null, Action<IHandlersCollection>? action = null)
|
||||||
|
{
|
||||||
|
builder.ConfigureServices((ctx, sp) => AddTelegratorInternal(sp, ctx.Configuration, builder.Properties, ref handlers, options));
|
||||||
|
action?.Invoke(handlers!); // AddTelegratorInternal initializes `handlers`
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces TelegramBotHostBuilder. Configures DI, options, and handlers.
|
||||||
|
/// </summary>
|
||||||
|
internal static void AddTelegratorInternal(IServiceCollection services, IConfiguration configuration, IDictionary<object, object> properties, [NotNull] ref IHandlersCollection? handlers, TelegratorOptions? options = null)
|
||||||
|
{
|
||||||
if (options == null)
|
if (options == null)
|
||||||
{
|
{
|
||||||
options = configuration.GetSection(nameof(TelegratorOptions)).Get<TelegratorOptions>();
|
options = configuration.GetSection(nameof(TelegratorOptions)).Get<TelegratorOptions>();
|
||||||
if (options == null)
|
if (options == null)
|
||||||
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'TelegratorOptions' wasn't registered. This configuration is runtime required!");
|
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'TelegratorOptions' was registered. This configuration is runtime required!");
|
||||||
}
|
}
|
||||||
|
|
||||||
CancellationTokenSource globallCancell = new CancellationTokenSource();
|
CancellationTokenSource globallCancell = new CancellationTokenSource();
|
||||||
@@ -96,16 +98,13 @@ public static class HostBuilderExtensions
|
|||||||
|
|
||||||
handlers ??= new HostHandlersCollection(services, options);
|
handlers ??= new HostHandlersCollection(services, options);
|
||||||
services.AddSingleton(handlers);
|
services.AddSingleton(handlers);
|
||||||
|
properties.Add(HandlersCollectionPropertyKey, handlers);
|
||||||
|
|
||||||
builder.Properties.Add(HandlersCollectionPropertyKey, handlers);
|
if (!services.Any(srvc => srvc.ServiceType == typeof(IOptions<ReceiverOptions>)))
|
||||||
if (builder is TelegramBotHostBuilder botHostBuilder)
|
|
||||||
botHostBuilder._handlers = handlers;
|
|
||||||
|
|
||||||
if (!services.Any(srvc => srvc.ImplementationType == typeof(IOptions<ReceiverOptions>)))
|
|
||||||
{
|
{
|
||||||
ReceiverOptions? receiverOptions = configuration.GetSection(nameof(ReceiverOptions)).Get<ReceiverOptions>();
|
ReceiverOptions? receiverOptions = configuration.GetSection(nameof(ReceiverOptions)).Get<ReceiverOptions>();
|
||||||
if (receiverOptions == null)
|
if (receiverOptions == null)
|
||||||
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'ReceiverOptions' wasn't registered. This configuration is runtime required!");
|
throw new MissingMemberException("Auto configuration disabled, yet no options of type 'ReceiverOptions' was registered. This configuration is runtime required!");
|
||||||
|
|
||||||
services.AddSingleton(Options.Create(receiverOptions));
|
services.AddSingleton(Options.Create(receiverOptions));
|
||||||
}
|
}
|
||||||
@@ -119,9 +118,8 @@ public static class HostBuilderExtensions
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
services.AddTelegramReceiver();
|
|
||||||
services.AddTelegramBotHostDefaults();
|
services.AddTelegramBotHostDefaults();
|
||||||
return builder;
|
services.AddTelegramReceiver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,8 +127,34 @@ public static class HostBuilderExtensions
|
|||||||
/// Contains extensions for <see cref="IServiceCollection"/>
|
/// Contains extensions for <see cref="IServiceCollection"/>
|
||||||
/// Provides method to configure Telegram Bot Host
|
/// Provides method to configure Telegram Bot Host
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ServicesCollectionExtensions
|
public static class HostServicesCollectionExtensions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Adds TelegramBotClientOptions to services
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IServiceCollection ConfigureTelegram(this IServiceCollection services, TelegramBotClientOptions options)
|
||||||
|
{
|
||||||
|
services.RemoveAll<IOptions<TelegramBotClientOptions>>();
|
||||||
|
services.AddSingleton(Options.Create(options));
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds ReceiverOptions to services
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IServiceCollection ConfigureReceiver(this IServiceCollection services, ReceiverOptions options)
|
||||||
|
{
|
||||||
|
services.RemoveAll<IOptions<ReceiverOptions>>();
|
||||||
|
services.AddSingleton(Options.Create(options));
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers <see cref="IStateStorage"/> service
|
/// Registers <see cref="IStateStorage"/> service
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -144,7 +168,7 @@ public static class ServicesCollectionExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers <see cref="TelegramBotHost"/> default services
|
/// Registers <see cref="Telegrator"/> default services
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="services"></param>
|
/// <param name="services"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -166,6 +190,9 @@ public static class ServicesCollectionExtensions
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IServiceCollection AddTelegramReceiver(this IServiceCollection services)
|
public static IServiceCollection AddTelegramReceiver(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
services.RemoveAll<ITelegramBotClient>();
|
||||||
|
services.RemoveAll<HostedUpdateReceiver>();
|
||||||
|
|
||||||
services.AddHttpClient<ITelegramBotClient>("tgreceiver").RemoveAllLoggers().AddTypedClient(TypedTelegramBotClientFactory);
|
services.AddHttpClient<ITelegramBotClient>("tgreceiver").RemoveAllLoggers().AddTypedClient(TypedTelegramBotClientFactory);
|
||||||
services.AddHostedService<HostedUpdateReceiver>();
|
services.AddHostedService<HostedUpdateReceiver>();
|
||||||
return services;
|
return services;
|
||||||
@@ -199,11 +226,14 @@ public static class TelegramBotHostExtensions
|
|||||||
|
|
||||||
if (logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Information))
|
if (logger.IsEnabled(Microsoft.Extensions.Logging.LogLevel.Information))
|
||||||
{
|
{
|
||||||
logger.LogInformation("Telegrator Bot .NET Host started");
|
logger.LogInformation("Telegrator Bot Host started (Generic Host)");
|
||||||
|
logger.LogInformation("Receiving mode : LONG-POLLING");
|
||||||
logger.LogInformation("Telegram Bot : {firstname}, @{usrname}, id:{id},", info.User.FirstName ?? "[NULL]", info.User.Username ?? "[NULL]", info.User.Id);
|
logger.LogInformation("Telegram Bot : {firstname}, @{usrname}, id:{id},", info.User.FirstName ?? "[NULL]", info.User.Username ?? "[NULL]", info.User.Id);
|
||||||
logger.LogHandlers(handlers);
|
logger.LogHandlers(handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
botHost.AddLoggingAdapter();
|
||||||
|
botHost.SetBotCommands();
|
||||||
return botHost;
|
return botHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +248,12 @@ public static class TelegramBotHostExtensions
|
|||||||
IUpdateRouter router = botHost.Services.GetRequiredService<IUpdateRouter>();
|
IUpdateRouter router = botHost.Services.GetRequiredService<IUpdateRouter>();
|
||||||
|
|
||||||
IEnumerable<BotCommand> aliases = router.HandlersProvider.GetBotCommands();
|
IEnumerable<BotCommand> aliases = router.HandlersProvider.GetBotCommands();
|
||||||
client.SetMyCommands(aliases).Wait();
|
if (aliases.Any())
|
||||||
|
{
|
||||||
|
client.SetMyCommands(aliases)
|
||||||
|
.ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
return botHost;
|
return botHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +289,7 @@ public static class LoggerExtensions
|
|||||||
|
|
||||||
StringBuilder logBuilder = new StringBuilder("Registered handlers : ");
|
StringBuilder logBuilder = new StringBuilder("Registered handlers : ");
|
||||||
if (!handlers.Keys.Any())
|
if (!handlers.Keys.Any())
|
||||||
throw new Exception();
|
throw new Exception("No update types were registered");
|
||||||
|
|
||||||
foreach (UpdateType updateType in handlers.Keys)
|
foreach (UpdateType updateType in handlers.Keys)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,15 +2,45 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
|
<RootNamespace>Telegrator</RootNamespace>
|
||||||
|
<BaseOutputPath>..\..\bin</BaseOutputPath>
|
||||||
|
<DocumentationFile>..\..\docs\$(AssemblyName).xml</DocumentationFile>
|
||||||
|
|
||||||
|
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||||
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
|
<Title>Telegrator.Localized</Title>
|
||||||
|
<Version>1.17.1</Version>
|
||||||
|
<Authors>Rikitav Tim4ik</Authors>
|
||||||
|
<Company>Rikitav Tim4ik</Company>
|
||||||
|
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
|
||||||
|
<PackageTags>telegram;bot;mediator;attributes;aspect;hosting;host;framework;easy;simple;handlers</PackageTags>
|
||||||
|
|
||||||
|
<PackageIcon>telegrator_nuget.png</PackageIcon>
|
||||||
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="10.0.2" />
|
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="10.0.7" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Telegrator\Telegrator.csproj" />
|
<ProjectReference Include="..\Telegrator\Telegrator.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include=".\README.md" Pack="True" PackagePath="\" />
|
||||||
|
<None Include="..\..\LICENSE" Pack="True" PackagePath="\" />
|
||||||
|
<None Include="..\..\resources\telegrator_nuget.png" Pack="True" PackagePath="\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -125,7 +125,8 @@ public sealed class DescriptorFiltersSet
|
|||||||
if (!anyErrors)
|
if (!anyErrors)
|
||||||
return Result.Ok();
|
return Result.Ok();
|
||||||
|
|
||||||
return formReport ? Result.Next() : Result.Fault();
|
return formReport
|
||||||
|
? Result.Next() : Result.Fault();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool ExecuteFilter<T>(IFilter<T> filter, FilterExecutionContext<T> context, out Exception? exception) where T : class
|
private static bool ExecuteFilter<T>(IFilter<T> filter, FilterExecutionContext<T> context, out Exception? exception) where T : class
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ public class HandlerDescriptor
|
|||||||
public DescriptorType Type
|
public DescriptorType Type
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -52,7 +51,6 @@ public class HandlerDescriptor
|
|||||||
public Type HandlerType
|
public Type HandlerType
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -164,7 +162,7 @@ public class HandlerDescriptor
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateHandlerAttributeBase handlerAttribute = HandlerInspector.GetHandlerAttribute(handlerType);
|
UpdateHandlerAttributeBase handlerAttribute = HandlerInspector.GetHandlerAttribute(handlerType);
|
||||||
if (handlerAttribute.ExpectingHandlerType != null && !handlerAttribute.ExpectingHandlerType.Contains(handlerType.BaseType))
|
if (handlerAttribute.ExpectingHandlerType?.Contains(handlerType.BaseType) == false)
|
||||||
throw new ArgumentException(string.Format("This handler attribute cannot be attached to this class. Attribute can be attached on next handlers : {0}", string.Join(", ", handlerAttribute.ExpectingHandlerType.AsEnumerable())));
|
throw new ArgumentException(string.Format("This handler attribute cannot be attached to this class. Attribute can be attached on next handlers : {0}", string.Join(", ", handlerAttribute.ExpectingHandlerType.AsEnumerable())));
|
||||||
|
|
||||||
IFilter<Update>? stateKeeperAttribute = HandlerInspector.GetStateKeeperAttribute(handlerType);
|
IFilter<Update>? stateKeeperAttribute = HandlerInspector.GetStateKeeperAttribute(handlerType);
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
using System.ComponentModel;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Telegram.Bot.Types.Enums;
|
using Telegram.Bot.Types.Enums;
|
||||||
@@ -21,6 +24,11 @@ public static class HandlerInspector
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string? GetDisplayName(MemberInfo handlerType)
|
public static string? GetDisplayName(MemberInfo handlerType)
|
||||||
{
|
{
|
||||||
|
if (handlerType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(handlerType));
|
||||||
|
}
|
||||||
|
|
||||||
return handlerType.GetCustomAttribute<DisplayNameAttribute>()?.DisplayName;
|
return handlerType.GetCustomAttribute<DisplayNameAttribute>()?.DisplayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,11 +39,26 @@ public static class HandlerInspector
|
|||||||
/// <returns>The handler attribute.</returns>
|
/// <returns>The handler attribute.</returns>
|
||||||
public static UpdateHandlerAttributeBase GetHandlerAttribute(MemberInfo handlerType)
|
public static UpdateHandlerAttributeBase GetHandlerAttribute(MemberInfo handlerType)
|
||||||
{
|
{
|
||||||
// Getting polling handler attribute
|
if (handlerType == null)
|
||||||
IEnumerable<UpdateHandlerAttributeBase> handlerAttrs = handlerType.GetCustomAttributes<UpdateHandlerAttributeBase>();
|
{
|
||||||
|
throw new ArgumentNullException(nameof(handlerType));
|
||||||
|
}
|
||||||
|
|
||||||
//
|
List<UpdateHandlerAttributeBase> handlerAttrs = handlerType.GetCustomAttributes<UpdateHandlerAttributeBase>().ToList();
|
||||||
return handlerAttrs.Single();
|
|
||||||
|
if (handlerAttrs.Count == 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
$"Failed to register handler '{handlerType.Name}': Missing required attribute derived from '{nameof(UpdateHandlerAttributeBase)}'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handlerAttrs.Count > 1)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
$"Failed to register handler '{handlerType.Name}': Multiple handler attributes found. A handler must have exactly one attribute derived from '{nameof(UpdateHandlerAttributeBase)}'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return handlerAttrs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -45,10 +68,16 @@ public static class HandlerInspector
|
|||||||
/// <returns>The state keeper attribute, or null if not present.</returns>
|
/// <returns>The state keeper attribute, or null if not present.</returns>
|
||||||
public static IFilter<Update>? GetStateKeeperAttribute(MemberInfo handlerType)
|
public static IFilter<Update>? GetStateKeeperAttribute(MemberInfo handlerType)
|
||||||
{
|
{
|
||||||
// Getting polling handler attribute
|
if (handlerType == null)
|
||||||
Attribute stateAttr = handlerType.GetCustomAttribute(typeof(StateAttribute<,>));
|
throw new ArgumentNullException(nameof(handlerType));
|
||||||
|
|
||||||
|
Attribute? stateAttr = handlerType.GetCustomAttributes()
|
||||||
|
.FirstOrDefault(attr =>
|
||||||
|
{
|
||||||
|
Type type = attr.GetType();
|
||||||
|
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(StateAttribute<,>);
|
||||||
|
});
|
||||||
|
|
||||||
//
|
|
||||||
return stateAttr as IFilter<Update>;
|
return stateAttr as IFilter<Update>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,12 +89,19 @@ public static class HandlerInspector
|
|||||||
/// <returns>An enumerable of filter attributes.</returns>
|
/// <returns>An enumerable of filter attributes.</returns>
|
||||||
public static IEnumerable<IFilter<Update>> GetFilterAttributes(MemberInfo handlerType, UpdateType validUpdType)
|
public static IEnumerable<IFilter<Update>> GetFilterAttributes(MemberInfo handlerType, UpdateType validUpdType)
|
||||||
{
|
{
|
||||||
//
|
if (handlerType == null)
|
||||||
IEnumerable<UpdateFilterAttributeBase> filters = handlerType.GetCustomAttributes<UpdateFilterAttributeBase>();
|
throw new ArgumentNullException(nameof(handlerType));
|
||||||
|
|
||||||
//
|
List<UpdateFilterAttributeBase> filters = handlerType.GetCustomAttributes<UpdateFilterAttributeBase>().ToList();
|
||||||
if (filters.Any(filterAttr => !filterAttr.AllowedTypes.Contains(validUpdType)))
|
|
||||||
throw new InvalidOperationException();
|
UpdateFilterAttributeBase? invalidFilter = filters.FirstOrDefault(f => !f.AllowedTypes.Contains(validUpdType));
|
||||||
|
if (invalidFilter != null)
|
||||||
|
{
|
||||||
|
string allowedTypesStr = string.Join(", ", invalidFilter.AllowedTypes);
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
$"Filter conflict on handler '{handlerType.Name}': The filter '{invalidFilter.GetType().Name}' " +
|
||||||
|
$"does not support update type '{validUpdType}'. Allowed types: [{allowedTypesStr}].");
|
||||||
|
}
|
||||||
|
|
||||||
UpdateFilterAttributeBase? lastFilterAttribute = null;
|
UpdateFilterAttributeBase? lastFilterAttribute = null;
|
||||||
foreach (UpdateFilterAttributeBase filterAttribute in filters)
|
foreach (UpdateFilterAttributeBase filterAttribute in filters)
|
||||||
@@ -78,7 +114,6 @@ public static class HandlerInspector
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
lastFilterAttribute = filterAttribute;
|
lastFilterAttribute = filterAttribute;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,8 +126,24 @@ public static class HandlerInspector
|
|||||||
/// <returns>A <see cref="DescriptorAspectsSet"/> containing the aspects configuration.</returns>
|
/// <returns>A <see cref="DescriptorAspectsSet"/> containing the aspects configuration.</returns>
|
||||||
public static DescriptorAspectsSet GetAspects(Type handlerType)
|
public static DescriptorAspectsSet GetAspects(Type handlerType)
|
||||||
{
|
{
|
||||||
Type? typedPre = handlerType.GetCustomAttribute(typeof(BeforeExecutionAttribute<>))?.GetType().GetGenericArguments()[0];
|
if (handlerType == null)
|
||||||
Type? typedPost = handlerType.GetCustomAttribute(typeof(AfterExecutionAttribute<>))?.GetType().GetGenericArguments()[0];
|
throw new ArgumentNullException(nameof(handlerType));
|
||||||
|
|
||||||
|
Type? typedPre = GetGenericArgumentFromOpenGenericAttribute(handlerType, typeof(BeforeExecutionAttribute<>));
|
||||||
|
Type? typedPost = GetGenericArgumentFromOpenGenericAttribute(handlerType, typeof(AfterExecutionAttribute<>));
|
||||||
|
|
||||||
return new DescriptorAspectsSet(typedPre, typedPost);
|
return new DescriptorAspectsSet(typedPre, typedPost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Type? GetGenericArgumentFromOpenGenericAttribute(Type handlerType, Type openGenericAttributeType)
|
||||||
|
{
|
||||||
|
Attribute? attribute = handlerType.GetCustomAttributes()
|
||||||
|
.FirstOrDefault(attr =>
|
||||||
|
{
|
||||||
|
Type type = attr.GetType();
|
||||||
|
return type.IsGenericType && type.GetGenericTypeDefinition() == openGenericAttributeType;
|
||||||
|
});
|
||||||
|
|
||||||
|
return attribute?.GetType().GetGenericArguments().FirstOrDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ public abstract class HandlerBuilderBase(Type buildingHandlerType, UpdateType up
|
|||||||
private static int HandlerServiceKeyIndex = 0;
|
private static int HandlerServiceKeyIndex = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="IHandlersCollection"/> to ehich new builded handlers is adding
|
/// <see cref="IHandlersCollection"/> to which new builded handlers is adding
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly IHandlersCollection? HandlerCollection = handlerCollection;
|
protected readonly IHandlersCollection? HandlerCollection = handlerCollection;
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public abstract class UpdateHandlerBase(UpdateType handlingUpdateType) : IUpdate
|
|||||||
.ExecutePre(this, container, cancellationToken)
|
.ExecutePre(this, container, cancellationToken)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (!preResult.Positive)
|
if (!preResult.Success)
|
||||||
return preResult;
|
return preResult;
|
||||||
}
|
}
|
||||||
catch (NotImplementedException)
|
catch (NotImplementedException)
|
||||||
@@ -69,7 +69,7 @@ public abstract class UpdateHandlerBase(UpdateType handlingUpdateType) : IUpdate
|
|||||||
{
|
{
|
||||||
// Executing handler
|
// Executing handler
|
||||||
Result execResult = await ExecuteInternal(container, cancellationToken).ConfigureAwait(false);
|
Result execResult = await ExecuteInternal(container, cancellationToken).ConfigureAwait(false);
|
||||||
if (!execResult.Positive)
|
if (!execResult.Success)
|
||||||
return execResult;
|
return execResult;
|
||||||
}
|
}
|
||||||
catch (NotImplementedException)
|
catch (NotImplementedException)
|
||||||
@@ -86,7 +86,7 @@ public abstract class UpdateHandlerBase(UpdateType handlingUpdateType) : IUpdate
|
|||||||
.ExecutePost(this, container, cancellationToken)
|
.ExecutePost(this, container, cancellationToken)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (!postResult.Positive)
|
if (!postResult.Success)
|
||||||
return postResult;
|
return postResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ public abstract class UpdateHandlerBase(UpdateType handlingUpdateType) : IUpdate
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual Task<Result> FiltersFallback(FiltersFallbackReport report, ITelegramBotClient client, CancellationToken cancellationToken = default)
|
public virtual Task<Result> FiltersFallback(FiltersFallbackReport report, ITelegramBotClient client, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return Task.FromResult(Result.Ok());
|
return Task.FromResult(Result.Next());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -31,6 +31,14 @@ public interface IHandlersCollection
|
|||||||
/// <returns>The handler descriptor list for the given update type.</returns>
|
/// <returns>The handler descriptor list for the given update type.</returns>
|
||||||
public HandlerDescriptorList this[UpdateType updateType] { get; }
|
public HandlerDescriptorList this[UpdateType updateType] { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tryes to get the <see cref="HandlerDescriptorList"/> for the specified <see cref="UpdateType"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="updateType"></param>
|
||||||
|
/// <param name="list"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetDescriptorList(UpdateType updateType, out HandlerDescriptorList? list);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a <see cref="HandlerDescriptor"/> to the collection and returns the updated collection.
|
/// Adds a <see cref="HandlerDescriptor"/> to the collection and returns the updated collection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IHandlersManager : IHandlersCollection, IHandlersProvider
|
public interface IHandlersManager : IHandlersCollection, IHandlersProvider
|
||||||
{
|
{
|
||||||
|
// :P
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public interface IHandlersProvider
|
|||||||
public IEnumerable<UpdateType> AllowedTypes { get; }
|
public IEnumerable<UpdateType> AllowedTypes { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Gets the collection of <see cref="UpdateType"/> keys for the handler lists.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="updateType"></param>
|
/// <param name="updateType"></param>
|
||||||
/// <param name="list"></param>
|
/// <param name="list"></param>
|
||||||
|
|||||||
@@ -9,3 +9,5 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
[assembly: SuppressMessage("Style", "IDE0090")]
|
[assembly: SuppressMessage("Style", "IDE0090")]
|
||||||
[assembly: SuppressMessage("Style", "IDE0057")]
|
[assembly: SuppressMessage("Style", "IDE0057")]
|
||||||
[assembly: SuppressMessage("Style", "IDE0270")]
|
[assembly: SuppressMessage("Style", "IDE0270")]
|
||||||
|
[assembly: SuppressMessage("Roslynator", "RCS1037")]
|
||||||
|
[assembly: SuppressMessage("Roslynator", "RCS1227")]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ internal class AwaiterHandler(UpdateType handlingUpdateType) : UpdateHandlerBase
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Manual reset event used for synchronization.
|
/// Manual reset event used for synchronization.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private ManualResetEventSlim ResetEvent = new ManualResetEventSlim(false);
|
private readonly TaskCompletionSource<Update> ResetEvent = new TaskCompletionSource<Update>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the update that triggered this awaiter handler.
|
/// Gets the update that triggered this awaiter handler.
|
||||||
@@ -26,10 +26,10 @@ internal class AwaiterHandler(UpdateType handlingUpdateType) : UpdateHandlerBase
|
|||||||
/// Waits for the specified update type to be received.
|
/// Waits for the specified update type to be received.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cancellationToken">The cancellation token to cancel the wait operation.</param>
|
/// <param name="cancellationToken">The cancellation token to cancel the wait operation.</param>
|
||||||
public void Wait(CancellationToken cancellationToken)
|
public async Task<Update> Await(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ResetEvent.Reset();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
ResetEvent.Wait(cancellationToken);
|
return await ResetEvent.Task.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -51,8 +51,18 @@ internal class AwaiterHandler(UpdateType handlingUpdateType) : UpdateHandlerBase
|
|||||||
/// <returns>A completed task.</returns>
|
/// <returns>A completed task.</returns>
|
||||||
protected override Task<Result> ExecuteInternal(IHandlerContainer container, CancellationToken cancellation)
|
protected override Task<Result> ExecuteInternal(IHandlerContainer container, CancellationToken cancellation)
|
||||||
{
|
{
|
||||||
ResetEvent.Set();
|
try
|
||||||
return Task.FromResult(Result.Ok());
|
{
|
||||||
|
if (!ResetEvent.TrySetResult(HandlingUpdate))
|
||||||
|
ResetEvent.TrySetCanceled(cancellation);
|
||||||
|
|
||||||
|
return Task.FromResult(Result.Ok());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ResetEvent.TrySetException(ex);
|
||||||
|
return Task.FromResult(Result.Fault());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -61,8 +71,7 @@ internal class AwaiterHandler(UpdateType handlingUpdateType) : UpdateHandlerBase
|
|||||||
if (!disposing)
|
if (!disposing)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
ResetEvent.Dispose();
|
ResetEvent.TrySetCanceled();
|
||||||
ResetEvent = null!;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,10 +76,8 @@ public class AwaiterHandlerBuilder<TUpdate> : HandlerBuilderBase, IAwaiterHandle
|
|||||||
|
|
||||||
using (HandlerProvider.UseHandler(descriptor))
|
using (HandlerProvider.UseHandler(descriptor))
|
||||||
{
|
{
|
||||||
handlerInstance.Wait(cancellationToken);
|
await handlerInstance.Await(cancellationToken);
|
||||||
|
return handlerInstance.HandlingUpdate.GetActualUpdateObject<TUpdate>();
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.CompletedTask;
|
|
||||||
return handlerInstance.HandlingUpdate.GetActualUpdateObject<TUpdate>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using Telegram.Bot.Types;
|
||||||
|
using Telegram.Bot.Types.Enums;
|
||||||
|
using Telegrator.Core;
|
||||||
|
using Telegrator.Core.Descriptors;
|
||||||
|
using Telegrator.Core.Filters;
|
||||||
|
using Telegrator.Core.Handlers.Building;
|
||||||
|
using Telegrator.Core.States;
|
||||||
|
|
||||||
|
namespace Telegrator.Handlers.Building;
|
||||||
|
|
||||||
|
internal class AwaiterHandlerDeleter<TUpdate>(UpdateType updateType, Update handlingUpdate, IAwaitingProvider handlerProvider) : IAwaiterHandlerBuilder<TUpdate> where TUpdate : class
|
||||||
|
{
|
||||||
|
public Task<TUpdate> Await(IStateKeyResolver keyResolver, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
string? handlingKey = keyResolver.ResolveKey(handlingUpdate);
|
||||||
|
if (handlingKey is null)
|
||||||
|
throw new InvalidOperationException("Cannot await update with resolved key as NULL");
|
||||||
|
|
||||||
|
if (!handlerProvider.TryGetDescriptorList(updateType, out HandlerDescriptorList? list) || list == null)
|
||||||
|
return Task.FromResult<TUpdate>(null!);
|
||||||
|
|
||||||
|
foreach (DescriptorIndexer handler in list.Where(x => x.UpdateType == updateType && typeof(IAwaiterHandlerBuilder<>).IsAssignableFrom(x.HandlerType)).Select(x => x.Indexer).ToArray())
|
||||||
|
list.Remove(handler);
|
||||||
|
|
||||||
|
return Task.FromResult<TUpdate>(null!);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddFilter(IFilter<Update> filter) => throw new NotImplementedException();
|
||||||
|
public void AddFilters(params IFilter<Update>[] filters) => throw new NotImplementedException();
|
||||||
|
public void AddTargetedFilter<TFilterTarget>(Func<Update, TFilterTarget?> getFilterringTarget, IFilter<TFilterTarget> filter) where TFilterTarget : class => throw new NotImplementedException();
|
||||||
|
public void AddTargetedFilters<TFilterTarget>(Func<Update, TFilterTarget?> getFilterringTarget, params IFilter<TFilterTarget>[] filters) where TFilterTarget : class => throw new NotImplementedException();
|
||||||
|
public void SetConcurreny(int concurrency) => throw new NotImplementedException();
|
||||||
|
public void SetIndexer(int concurrency, int priority) => throw new NotImplementedException();
|
||||||
|
public void SetPriority(int priority) => throw new NotImplementedException();
|
||||||
|
public void SetState<TKey, TValue>(TValue? state) where TKey : IStateKeyResolver, new() where TValue : IEquatable<TValue> => throw new NotImplementedException();
|
||||||
|
public void SetUpdateValidating(UpdateValidateAction validateAction) => throw new NotImplementedException();
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Telegrator.Core;
|
using Telegram.Bot.Polling;
|
||||||
|
using Telegrator.Core;
|
||||||
|
|
||||||
namespace Telegrator;
|
namespace Telegrator;
|
||||||
|
|
||||||
@@ -12,4 +13,12 @@ public interface ITelegratorBot
|
|||||||
/// Gets the update router for handling incoming updates.
|
/// Gets the update router for handling incoming updates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IUpdateRouter UpdateRouter { get; }
|
public IUpdateRouter UpdateRouter { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the update router and begins polling for updates asynchronously.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="receiverOptions">Optional receiver options for configuring update polling.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token to stop receiving updates.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task StartReceivingAsync(ReceiverOptions? receiverOptions = null, CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,27 +19,22 @@ namespace Telegrator.Mediation;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class UpdateRouter : IUpdateRouter
|
public class UpdateRouter : IUpdateRouter
|
||||||
{
|
{
|
||||||
private readonly TelegratorOptions _options;
|
|
||||||
private readonly IHandlersProvider _handlersProvider;
|
|
||||||
private readonly IAwaitingProvider _awaitingProvider;
|
|
||||||
private readonly IStateStorage _stateStorage;
|
|
||||||
private readonly IUpdateHandlersPool _HandlersPool;
|
|
||||||
private readonly ITelegramBotInfo _botInfo;
|
private readonly ITelegramBotInfo _botInfo;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IHandlersProvider HandlersProvider => _handlersProvider;
|
public TelegratorOptions Options { get; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IAwaitingProvider AwaitingProvider => _awaitingProvider;
|
public IHandlersProvider HandlersProvider { get; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IStateStorage StateStorage => _stateStorage;
|
public IAwaitingProvider AwaitingProvider { get; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public TelegratorOptions Options => _options;
|
public IStateStorage StateStorage { get; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IUpdateHandlersPool HandlersPool => _HandlersPool;
|
public IUpdateHandlersPool HandlersPool { get; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IRouterExceptionHandler? ExceptionHandler { get; set; }
|
public IRouterExceptionHandler? ExceptionHandler { get; set; }
|
||||||
@@ -57,11 +52,11 @@ public class UpdateRouter : IUpdateRouter
|
|||||||
/// <param name="botInfo"></param>
|
/// <param name="botInfo"></param>
|
||||||
public UpdateRouter(IHandlersProvider handlersProvider, IAwaitingProvider awaitingProvider, IStateStorage stateStorage, TelegratorOptions options, ITelegramBotInfo botInfo)
|
public UpdateRouter(IHandlersProvider handlersProvider, IAwaitingProvider awaitingProvider, IStateStorage stateStorage, TelegratorOptions options, ITelegramBotInfo botInfo)
|
||||||
{
|
{
|
||||||
_options = options;
|
Options = options;
|
||||||
_handlersProvider = handlersProvider;
|
HandlersProvider = handlersProvider;
|
||||||
_awaitingProvider = awaitingProvider;
|
AwaitingProvider = awaitingProvider;
|
||||||
_stateStorage = stateStorage;
|
StateStorage = stateStorage;
|
||||||
_HandlersPool = new UpdateHandlersPool(this, _options, _options.GlobalCancellationToken);
|
HandlersPool = new UpdateHandlersPool(this, Options, Options.GlobalCancellationToken);
|
||||||
_botInfo = botInfo;
|
_botInfo = botInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,11 +97,8 @@ public class UpdateRouter : IUpdateRouter
|
|||||||
Result? lastResult = null;
|
Result? lastResult = null;
|
||||||
foreach (DescribedHandlerDescriptor handlerInfo in GetHandlers(AwaitingProvider, botClient, update, cancellationToken))
|
foreach (DescribedHandlerDescriptor handlerInfo in GetHandlers(AwaitingProvider, botClient, update, cancellationToken))
|
||||||
{
|
{
|
||||||
if (lastResult?.NextType != null)
|
if (lastResult?.NextType is not null && lastResult?.NextType != handlerInfo.From.HandlerType)
|
||||||
{
|
continue;
|
||||||
if (lastResult.NextType != handlerInfo.From.HandlerType)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enqueuing found awiting handlers
|
// Enqueuing found awiting handlers
|
||||||
await HandlersPool.Enqueue(handlerInfo);
|
await HandlersPool.Enqueue(handlerInfo);
|
||||||
@@ -116,7 +108,7 @@ public class UpdateRouter : IUpdateRouter
|
|||||||
if (lastResult == null)
|
if (lastResult == null)
|
||||||
break; // Smth went horribly wrong, better to stop routing
|
break; // Smth went horribly wrong, better to stop routing
|
||||||
|
|
||||||
if (lastResult != null && !lastResult.RouteNext)
|
if (!lastResult.RouteNext)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
TelegratorLogging.LogTrace("Handler '{0}' requested route continuation (Update {1})", handlerInfo.DisplayString, handlerInfo.HandlingUpdate.Id);
|
TelegratorLogging.LogTrace("Handler '{0}' requested route continuation (Update {1})", handlerInfo.DisplayString, handlerInfo.HandlingUpdate.Id);
|
||||||
@@ -132,11 +124,8 @@ public class UpdateRouter : IUpdateRouter
|
|||||||
// Queuing reagular handlers for execution
|
// Queuing reagular handlers for execution
|
||||||
foreach (DescribedHandlerDescriptor handlerInfo in GetHandlers(HandlersProvider, botClient, update, cancellationToken))
|
foreach (DescribedHandlerDescriptor handlerInfo in GetHandlers(HandlersProvider, botClient, update, cancellationToken))
|
||||||
{
|
{
|
||||||
if (lastResult?.NextType != null)
|
if (lastResult?.NextType is not null && lastResult?.NextType != handlerInfo.From.HandlerType)
|
||||||
{
|
continue;
|
||||||
if (lastResult.NextType != handlerInfo.From.HandlerType)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enqueuing found handlers
|
// Enqueuing found handlers
|
||||||
await HandlersPool.Enqueue(handlerInfo);
|
await HandlersPool.Enqueue(handlerInfo);
|
||||||
@@ -146,7 +135,7 @@ public class UpdateRouter : IUpdateRouter
|
|||||||
if (lastResult == null)
|
if (lastResult == null)
|
||||||
break; // Smth went horribly wrong, better to stop routing
|
break; // Smth went horribly wrong, better to stop routing
|
||||||
|
|
||||||
if (lastResult != null && !lastResult.RouteNext)
|
if (!lastResult.RouteNext)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
TelegratorLogging.LogTrace("Handler '{0}' requested route continuation (Update {1})", handlerInfo.DisplayString, handlerInfo.HandlingUpdate.Id);
|
TelegratorLogging.LogTrace("Handler '{0}' requested route continuation (Update {1})", handlerInfo.DisplayString, handlerInfo.HandlingUpdate.Id);
|
||||||
@@ -255,7 +244,7 @@ public class UpdateRouter : IUpdateRouter
|
|||||||
breakRouting = !fallbackResult.RouteNext;
|
breakRouting = !fallbackResult.RouteNext;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if (!filtersResult.Positive)
|
else if (!filtersResult.Success)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -307,6 +296,4 @@ public class UpdateRouter : IUpdateRouter
|
|||||||
|
|
||||||
TelegratorLogging.LogTrace(sb.ToString());
|
TelegratorLogging.LogTrace(sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BreakDescribingException : Exception { }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ public class AwaitingProvider(TelegratorOptions options) : HandlersProvider([],
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool TryGetDescriptorList(UpdateType updateType, out HandlerDescriptorList? list)
|
public override bool TryGetDescriptorList(UpdateType updateType, out HandlerDescriptorList? list)
|
||||||
{
|
{
|
||||||
|
if (HandlersList.HandlingType != updateType)
|
||||||
|
{
|
||||||
|
list = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
list = HandlersList;
|
list = HandlersList;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -46,7 +52,7 @@ public class AwaitingProvider(TelegratorOptions options) : HandlersProvider([],
|
|||||||
public readonly void Register()
|
public readonly void Register()
|
||||||
{
|
{
|
||||||
if (handlerDescriptor.SingletonInstance == null)
|
if (handlerDescriptor.SingletonInstance == null)
|
||||||
throw new Exception();
|
throw new Exception("Handler descriptor has no singleton instance.");
|
||||||
|
|
||||||
handlersList.Add(handlerDescriptor);
|
handlersList.Add(handlerDescriptor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,8 +96,7 @@ public class HandlersCollection(TelegratorOptions? options) : IHandlersCollectio
|
|||||||
protected virtual HandlerDescriptorList GetDescriptorList(HandlerDescriptor descriptor)
|
protected virtual HandlerDescriptorList GetDescriptorList(HandlerDescriptor descriptor)
|
||||||
{
|
{
|
||||||
UpdateType updateType = UpdateTypeExtensions.SuppressTypes.TryGetValue(descriptor.UpdateType, out UpdateType suppressType)
|
UpdateType updateType = UpdateTypeExtensions.SuppressTypes.TryGetValue(descriptor.UpdateType, out UpdateType suppressType)
|
||||||
? suppressType
|
? suppressType : descriptor.UpdateType;
|
||||||
: descriptor.UpdateType;
|
|
||||||
|
|
||||||
if (!InnerDictionary.TryGetValue(updateType, out HandlerDescriptorList? list))
|
if (!InnerDictionary.TryGetValue(updateType, out HandlerDescriptorList? list))
|
||||||
{
|
{
|
||||||
@@ -127,4 +126,10 @@ public class HandlersCollection(TelegratorOptions? options) : IHandlersCollectio
|
|||||||
|
|
||||||
CommandAliasses.AddRange(alliasAttribute.Alliases);
|
CommandAliasses.AddRange(alliasAttribute.Alliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public bool TryGetDescriptorList(UpdateType updateType, out HandlerDescriptorList list)
|
||||||
|
{
|
||||||
|
return InnerDictionary.TryGetValue(updateType, out list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public abstract class HandlersManagerBase(TelegratorOptions options) : IHandlers
|
|||||||
/// <exception cref="Exception">Thrown when intersecting command aliases are found and ExceptIntersectingCommandAliases is enabled.</exception>
|
/// <exception cref="Exception">Thrown when intersecting command aliases are found and ExceptIntersectingCommandAliases is enabled.</exception>
|
||||||
protected virtual void IntersectCommands(HandlerDescriptor descriptor)
|
protected virtual void IntersectCommands(HandlerDescriptor descriptor)
|
||||||
{
|
{
|
||||||
if (Options == null || !Options.ExceptIntersectingCommandAliases)
|
if (Options?.ExceptIntersectingCommandAliases is not true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CommandAlliasAttribute? alliasAttribute = descriptor.HandlerType.GetCustomAttribute<CommandAlliasAttribute>();
|
CommandAlliasAttribute? alliasAttribute = descriptor.HandlerType.GetCustomAttribute<CommandAlliasAttribute>();
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ public sealed class Result
|
|||||||
private static readonly Result next = new Result(true, true, null);
|
private static readonly Result next = new Result(true, true, null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is result positive
|
/// Tell router to stop describing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Positive { get; }
|
public bool Success { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should router search for next matching handler
|
/// Tell router to continue describing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool RouteNext { get; }
|
public bool RouteNext { get; }
|
||||||
|
|
||||||
@@ -29,9 +29,9 @@ public sealed class Result
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Type? NextType { get; }
|
public Type? NextType { get; }
|
||||||
|
|
||||||
internal Result(bool positive, bool routeNext, Type? nextType)
|
internal Result(bool success, bool routeNext, Type? nextType)
|
||||||
{
|
{
|
||||||
Positive = positive;
|
Success = success;
|
||||||
RouteNext = routeNext;
|
RouteNext = routeNext;
|
||||||
NextType = nextType;
|
NextType = nextType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,21 @@ public static partial class ColletionsExtensions
|
|||||||
return new ReadOnlyDictionary<TKey, TValue>(dictionary);
|
return new ReadOnlyDictionary<TKey, TValue>(dictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove all <see langword="null"/> values and returns collection without nullable type.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="source"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IEnumerable<T> Squeeze<T>(this IEnumerable<T?> source)
|
||||||
|
{
|
||||||
|
foreach (T? item in source)
|
||||||
|
{
|
||||||
|
if (item is not null)
|
||||||
|
yield return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enumerates objects in a <paramref name="source"/> and executes an <paramref name="action"/> on each one
|
/// Enumerates objects in a <paramref name="source"/> and executes an <paramref name="action"/> on each one
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -136,7 +151,7 @@ public static partial class ColletionsExtensions
|
|||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T? SingleSafe<T>(this IEnumerable<T> source)
|
public static T? SingleOrNothing<T>(this IEnumerable<T> source)
|
||||||
=> source.Count() == 1 ? source.ElementAt(0) : default;
|
=> source.Count() == 1 ? source.ElementAt(0) : default;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -147,7 +162,7 @@ public static partial class ColletionsExtensions
|
|||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
/// <param name="predicate"></param>
|
/// <param name="predicate"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T? SingleSafe<T>(this IEnumerable<T> source, Func<T, bool> predicate)
|
public static T? SingleOrNothing<T>(this IEnumerable<T> source, Func<T, bool> predicate)
|
||||||
{
|
{
|
||||||
source = source.Where(predicate);
|
source = source.Where(predicate);
|
||||||
return source.Count() == 1 ? source.ElementAt(0) : default;
|
return source.Count() == 1 ? source.ElementAt(0) : default;
|
||||||
@@ -188,7 +203,7 @@ public static partial class ReflectionExtensions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool IsHandlerRealization(this Type type)
|
public static bool IsHandlerImplementation(this Type type)
|
||||||
=> !type.IsAbstract && type != typeof(UpdateHandlerBase) && typeof(UpdateHandlerBase).IsAssignableFrom(type);
|
=> !type.IsAbstract && type != typeof(UpdateHandlerBase) && typeof(UpdateHandlerBase).IsAssignableFrom(type);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -205,7 +220,7 @@ public static partial class ReflectionExtensions
|
|||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool HasPublicProperties(this Type type)
|
public static bool HasPublicProperties(this Type type)
|
||||||
=> type.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(prop => prop.Name != "IsCollectible").Any();
|
=> type.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Any(prop => prop.Name != "IsCollectible");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether an instance of a specified type can be assigned to an instance of the current type
|
/// Determines whether an instance of a specified type can be assigned to an instance of the current type
|
||||||
@@ -260,6 +275,7 @@ public static partial class StringExtensions
|
|||||||
{
|
{
|
||||||
char[] chars = target.ToCharArray();
|
char[] chars = target.ToCharArray();
|
||||||
int index = chars.IndexOf(char.IsLetter);
|
int index = chars.IndexOf(char.IsLetter);
|
||||||
|
|
||||||
chars[index] = char.ToUpper(chars[index]);
|
chars[index] = char.ToUpper(chars[index]);
|
||||||
return new string(chars);
|
return new string(chars);
|
||||||
}
|
}
|
||||||
@@ -273,6 +289,7 @@ public static partial class StringExtensions
|
|||||||
{
|
{
|
||||||
char[] chars = target.ToCharArray();
|
char[] chars = target.ToCharArray();
|
||||||
int index = chars.IndexOf(char.IsLetter);
|
int index = chars.IndexOf(char.IsLetter);
|
||||||
|
|
||||||
chars[index] = char.ToLower(chars[index]);
|
chars[index] = char.ToLower(chars[index]);
|
||||||
return new string(chars);
|
return new string(chars);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,12 @@
|
|||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||||
|
<IncludeSymbols>True</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
|
||||||
<Title>Telegrator : Telegram.Bot mediator framework</Title>
|
<Title>Telegrator : Telegram.Bot mediator framework</Title>
|
||||||
<Version>1.16.7</Version>
|
<Version>1.17.1</Version>
|
||||||
<Authors>Rikitav Tim4ik</Authors>
|
<Authors>Rikitav Tim4ik</Authors>
|
||||||
<Company>Rikitav Tim4ik</Company>
|
<Company>Rikitav Tim4ik</Company>
|
||||||
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
|
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
|
||||||
@@ -32,9 +35,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.3" />
|
<PackageReference Include="Telegram.Bot" Version="22.10.0" />
|
||||||
<PackageReference Include="System.Threading.Channels" Version="10.0.3" />
|
<PackageReference Include="System.Threading.Channels" Version="10.0.7" />
|
||||||
<PackageReference Include="Telegram.Bot" Version="22.9.5.3" />
|
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.7" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -20,16 +20,16 @@ public class TelegratorClient : TelegramBotClient, ITelegratorBot, ICollectingPr
|
|||||||
private IUpdateRouter? updateRouter = null;
|
private IUpdateRouter? updateRouter = null;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public TelegratorOptions Options { get; private set; }
|
public TelegratorOptions Options { get; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IHandlersCollection Handlers { get; private set; }
|
public IHandlersCollection Handlers { get; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public ITelegramBotInfo BotInfo { get; private set; }
|
public ITelegramBotInfo BotInfo { get; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IUpdateRouter UpdateRouter { get => updateRouter ?? throw new Exception(); }
|
public IUpdateRouter UpdateRouter => updateRouter ?? throw new InvalidOperationException("Router's not created yet. Invoke `StartReceiving` to initialize this property.");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TelegratorClient"/> class with a bot token.
|
/// Initializes a new instance of the <see cref="TelegratorClient"/> class with a bot token.
|
||||||
@@ -63,13 +63,8 @@ public class TelegratorClient : TelegramBotClient, ITelegratorBot, ICollectingPr
|
|||||||
BotInfo = new TelegramBotInfo(this.GetMe(cancellationToken).Result);
|
BotInfo = new TelegramBotInfo(this.GetMe(cancellationToken).Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <inheritdoc/>
|
||||||
/// Starts receiving updates from Telegram.
|
public async Task StartReceivingAsync(ReceiverOptions? receiverOptions = null, CancellationToken cancellationToken = default)
|
||||||
/// Initializes the update router and begins polling for updates.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="receiverOptions">Optional receiver options for configuring update polling.</param>
|
|
||||||
/// <param name="cancellationToken">The cancellation token to stop receiving updates.</param>
|
|
||||||
public void StartReceiving(ReceiverOptions? receiverOptions = null, CancellationToken cancellationToken = default)
|
|
||||||
{
|
{
|
||||||
if (Options.GlobalCancellationToken == CancellationToken.None)
|
if (Options.GlobalCancellationToken == CancellationToken.None)
|
||||||
Options.GlobalCancellationToken = cancellationToken;
|
Options.GlobalCancellationToken = cancellationToken;
|
||||||
@@ -78,12 +73,9 @@ public class TelegratorClient : TelegramBotClient, ITelegratorBot, ICollectingPr
|
|||||||
AwaitingProvider awaitingProvider = new AwaitingProvider(Options);
|
AwaitingProvider awaitingProvider = new AwaitingProvider(Options);
|
||||||
DefaultStateStorage stateStorage = new DefaultStateStorage();
|
DefaultStateStorage stateStorage = new DefaultStateStorage();
|
||||||
|
|
||||||
updateRouter = new UpdateRouter(handlerProvider, awaitingProvider, stateStorage, Options, BotInfo);
|
|
||||||
|
|
||||||
// Log startup
|
|
||||||
TelegratorLogging.LogInformation($"Telegrator bot starting up - BotId: {BotInfo.User.Id}, Username: {BotInfo.User.Username}, MaxParallelHandlers: {Options.MaximumParallelWorkingHandlers ?? -1}");
|
TelegratorLogging.LogInformation($"Telegrator bot starting up - BotId: {BotInfo.User.Id}, Username: {BotInfo.User.Username}, MaxParallelHandlers: {Options.MaximumParallelWorkingHandlers ?? -1}");
|
||||||
|
updateRouter = new UpdateRouter(handlerProvider, awaitingProvider, stateStorage, Options, BotInfo);
|
||||||
StartReceivingInternal(receiverOptions, cancellationToken);
|
await StartReceivingInternal(receiverOptions, Options.GlobalCancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -92,7 +84,7 @@ public class TelegratorClient : TelegramBotClient, ITelegratorBot, ICollectingPr
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="receiverOptions">Optional receiver options for configuring update polling.</param>
|
/// <param name="receiverOptions">Optional receiver options for configuring update polling.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token to stop receiving updates.</param>
|
/// <param name="cancellationToken">The cancellation token to stop receiving updates.</param>
|
||||||
private async void StartReceivingInternal(ReceiverOptions? receiverOptions, CancellationToken cancellationToken)
|
private async Task StartReceivingInternal(ReceiverOptions? receiverOptions, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -115,6 +107,4 @@ public class TelegratorClient : TelegramBotClient, ITelegratorBot, ICollectingPr
|
|||||||
TelegratorLogging.LogInformation("Telegrator bot stopped (cancelled)");
|
TelegratorLogging.LogInformation("Telegrator bot stopped (cancelled)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Telegram.Bot.Polling;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Telegram.Bot.Types.Enums;
|
using Telegram.Bot.Types.Enums;
|
||||||
using Telegram.Bot.Types.Payments;
|
using Telegram.Bot.Types.Payments;
|
||||||
@@ -13,6 +14,24 @@ using Telegrator.States;
|
|||||||
|
|
||||||
namespace Telegrator;
|
namespace Telegrator;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides usefull helper methods for TelegratorBot
|
||||||
|
/// </summary>
|
||||||
|
public static class TelegratorBotExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the update router and begins polling for updates synchronously (Blocking calling thread).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bot"></param>
|
||||||
|
/// <param name="receiverOptions">Optional receiver options for configuring update polling.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token to stop receiving updates.</param>
|
||||||
|
public static void StartReceiving(this ITelegratorBot bot, ReceiverOptions? receiverOptions = null, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
bot.StartReceivingAsync(receiverOptions, cancellationToken)
|
||||||
|
.ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides usefull helper methods for messages
|
/// Provides usefull helper methods for messages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -231,6 +250,17 @@ public static class AwaitingProviderExtensions
|
|||||||
public static IAwaiterHandlerBuilder<TUpdate> CreateAbstract<TUpdate>(this IAwaitingProvider awaitingProvider, UpdateType updateType, Update handlingUpdate) where TUpdate : class
|
public static IAwaiterHandlerBuilder<TUpdate> CreateAbstract<TUpdate>(this IAwaitingProvider awaitingProvider, UpdateType updateType, Update handlingUpdate) where TUpdate : class
|
||||||
=> new AwaiterHandlerBuilder<TUpdate>(updateType, handlingUpdate, awaitingProvider);
|
=> new AwaiterHandlerBuilder<TUpdate>(updateType, handlingUpdate, awaitingProvider);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an awaiter handler builder for a specific update type that will delete the awaiting handler after awaiting is completed.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TUpdate"></typeparam>
|
||||||
|
/// <param name="awaitingProvider"></param>
|
||||||
|
/// <param name="updateType"></param>
|
||||||
|
/// <param name="handlingUpdate"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IAwaiterHandlerBuilder<TUpdate> CreateDeleting<TUpdate>(this IAwaitingProvider awaitingProvider, UpdateType updateType, Update handlingUpdate) where TUpdate : class
|
||||||
|
=> new AwaiterHandlerDeleter<TUpdate>(updateType, handlingUpdate, awaitingProvider);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates an awaiter builder for any update type.
|
/// Creates an awaiter builder for any update type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -257,6 +287,15 @@ public static class AwaitingProviderExtensions
|
|||||||
/// <returns>An awaiter builder for callback query updates.</returns>
|
/// <returns>An awaiter builder for callback query updates.</returns>
|
||||||
public static IAwaiterHandlerBuilder<CallbackQuery> AwaitCallbackQuery(this IAwaitingProvider awaitingProvider, Update handlingUpdate)
|
public static IAwaiterHandlerBuilder<CallbackQuery> AwaitCallbackQuery(this IAwaitingProvider awaitingProvider, Update handlingUpdate)
|
||||||
=> awaitingProvider.CreateAbstract<CallbackQuery>(UpdateType.CallbackQuery, handlingUpdate);
|
=> awaitingProvider.CreateAbstract<CallbackQuery>(UpdateType.CallbackQuery, handlingUpdate);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all awaiting handlers for callback query updates.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="awaitingProvider"></param>
|
||||||
|
/// <param name="handlingUpdate"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IAwaiterHandlerBuilder<CallbackQuery> CancellAllCallbacks(this IAwaitingProvider awaitingProvider, Update handlingUpdate)
|
||||||
|
=> awaitingProvider.CreateDeleting<CallbackQuery>(UpdateType.CallbackQuery, handlingUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -392,6 +431,26 @@ public static partial class HandlersCollectionExtensions
|
|||||||
"Ocelot", "BouncyCastle", "IdentityModel", "Telegrator"
|
"Ocelot", "BouncyCastle", "IdentityModel", "Telegrator"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Collects all handlers from current app domain.
|
||||||
|
/// Scans for handlers exported by analyzer into class `Telegrator.Analyzers.AnalyzerExport` in each assembly and registers them to the collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="handlers"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IHandlersCollection CollectHandlers(this IHandlersCollection handlers)
|
||||||
|
{
|
||||||
|
const string exportClassName = "Telegrator.Analyzers.AnalyzerExport";
|
||||||
|
AppDomain.CurrentDomain.GetAssemblies()
|
||||||
|
.Select(ass => ass.GetType(exportClassName))
|
||||||
|
.Squeeze()
|
||||||
|
.SelectMany(t => t.GetFields())
|
||||||
|
.Select(f => f.GetValue(null) as Type)
|
||||||
|
.Squeeze()
|
||||||
|
.ForEach(v => handlers.AddHandler(v));
|
||||||
|
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Collects all public handlers from the current app domain.
|
/// Collects all public handlers from the current app domain.
|
||||||
/// Scans for types that implement handlers and adds them to the collection.
|
/// Scans for types that implement handlers and adds them to the collection.
|
||||||
@@ -418,8 +477,7 @@ public static partial class HandlersCollectionExtensions
|
|||||||
{
|
{
|
||||||
(collectingTarget ?? Assembly.GetCallingAssembly())
|
(collectingTarget ?? Assembly.GetCallingAssembly())
|
||||||
.GetExportedTypes()
|
.GetExportedTypes()
|
||||||
.Where(type => type.GetCustomAttribute<DontCollectAttribute>() == null)
|
.Where(type => type.GetCustomAttribute<DontCollectAttribute>() == null && type.IsHandlerImplementation())
|
||||||
.Where(type => type.IsHandlerRealization())
|
|
||||||
.ForEach(type => handlers.AddHandler(type));
|
.ForEach(type => handlers.AddHandler(type));
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
@@ -477,7 +535,7 @@ public static partial class HandlersCollectionExtensions
|
|||||||
/// <exception cref="Exception">Thrown when the type is not a valid handler implementation.</exception>
|
/// <exception cref="Exception">Thrown when the type is not a valid handler implementation.</exception>
|
||||||
public static IHandlersCollection AddHandler(this IHandlersCollection handlers, Type handlerType)
|
public static IHandlersCollection AddHandler(this IHandlersCollection handlers, Type handlerType)
|
||||||
{
|
{
|
||||||
if (!handlerType.IsHandlerRealization())
|
if (!handlerType.IsHandlerImplementation())
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
|
|
||||||
if (handlerType.IsCustomDescriptorsProvider())
|
if (handlerType.IsCustomDescriptorsProvider())
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// This file is used by Code Analysis to maintain SuppressMessage
|
||||||
|
// attributes that are applied to this project.
|
||||||
|
// Project-level suppressions either have no target or are given
|
||||||
|
// a specific target and scoped to a namespace, type, member, etc.
|
||||||
|
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
|
[assembly: SuppressMessage("Roslynator", "RCS1037")]
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.Data.Sqlite;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Telegram.Bot.Polling;
|
||||||
|
|
||||||
|
namespace Telegrator.Tests;
|
||||||
|
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
public static void HostApplicationBuilder_Example(string[] args)
|
||||||
|
{
|
||||||
|
HostApplicationBuilder builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings()
|
||||||
|
{
|
||||||
|
Args = args,
|
||||||
|
ApplicationName = "Host example",
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.Services.ConfigureReceiver(new ReceiverOptions()
|
||||||
|
{
|
||||||
|
DropPendingUpdates = true,
|
||||||
|
Limit = 100
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.AddTelegrator(action: builder => builder.Handlers
|
||||||
|
.CollectHandlersAssemblyWide());
|
||||||
|
|
||||||
|
builder.Build()
|
||||||
|
.UseTelegrator()
|
||||||
|
.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WideBotApplicationBuilder_Example(string[] args)
|
||||||
|
{
|
||||||
|
HostApplicationBuilder builder = Host.CreateApplicationBuilder(new HostApplicationBuilderSettings()
|
||||||
|
{
|
||||||
|
Args = args,
|
||||||
|
ApplicationName = "WBot example",
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.Services.ConfigureWideBot(new WideBotOptions()
|
||||||
|
{
|
||||||
|
ApiId = 123,
|
||||||
|
ApiHash = "API_HASH",
|
||||||
|
DropPendingUpdates = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.AddWideTelegrator(
|
||||||
|
dbConnectionFactory: provider => new SqliteConnection($"Data Source={Environment.ExpandEnvironmentVariables("%AppData%\\Telegrator\\%wtgb.db")}"),
|
||||||
|
action: builder => builder.Handlers.CollectHandlersAssemblyWide());
|
||||||
|
|
||||||
|
builder.Build()
|
||||||
|
.UseWideTelegrator()
|
||||||
|
.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WebApplicationBuilder_Example(string[] args)
|
||||||
|
{
|
||||||
|
WebApplicationBuilder builder = WebApplication.CreateBuilder(new WebApplicationOptions()
|
||||||
|
{
|
||||||
|
Args = args,
|
||||||
|
ApplicationName = "WebApplication example",
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.Services.ConfigureWebhooker(new WebhookerOptions()
|
||||||
|
{
|
||||||
|
WebhookUri = "https://medic-gaming.com/",
|
||||||
|
DropPendingUpdates = true,
|
||||||
|
SecretToken = "MEDIC_GAMING"
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.AddTelegratorWeb(action: builder => builder.Handlers
|
||||||
|
.CollectHandlersAssemblyWide());
|
||||||
|
|
||||||
|
builder.Build()
|
||||||
|
.UseTelegratorWeb(dontMap: true)
|
||||||
|
.RemapWebhook("https://amazing-butt-sex.cloudpub.ru/")
|
||||||
|
.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,15 +9,26 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.7" />
|
||||||
<PackageReference Include="xunit" Version="2.6.6" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6" />
|
<PackageReference Include="xunit" Version="2.9.3" />
|
||||||
<PackageReference Include="Moq" Version="4.20.70" />
|
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
||||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Moq" Version="4.20.72" />
|
||||||
|
<PackageReference Include="FluentAssertions" Version="8.9.0" />
|
||||||
|
<PackageReference Include="coverlet.collector" Version="10.0.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\Telegartor.RedisStateStorage\Telegartor.RedisStateStorage.csproj" />
|
||||||
|
<ProjectReference Include="..\..\src\Telegrator.Hosting.Web\Telegrator.Hosting.Web.csproj" />
|
||||||
|
<ProjectReference Include="..\..\src\Telegrator.Hosting.WideBot\Telegrator.Hosting.WideBot.csproj" />
|
||||||
|
<ProjectReference Include="..\..\src\Telegrator.Localized\Telegrator.Localized.csproj" />
|
||||||
<ProjectReference Include="..\..\src\Telegrator\Telegrator.csproj" />
|
<ProjectReference Include="..\..\src\Telegrator\Telegrator.csproj" />
|
||||||
<ProjectReference Include="..\..\src\Telegrator.Hosting\Telegrator.Hosting.csproj" />
|
<ProjectReference Include="..\..\src\Telegrator.Hosting\Telegrator.Hosting.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -1,23 +1,21 @@
|
|||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Telegrator.Handlers;
|
using Telegrator.Handlers;
|
||||||
|
|
||||||
namespace Telegrator.Tests
|
namespace Telegrator.Tests;
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Вспомогательный класс для тестирования абстрактного UpdateHandlerBase.
|
|
||||||
///
|
|
||||||
/// ПРИНЦИП: Создание тестовых двойников для абстрактных классов
|
|
||||||
/// </summary>
|
|
||||||
[MessageHandler]
|
|
||||||
internal class TestUpdateHandler : MessageHandler
|
|
||||||
{
|
|
||||||
public bool WasExecuted { get; private set; }
|
|
||||||
|
|
||||||
public override Task<Result> Execute(IHandlerContainer<Message> container, CancellationToken cancellationToken)
|
/// <summary>
|
||||||
{
|
/// Вспомогательный класс для тестирования абстрактного UpdateHandlerBase.
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
/// ПРИНЦИП: Создание тестовых двойников для абстрактных классов
|
||||||
WasExecuted = true;
|
/// </summary>
|
||||||
return Task.FromResult(Result.Ok());
|
[MessageHandler]
|
||||||
}
|
internal class TestUpdateHandler : MessageHandler
|
||||||
|
{
|
||||||
|
public bool WasExecuted { get; private set; }
|
||||||
|
|
||||||
|
public override Task<Result> Execute(IHandlerContainer<Message> container, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
WasExecuted = true;
|
||||||
|
return Task.FromResult(Result.Ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user