diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f288702..0000000 --- a/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -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: - - Copyright (C) - 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 -. - - 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 -. diff --git a/README.md b/README.md deleted file mode 100644 index a1d0ac2..0000000 --- a/README.md +++ /dev/null @@ -1,191 +0,0 @@ -# ![ChatRD](https://i.imgur.com/Ifpd7Ay.png) - -ChatRD is a chat tool and/or overlay widget that unifies messages and events from **Twitch**, **YouTube**, **TikTok**, **Kick**, **Streamlabs**, **StreamElements**, **Patreon**, **TipeeeStream**, **Ko-Fi**, **Fourthwall** (and more to come). - -![ChatRD Config UI](https://i.imgur.com/zrP363q.png) - ---- - -## πŸš€ Features - -- πŸ’¬ **Multi-platform chat** -- πŸ’¬ **Multi-language events** -- πŸ“Š **Events and Live stats** -- 🎨 **Customizable** -- πŸ’Ύ **Saves your settings using localStorage and Streamer.Bot's Global Varaibles** - ---- - -## πŸ› οΈ Usage - -Make sure your **Twitch** and **YouTube** accounts are connected on **Streamer.Bot** and you have **TikFinity Desktop App** installed and set up to your account on **TikTok**. **BOTH APPS NEED TO RUN ON THE SAME PC**. - -### Streamer.Bot & TikFinity -1. On **Streamer.Bot**, go to **Server/Clients β†’ WebSocket Server** and make sure it is running -2. Import the string inside the file [streamerbot-import.vortisrd](https://github.com/vortisrd/chatrd/blob/main/streamerbot-import.vortisrd) to your **Streamer.Bot** using the **Import** button at the top. -3. Go to **Server/Clients β†’ WebSocket Client** and make sure the *TikFinity* WebSocket is connected. If not, right-click on it and check *Auto-Connect* and *Reconnect* before clicking on *Connect*. -4. Download [**TikFinity Desktop App**](https://tikfinity.zerody.one/) and make sure it's is opened and connected to your TikTok Account. -5. Open the [Settings Page](https://vortisrd.github.io/chatrd) in your browser. -6. Choose your desired options. -7. Click **"Copy URL"**. -8. Add the copied URL as a Browser Source in OBS. Or use it in your browser to read chat. 😊 -9. For **Streamlabs**, **StreamElements**, **Patreon**, **TipeeeStream**, **Ko-Fi** and **Fourthwall**, you need to connect them to your Streamer.Bot account to their website. Follow the tutorial links in each section presented in the [Settings Page](https://vortisrd.github.io/chatrd). - -### TikTok Chat Setup -To send messages to **TikTok** using the *Chat Field*, you need to the following on **TikFinity**: - -1. Make sure you're connected to your TikTok Account on **TikFinity**. If you're not, go to **Setup β†’ TikTok Login** and click on *Login to TikTok*. -2. Go to **Setup β†’ Streamer.Bot Connection** and type the IP and the PORT you're using on your **Streamer.Bot** and then click on *Test Connection*. - -![TikFinity Setup β†’ Streamer.Bot Connection](https://i.imgur.com/h0QDnNX.png) - -3. Go to **Chatbot β†’ Streamer.Bot Messages** and enable *Allow Streamer.Bot to push messages to TikFinity*. - -![Chatbot β†’ Streamer.Bot Messages](https://i.imgur.com/IGQ5xQq.png) - - -### Kick.Bot installation on Streamer.Bot - -1. First, [download Kick.Bot from Sehelitar's repo](https://github.com/Sehelitar/Kick.bot/releases/). -2. Unzip and copy the DLLs from **Kick.Bot** to the *dlls folder* inside **Streamer.Bot**. If it's not there, create one (name it "dlls", lowercase). -3. Import the action from *action.txt* file (inside the ZIP folder you just unzipped) to **Streamer.Bot**. -4. Close **Streamer.Bot** and open it again. After a few seconds, a window will appear asking you to login on *Kick*. -5. Done! 😊 - -If **Kick.Bot** stops sending events to ChatRD, delete it's dlls in the *dlls folder*, delete the imported **Kick.Bot** action and delete the *Streamer.bot.exe.WebView2* folder. After that, reinstall **Kick.Bot** using the above instructions. - - -#### ⚠️ KICK IS A BETA FEATURE! -Kick doesn't offer an API like Twitch does. It's not feasible for Streamer.Bot do it in an easy manner like Twitch, YouTube, Trovo, etc. - -[Kick.Bot](https://github.com/Sehelitar/Kick.bot/releases/) does an excelent job but there is some information missing on the payload from Kick, like *avatars*, *badges (gift sub, community, etc), viewership, etc*. And there will be some errors or some misinformation being shown. I tried my best to emulate these. - -I couldn't test every single outcome because it's not possible to simulate the events besides Chat. I followed [Kick.Bot's](https://github.com/Sehelitar/Kick.bot/releases/) documentation and hoped for the best. πŸ™ - -Also, at any point either **Kick** or **Kick.Bot** might change their stuff, so please, **be patient!** 😊 - - ---- - -## πŸ”Š How to set TTS with Speaker.Bot - -### Speaker.Bot Setup -1. Go to **Settings β†’ WebSocket Server**, click on *Start Server*. Make sure to also tick the *Auto-Start* checkbox. -2. Go to **Settings β†’ Speech Engine** and add the TTS Service of your preference. (Sapi5 is the Windows default). -3. Go to **Settings β†’ Voice Aliases**, name the voice *SpeakerBot* and click **Add** right next to it. -4. In the Left Column, click on the **SpeakerBot** you just added and on the **Speak!** section, select the voice you want to use and click **Add**. (If you're using Sapi5, I recommend using *Microsoft Zira Desktop* as a voice). - -### Streamer.Bot Setup -1. Import the [streamerbot-import.vortisrd](https://github.com/vortisrd/chatrd/blob/main/streamerbot-import.vortisrd) file to your **Streamer.Bot**. There's a new action that will handle the **Speaker.Bot** integration. -2. Go to **Integrations β†’ Speaker.Bot**, click on *Connect*. Make sure to also tick the *Auto-Start* and *Auto-Connect* checkboxes. - ---- - -## πŸ’» Commands supported by the Chat Field - -**Commands for Twitch** -- /me (message) -- /announce (message) -- /clear -- /slow (duration in seconds) -- /slowoff -- /subscribers -- /subscribersoff -- /commercial (duration in seconds) -- /timeout (user) (duration) (reason) -- /untimeout (user) -- /ban (user) (reason) -- /unban (user) -- /mod (user) -- /unmod (user) -- /vip (user) -- /unvip (user) -- /shoutout (user) -- /raid (user) -- /unraid - -**Commands for YouTube** -- /yt/title (title) -- /yt/description (description) -- /yt/timeout (userID) (duration in seconds) -- /yt/ban (userID) - -**TikTok** -- TikTok commands are not supported yet. - -**Kick** -- Kick commands are not supported yet. - ---- - -## πŸ“ To-Do List - -- Trovo -- LivePix -- Tipa.Ai - ---- - -## ❓ Frequently Asked Questions -**- Can I use it to read my chat?** -R: Yes you can. You can open it on your browser, use it as a chat overlay and use it as a dock in OBS. - -**- What about YouTube Members Emotes?** -R: YouTube doesn't expose their Partner Emojis to Streamer.Bot. All you can do is add the emojis manually in ChatRD. Please [read this](https://github.com/vortisrd/chatrd#about-youtube-membership-emojis). - -**- Can I set TTS to read only the events I want to read?** -R: ChatRD only reads either chats, events or both. If you want to filter the events, [I suggest you setup Speaker.Bot separately](https://github.com/vortisrd/chatrd?tab=readme-ov-file#about-speakerbot-tts-customization). - -**- TikTok events are not working anymore, what should I do?** -R: Make sure your TikFinity is connected to your account and you are live. Also go to **Server/Clients β†’ WebSocket Client** and make sure the TikFinity WebSocket is connected. [Instructions here](https://github.com/vortisrd/chatrd#streamerbot--tikfinity). - -**- Kick events are not working anymore, what should I do?** -R: Try reinstalling Kick.Bot [using the following methods](https://github.com/vortisrd/chatrd?tab=readme-ov-file#kickbot-installation-on-streamerbot). - -**- Where are my Kick sub badges? And the X or Y badges?** -R: At the moment of this post, the WebSocket I connect to show Kick's chat doesn't expose the Badges like Twitch does. Twitch mentions the badges and sends the URL, showing it [like this](https://i.imgur.com/xwg39hO.png). **Kick doesn't, showing on code [like this](https://i.imgur.com/OtMcDzI.png)**. You can see the person is subscribed and it's a sub gifter, but it doesn't show the specified badges. I did the best I could with the other badges. When Kick improves their API, I will revisit this later. - -**- Can you add other streaming/payment platforms?** -R: ChatRD uses Streamer.Bot to 95% of all platform iterations. *TikFinity* is perfectly integrated via WebSockets and *Kick.Bot* adds a decent integration. So if the platform has a decent WebSocket API (not WebHooks, those need a server to be usable) and/or has any integration with Streamer.Bot, please feel free to suggest it. Other than that, there are no plans to add more platforms. - -**- Can I customize it?** -R: If you mean visual styles, yes. [Read here](https://github.com/vortisrd/chatrd?tab=readme-ov-file#about-custom-styling). - - - ---- - -## **⚠️ DISCLAIMERS ⚠️** - -### About YouTube Membership Emojis -I tried to add member emotes but **that is currently impossible due to YouTube's API not exposing Members Emotes and with that, Streamer.Bot won't be able to show them.**. So I've added a way for the users to add them manually at the overlay, with the data saved as a Streamer.Bot Global Variable. - -What Casterlabs Caffeinated, Social Stream Ninja and Onecomme do to scrape the emotes won't work with the current way Streamer.Bot and my code works, so I had to choose between **making the user add them manually** or build a **server-sided executable (using NodeJS, Python or whatever) to read the chat as it's going or scrape the HTML code**. I don't want to add another executable on top of the user's flow, so it would be easier to use what it's currently available. **And no, I won't do any research based on what other tools do.** Tried to do that and wasted 1 week of my life doing it. - -When YouTube decide to expose their Partner Emotes on their API, I'll come back to this. - -### About Speaker.Bot TTS Customization -If you want to customize what events the TTS reads, like "I want it to read sub notifications but I don't want it to read bits", it's possible. But doing that means adding an extra TTS switch for every single event for all platforms, making the setup page almost triplicate in size and bloat the code. **I won't do that**. I want to keep it simple and contained. - -If you want to have TTS for events separately, I suggest you **Disable TTS Events** on ChatRD and setup Speaker.Bot with the things you want. 😊 - -### About Custom Styling -The safest way to customize ChatRD is open either the Chat or the Config in your browser and use [it's Dev Tools](https://i.imgur.com/Nirwz5R.png) to look for the tags, their classes, identifiers and then style in the way you want. **You need basic CSS knowledge for that**. - -After you finish it, paste the CSS inside the [Custom CSS field within Browser Source Property Window](https://i.imgur.com/BjvrV28.png). - -### About Support on Changing the Javascript or other Core Files -If you break it, you fix it. 😊 - - ---- - -## ✨ Credits - -Made with ❀️ by **VortisRD** - -πŸ”— [GitHub](https://github.com/vortisrd) β€’ [Twitch](https://twitch.tv/vortisrd) β€’ [YouTube](https://youtube.com/@vortisrd) β€’ [TikTok](https://tiktok.com/@vortisrd) β€’ [Kick](https://kick.com/vortisrd) β€’ [Twitter / X](https://twitter.com/vortisrd) - -Heavily inspired by [Nutty](https://nutty.gg) - -πŸ”— [GitHub](https://github.com/nuttylmao) β€’ [Twitch](https://twitch.tv/nutty) β€’ [YouTube](https://youtube.com/@nuttylmao) β€’ [TikTok](https://tiktok.com/@nuttylmao) β€’ [Twitter / X](https://x.com/nuttylmao) diff --git a/chat.html b/chat.html index 4c5c515..7a57356 100644 --- a/chat.html +++ b/chat.html @@ -5,110 +5,132 @@ ChatRD - - - - + + + - + + + + +
- + 0
- + 0
- + 0
- - - - + 0
- -
- +
-
+
- + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + - + \ No newline at end of file diff --git a/css/app.css b/css/app.css deleted file mode 100644 index c90e790..0000000 --- a/css/app.css +++ /dev/null @@ -1,871 +0,0 @@ -/* Basic reset and styling */ -* { - margin: 0; - padding: 0; - box-sizing: border-box; -} - -.sn-notify-outline { --sn-notify-background-color: #27272a; } -.sn-notify-outline .sn-notify-title { --sn-notify-title-color: #FFFFFF; } -.sn-notify-outline .sn-notify-text { --sn-notify-text-color: rgba(255,255,255,0.5); } - -/* Full-page container styling */ -html { - width: 100vw; - height: 100vh; - font-family: "Inter", sans-serif; - scroll-behavior: smooth; - overflow-wrap: break-word; -} - - -body { - height: 100%; - overflow: hidden; -} - - -#container { - height: 100%; - display: flex; - flex-direction: column; -} -.wrapper { - flex: 1; - display: flex; - flex-direction: column; - overflow: hidden; -} -#chat { - flex: 1; - display: flex; - flex-direction: column-reverse; /* conteΓΊdo comeΓ§a no fundo */ - overflow-y: auto; - padding: 10px; - scrollbar-color: #555 #1e1e1e; -} - -#chat.noscrollbar { - overflow-y: hidden; -} - -#chat::-webkit-scrollbar { width: 8px; } -#chat::-webkit-scrollbar-track { background: #1e1e1e; } -#chat::-webkit-scrollbar-thumb { background-color: #555; border-radius: 4px; border: 2px solid #1e1e1e; } -#chat::-webkit-scrollbar-thumb:hover { background-color: #777; } - - - - - -#chat .message { - position: relative; - color: #FFF; - font-size: 18px; - line-height: 150%; - text-shadow: 2px 2px 2px rgba(0,0,0,0.75); - transition: all ease-in-out 300ms; - margin: 5px 0; - padding-bottom: 4px; - border-radius: 5px; -} - -#chat .message:not(.event):hover { - background: #1a1a1a; -} - -#chat .message img { - height: 22px; - vertical-align: middle; -} - -#chat .message.bigger-emojis img.emote { - height: 32px; -} - -#chat .message .text img.gigantify { - height: 84px !important; - display: block; - margin: 10px 0 5px 0; -} - -#chat .message .user { font-weight: bold; } - -#chat .message .user .pronouns { - font-style: normal; - font-weight: normal; - font-size: 12px; - color: #FFF; - background: rgba(0,0,0,0.5); - - - margin: 0 5px; - padding: 5px 7px; - - border-radius: 5px; -} - -#chat .message .time { - display: inline-block; - background: rgba(0,0,0,0.5); - font-size: 12px; - padding: 0px 10px; - border-radius: 5px; -} - -#chat .message .avatar { - display: inline-block; - position: relative; - margin: 2px 0px; - width: 28px; - height: 28px; - overflow: hidden; - border-radius: 100px; - transform: translateY(11px); -} - -#chat .message .avatar img { - position: absolute; - top: 0; - left: 50%; - transform: translateX(-50%); - height: 28px; -} - -#chat .message .platform { - display: inline-flex; - justify-content: center; - align-items: center; - width: 24px; - height: 24px; - filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.25)); - transform: translateY(6px); -} - -#chat .message .badges i { - display: inline-flex; - justify-content: center; - align-items: center; - background: #000; - width: 24px; - height: 24px; - font-size: 12px; - border-radius: 5px; - margin: 0 5px 0 0; - text-shadow: 2px 2px 2px rgba(0,0,0,0.25); -} - -#chat .message .reply { - max-width: 100%; - flex-basis: 100%; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - display: block; - - font-size: 14px; - color: #999; -} - -#chat .message .reply i { - transform: rotate(90deg); - margin: 0 5px; -} - - -#chat .message .shared { - max-width: 100%; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - display: block; - text-shadow: none; - font-size: 14px; - margin: 10px 0 -5px 0; - color: #999; -} - -#chat .message .shared i { - margin: 0 3px; -} - - -#chat .message.event { - text-shadow: 2px 2px 2px rgba(0,0,0,0.25); - font-size: 16px; -} - - -#chat .message.event .platform { - transform: translateY(0px); - margin: 0px 5px 0 0; -} - -#chat .message.event > div { - padding: 5px 15px 5px 5px; - margin: 2px 0 0 0; - border-radius: 5px; - background: rgba(0,0,0,0.15); - display: inline-flex; - align-items: flex-start; -} - -#chat .message:not(.event) > div { - margin-top: -10px; -} - - -#chat .message.twitch .shared span { - display: inline-block; - border-radius: 5px; - padding: 2px 10px 2px 5px; - background: rgba(169,112,255,0.85); - background: linear-gradient(180deg, rgba(169,112,255,0.85) 0%, rgba(95,67,138,0.85) 100%); - color: #fff; -} - - -#chat .message.twitch.first-message > div { - background: rgba(18,18,18,0.5); - background: linear-gradient(180deg, rgba(18,18,18,0.5) 1%, rgba(0,0,0,0.5) 100%); - padding: 0px 15px 13px 15px; - border-radius: 10px; - display: inline-block; -} - -#chat .message.twitch.first-message > div .first-chatter { - display: inline-block; -} - - -#chat .message.twitch .badges img { margin: 0 2px; } -#chat .message.twitch.event > div { - background: rgba(169,112,255,0.85); - background: linear-gradient(180deg, rgba(169,112,255,0.85) 0%, rgba(95,67,138,0.85) 100%); -} - -#chat .message.twitch.announcement > div { - padding: 10px 15px 13px 10px; - display: inline-block; - border-bottom: 2px solid #ffcc00; - background: rgba(18,18,18,0.85); - background: linear-gradient(180deg, rgba(18,18,18,0.85) 1%, rgba(0,0,0,0.85) 100%); -} - -#chat .message.twitch.announcement .reply { - padding: 2px; - color: #ffcc00; -} - -#chat .message.twitch.announcement .reply i { - transform: rotate(0deg); -} - -#chat .message.twitch.announcement .platform { - transform: translateY(6px); - margin: 0; -} - -#chat .message.twitch.rewards-redemption > div { - padding: 10px 15px 13px 10px; - display: inline-block; - border-bottom: 2px solid #ffcc00; - background: rgba(18,18,18,0.85); - background: linear-gradient(180deg, rgba(18,18,18,0.85) 1%, rgba(0,0,0,0.85) 100%); -} -#chat .message.twitch.rewards-redemption .reply { - padding: 2px; - color: #FFF; -} - -#chat .message.twitch.rewards-redemption .reply i { - transform: rotate(0deg); - color: #ffcc00; -} - -#chat .message.twitch.rewards-redemption .platform { - transform: translateY(6px); - margin: 0; -} - - - - - - - -#chat .message.youtube.event .platform { color: #FFF; } -#chat .message.youtube.event > div { - background: rgba(255,0,0,0.85); - background: linear-gradient(180deg, rgba(255,0,0,0.85) 1%, rgba(136,0,0,0.85) 100%); -} - - -#chat .message.youtube.owner .user { - background: #ffd600; - color: #121212 !important; - border-radius: 5px; - padding: 2px 5px; - margin-right: 5px; - text-shadow: 2px 2px 2px rgba(0,0,0,0); -} - -#chat .message.youtube.owner .badges i.fa-solid.fa-video { background: #ff0000 } - -#chat .message.youtube.mod .user { color: #5e84f1 !important; } -#chat .message.youtube.mod .badges i.fa-solid.fa-wrench { background: #5e84f1 } - -#chat .message.youtube.sub .user { color: #2ba640 !important; } -#chat .message.youtube.sub .badges i.fa-solid.fa-star { background: #2ba640; } - -#chat .message.youtube .badges i.fa-solid.fa-check { background: #999; } - - -#chat .message.youtube.event.supersticker > div .platform { order: 1; } -#chat .message.youtube.event.supersticker > div .sticker { - order: 2; - width: 48px; - height: 48px; - filter: drop-shadow(0px 0px 6px rgba(0,0,0,1)); - padding: 5px 10px 5px 0; -} -#chat .message.youtube.event.supersticker > div .sticker img { - width: 100%; - height: 100%; -} -#chat .message.youtube.event.supersticker > div .info { order: 3; } -#chat .message.youtube.event.supersticker.giantsupersticker > div { - flex-wrap: wrap; -} -#chat .message.youtube.event.supersticker.giantsupersticker > div .platform { order: 2; } -#chat .message.youtube.event.supersticker.giantsupersticker > div .sticker { - order: 1; - flex: 0 0 100%; - height: 148px; - text-align: center; - margin: 10px 0; -} -#chat .message.youtube.event.supersticker.giantsupersticker > div .sticker img { - width: 148px; - height: 148px; -} -#chat .message.youtube.event.supersticker.giantsupersticker > div .info { order: 3; } - - - -#chat .message.streamlabs.event > div { - background: rgba(128,245,210,0.85); - background: linear-gradient(180deg, rgba(128,245,210,0.85) 1%, rgba(8,108,78,0.85) 100%); -} - - - -#chat .message.streamelements.event > div { - background: rgba(39,0,255,0.85); - background: linear-gradient(180deg, rgba(39,0,255,0.85) 1%, rgba(13,0,88,0.85) 100%); -} - - - - - -#chat .message.tiktok.event > div { - background: rgba(255,0,80,0.85); - background: linear-gradient(180deg, rgba(255,0,80,0.85) 1%, rgba(120,0,38,0.85) 100%); -} - -#chat .message.tiktok.mod .badges i.fa-solid.fa-wrench { - background: #121212; -} - - - - - - - - - -#chat .message.kick .badges svg { - width: 20px; - transform: translateY(4px); -} - -#chat .message.kick .badges i.sub { - margin: 0; - color: #48d415; -} - -#chat .message.kick.event > div { - background: #48d415; - background: linear-gradient(180deg,rgba(72, 212, 21, 1) 0%, rgba(39, 145, 0, 1) 100%); -} - - - - - - - -#chat .message.patreon.event > div { - background: #ff5900; - background: linear-gradient(180deg,rgba(255, 89, 0, 1) 0%, rgba(199, 70, 0, 1) 100%); -} - - - - - - - -#chat .message.tipeeestream.event > div { - background: #E02F44; - background: linear-gradient(180deg,rgba(224, 47, 68, 1) 0%, rgba(140, 35, 47, 1) 100%); -} - - - - - - - -#chat .message.kofi.event > div { - background: #72A5F2; - background: linear-gradient(180deg,rgba(114, 165, 242, 1) 0%, rgba(81, 115, 166, 1) 100%); -} - - - - - - - - -#chat .message.fourthwall.event.order > div .platform { order: 1; } -#chat .message.fourthwall.event.order > div .image { - order: 2; - width: max-content; - height: 72px; - filter: drop-shadow(0px 0px 6px rgba(0,0,0,0.25)); - padding: 5px 10px 5px 0; -} -#chat .message.fourthwall.event.order > div .image img { - width: max-content; - height: 100%; - border-radius: 5px; -} -#chat .message.fourthwall.event.order > div .info { order: 3; } -#chat .message.fourthwall.event.order.giantimage > div { - flex-wrap: wrap; -} -#chat .message.fourthwall.event.order.giantimage > div .platform { order: 2; } -#chat .message.fourthwall.event.order.giantimage > div .image { - order: 1; - flex: 0 0 100%; - height: 202px; - text-align: center; - margin: 10px 0; -} -#chat .message.fourthwall.event.order.giantimage > div .image img { - width: max-content; - height: 192px; -} -#chat .message.fourthwall.event.order.giantimage > div .info { order: 3; } - -#chat .message.fourthwall.event > div { - background: #0044ff; - background: linear-gradient(180deg,rgba(0, 68, 255, 1) 0%, rgba(0, 47, 176, 1) 100%); -} - - - - - -.wrapper.horizontal { - align-items: flex-end; -} - -.wrapper.horizontal #chat { - flex-direction: row-reverse; - align-items: flex-end; - gap: 15px; - width: max-content; -} - -.wrapper.horizontal #chat .message { - width: 0; - white-space: nowrap -} - -.wrapper.horizontal #chat .message > div { - width: fit-content; -} - - - - -#chat .message.twitch:hover .chatmoderation.twitch { - display: block; -} - -#chat .message .chatmoderation { - display: none; - position: absolute; - top: 0; - right: 0; - padding: 2px 3px; - background: #262626; - border-radius: 5px; - transition: all ease-in-out 300ms; -} - -#chat .message .chatmoderation button { - background: none; - border: none; - color: #FFF; - cursor: pointer; - font-size: 18px; - padding: 5px; - transition: all ease-in-out 300ms; - margin: 0 3px; -} - -#chat .message .chatmoderation { - color: #ffcc00; -} - -#chat .message.twitch:hover .chatmoderation.twitch { - display: block; -} - -#chat .message.youtube:hover .chatmoderation.youtube { - display: block; -} - - -#chat .message.streamer .chatmoderation button:nth-child(2), -#chat .message.streamer .chatmoderation button:nth-child(3), -#chat .message.owner .chatmoderation { - display: none; -} - - - -#chat-input { - padding: 15px 10px; - position: relative; - display: none; -} - -#chat-input.enabled { - display: block; - width: 100%; -} - -#chat-input input[type=text] { - font-family: "Inter", sans-serif; - border: none; - background: #222; - color: #FFF; - padding: 10px 90px 10px 15px; - border-radius: 10px; - outline: none; - font-size: 16px; - width: 100%; - transition: all ease-in-out 300ms; -} - -#chat-input button { - background: none; - border: none; - color: #FFF; - cursor: pointer; - font-size: 18px; - padding: 5px; - - position: absolute; - top: 50%; - transform: translateY(-50%); -} - -#chat-input button.active, -#chat-input button:hover { - color: #ffcc00; -} - -#chat-input #chat-input-settings i { - transition: all ease-in-out 300ms; -} - -#chat-input #chat-input-send { - right: 60px; -} - -#chat-input #chat-input-settings { - right: 20px; -} - -#chat-input #chat-input-settings.active i { - transform: rotate(60deg); -} - -#chat-input .settings { - display: none; - background: #0c0c0c; - padding: 5px 10px; - border-radius: 100px; - - position: absolute; - top: -40px; - right: 0px; - z-index: 11; - - box-shadow: 0 0 10px rgba(255,255,255,0.05) -} - -#chat-input .settings.active { - display: inline-block; -} - -#chat-input .settings::after { - content: ""; - position: absolute; - bottom: -10px; /* posiciona fora do balΓ£o */ - right: 25px; /* onde a pontinha aparece horizontalmente */ - width: 0; - height: 0; - border-left: 10px solid transparent; - border-right: 10px solid transparent; - border-top: 10px solid #0c0c0c; /* mesma cor do balΓ£o */ -} - -#chat-input .settings img { - width: 20px; -} - - -#chat-input .chat-enabler { - display: inline-flex; - padding: 5px; - gap: 5px; - color: #FFF; - font-size: 14px; - align-items: center; - color: #333; -} - -#chat-input .settings .switch { - position: relative; - display: inline-block; - width: 40px; - height: 20px; -} - -#chat-input .settings .hint { - color: #FFF; - font-size: 18px; -} - -#chat-input .settings .hint a { - color: #ffcc00; - font-weight: bold; -} - -/* Hide default HTML checkbox */ -#chat-input .settings .switch input[type=checkbox] { - opacity: 1; - width: 0; - height: 0; -} - -/* The slider */ -#chat-input .settings .slider { - position: absolute; - cursor: pointer; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: #CCC; - transition: .4s; - border-radius: 30px; -} - -#chat-input .settings .slider:before { - position: absolute; - content: ""; - height: 16px; - width: 16px; - border-radius: 16px; - left: 3px; - top: 2px; - bottom: 0; - background-color: white; - transition: .4s; -} - -#chat-input .settings input[type=checkbox]:checked + .slider:before { - transform: translateX(19px); -} - -#chat-input #twitch input[type=checkbox]:checked + .slider { - background-color: #a970ff; -} -#chat-input #youtube input[type=checkbox]:checked + .slider { - background-color: #FF0000; -} -#chat-input #tiktok input[type=checkbox]:checked + .slider { - background-color: #ff0050; -} -#chat-input #kick input[type=checkbox]:checked + .slider { - background-color: #48d415; -} - - -#chat-input .settings input[type=checkbox]:checked + .slider { - background-color: #03c4de; -} -#chat-input .setting input[type=checkbox]:disabled + .slider { - background-color: #000 !important; -} - - - - -#chat-autocomplete-list { - position: absolute; - bottom: 65px; - left: 10px; - width: calc(100% - 40px); - border-radius: 10px; - background: #222; - color: #FFF; - - max-height: 300px; - overflow: hidden; - overflow-y: visible; - - font-size: 14px;; - - color: #696969; -} - -#chat-autocomplete-list::-webkit-scrollbar { width: 10px; } -#chat-autocomplete-list::-webkit-scrollbar-track { background: #1e1e1e; } -#chat-autocomplete-list::-webkit-scrollbar-thumb { background-color: #555; border-radius: 10px; border: 2px solid #1e1e1e; } -#chat-autocomplete-list::-webkit-scrollbar-thumb:hover { background-color: #777; } - -#chat-autocomplete-list div { - margin: 5px 10px; - padding: 5px; - border-radius: 5px; - cursor: pointer; -} - -#chat-autocomplete-list div.autocomplete-item { - cursor: pointer; -} - -#chat-autocomplete-list div:not(.autocomplete-item) { - background: #191919; - color: #FFF; - padding: 10px; - margin: 10px; -} - -#chat-autocomplete-list .autocomplete-item strong { - display: block; -} - -#chat-autocomplete-list .autocomplete-item:hover, -#chat-autocomplete-list .autocomplete-item.active { - color: #FFF; - background: #292929; -} - -#chat-autocomplete-list .autocomplete-item small { - color: #666; -} - - -#statistics { - position: fixed; - z-index: 11; - width: 100%; - top: 0; left: 0; - padding: 10px; - font-size: 14px; - display: flex; - gap: 15px; - justify-content: flex-end; - backdrop-filter: blur(5px); - font-weight: bold; - -webkit-mask-image: linear-gradient(to top, transparent, black 40%); - mask-image: linear-gradient(to top, transparent, black 40%); - text-shadow: 2px 2px 2px rgba(0,0,0,0.25); -} - - -#statistics .platform { - background: #000; - color: #FFF; - padding: 5px 10px; - border-radius: 100px; - - display: flex; - flex-direction: row; - align-items: center; - flex-wrap: nowrap; -} - -#statistics .platform i.fa-brands { - margin-right: 5px; -} - -#statistics .platform > span { - display: inline-block; - margin: 0 5px; -} - -#statistics .platform#twitch { - background: #a970ff; -} - -#statistics .platform#youtube { - background: #FF0000; -} - -#statistics .platform#tiktok { - background: #ff0050; -} - -#statistics .platform#kick { - background: #48d415; -} - -#statistics .platform#kick svg { - width: 24px; - fill: #FFF; - filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.25)); -} - -@media (max-width: 768px) { - #statistics { - - justify-content: center; - font-size: 12px; - gap: 5px; - text-shadow: 2px 2px 2px rgba(0,0,0,0.5); - } - - #statistics .platform { - padding: 5px 10px; - text-align: center; - } - - - #statistics .platform#kick svg { - width: 18px; - filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.5)); - } -} diff --git a/css/chatrd.css b/css/chatrd.css new file mode 100644 index 0000000..26ce4cd --- /dev/null +++ b/css/chatrd.css @@ -0,0 +1,61 @@ +/* Basic reset and styling */ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +.sn-notify-outline { --sn-notify-background-color: #27272a; } +.sn-notify-outline .sn-notify-title { --sn-notify-title-color: #FFFFFF; } +.sn-notify-outline .sn-notify-text { --sn-notify-text-color: rgba(255,255,255,0.5); } + +.sn-notify-outline { --sn-notify-background-color: #27272a; } +.sn-notify-outline .sn-notify-title { --sn-notify-title-color: #FFFFFF; } +.sn-notify-outline .sn-notify-text { --sn-notify-text-color: rgba(255,255,255,0.5); } + +/* Full-page container styling */ +html { + width: 100vw; + height: 100vh; + font-family: "Inter", sans-serif; + scroll-behavior: smooth; + overflow-wrap: break-word; +} + + +body { + height: 100%; + overflow: hidden; +} + + +#container { + height: 100%; + display: flex; + flex-direction: column; +} + +#container .wrapper { + flex: 1; + display: flex; + flex-direction: column; + overflow: hidden; +} + +#chat { + flex: 1; + display: flex; + flex-direction: column-reverse; + overflow-y: auto; + padding: 10px; + scrollbar-color: #555 #1e1e1e; +} + +#chat.noscrollbar { + overflow-y: hidden; +} + +#chat::-webkit-scrollbar { width: 8px; } +#chat::-webkit-scrollbar-track { background: #1e1e1e; } +#chat::-webkit-scrollbar-thumb { background-color: #555; border-radius: 4px; border: 2px solid #1e1e1e; } +#chat::-webkit-scrollbar-thumb:hover { background-color: #777; } \ No newline at end of file diff --git a/css/settings.css b/css/settings.css deleted file mode 100644 index 18fe4a4..0000000 --- a/css/settings.css +++ /dev/null @@ -1,580 +0,0 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box; -} - -body { - font-family: "Inter", sans-serif; - scroll-behavior: smooth; - overflow-wrap: break-word; - background-color: #121212; - color: #FFF; - text-align: center; - font-size: 16px; -} - -a { color: #ffcc00; } - -hr { - border: 1px solid #222; - margin: 20px 0; -} - -h2 { - font-size: 20px; - padding: 15px 30px; - border-bottom: 1px solid #222; - margin: 15px 0 0 0; - text-align: left; - position: relative; -} - -h2 i { - margin-right: 5px; -} - -h2 svg { - width: 26px; - vertical-align: bottom; - fill: #FFF; -} - -h2 img { - width: 26px; - vertical-align: bottom; -} - -h2 button { - display: none; - - position: absolute; - top: 50%; - right: 0; - transform: translateY(-50%); - - border: none; - background: black; - text-align: center; - color: #FFF; - cursor: pointer; - - font-size: 16px; - padding: 10px; - border-radius: 100px; -} - -h2 button i { - margin: 0; - transition: transform 0.3s ease; -} - - -.accordion-container { - /*max-height: 0; - overflow: hidden;*/ - transition: max-height 0.4s ease; -} - - - -#chat-divided { - display: flex; - flex-direction: row; - flex-wrap: nowrap; - gap: 30px; - padding: 30px; -} - -#chat-settings { width: 640px; } -#chat-preview { width: calc(100% - 640px); } - -#chat-settings h1 { - width: 200px; - height: 80px; - background: url('../images/logo-chatrd.png') center center no-repeat; - background-size: cover; - margin: auto; - text-indent: -9999px; -} - -#chat-preview iframe { - position: sticky; - top: 30px; - left: 0; - width: 100%; - height: calc(100vh - 60px); -} - -.url-bar { - margin: 0 0 20px 0; - font-size: 16px; -} - -.url-bar input[type=text] { - display: none; -} - - -.url-bar button { - font-family: "Inter", sans-serif; - font-weight: bold; - border: none; - padding: 15px 30px; - margin-top: 10px; - border-radius: 10px; - cursor: pointer; - background: #252525; - color: #FFF; - transition: .4s; - width: 100%; - font-size: 14px; -} - -.url-bar button:hover { - background: #292929; -} - -.tab-content { - border-radius: 0 0 20px 20px; - background: #171717; - margin: 0 auto; - text-align: left; - margin: 0 0 30px 0; -} - -.tab-content .wrapper { - padding: 20px 30px; -} - -/* When visible */ -.tab-content.open { - display: block; -} - -.tab-content .setting { - display: flex; - justify-content: space-between; - padding: 5px 0px; - flex-direction: row; - flex-wrap: nowrap; - align-items: center; -} - -.tab-content .setting.column { - flex-direction: column; -} - -.tab-content .setting.column label { - width: 100%; -} - -.tab-content .setting.column .emote-list { - width:100%; - display: flex; - flex-wrap: wrap; /* allow items to wrap */ - gap: 10px; - margin-top: 15px; -} - -.tab-content .setting.column .emote-list .emote-item { - width: 96px; - height: 96px; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - position: relative; - background: #222; - border-radius: 10px; -} - -.tab-content .setting.column .emote-list .emote-item button { - position: absolute; - top: 0; - right: 0; - width: 36px; - height: 36px; - - border-radius: 10px; - - transition: .4s; - - text-align: center; - background: none; - border: none; - cursor: pointer; -} - -.tab-content .setting.column .emote-list .emote-item button.add { - top: 50%; - left: 50%; - right: unset; - - transform: translate(-50%,-50%); - - width: 100%; - height: 100%; - font-size: 36px; -} - -.tab-content .setting.column .emote-list .emote-item button.add:hover { - background-color: #333; -} - -.tab-content .setting.column .emote-list .emote-item button.add i { - vertical-align: middle; -} - - -.tab-content .setting.column .emote-list .emote-item em { - display: block; - margin-top: 5px; - font-size: 9px; -} - -.tab-content .setting.column .emote-list .emote-item img { - height: 24px; -} - - -.tab-content .setting i { - font-size: 14px; - color: #666; - margin: 0 10px; -} - -.tab-content .setting i.fa-arrow-turn-up { - transform: rotate(90deg); -} - - -.tab-content .setting small { color: #777; } - -.tab-content .setting input[type=text], -.tab-content .setting input[type=number], -.tab-content .setting textarea { - font-family: "Inter", sans-serif; - border: none; - background:#222; - color: #FFF; - padding: 10px 20px; - border-radius: 10px; - outline: none; -} - -.tab-content .setting textarea { - width: 100%; - height: 200px; - margin-top: 15px; -} - -.tab-content .setting.select select { - font-family: "Inter", sans-serif; - border: none; - background:#222; - color: #FFF; - padding: 10px 20px 10px 10px; - border-radius: 10px; - outline: none; -} - -.tab-content .setting .switch { - position: relative; - display: inline-block; - width: 50px; - height: 27px; -} - -/* Hide default HTML checkbox */ -.tab-content .setting .switch input[type=checkbox] { - opacity: 1; - width: 0; - height: 0; -} - -/* The slider */ -.tab-content .setting .slider { - position: absolute; - cursor: pointer; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: #CCC; - transition: .4s; - border-radius: 30px; -} - -.tab-content .setting .slider:before { - position: absolute; - content: ""; - height: 1.3em; - width: 1.2em; - border-radius: 16px; - left: 5px; - top: 3px; - bottom: 0; - background-color: white; - transition: .4s; -} - - - -.tab-content .setting input[type=color] { - background: #111; - padding: 0 2px; -} - -.tab-content .setting input[type=checkbox]:checked + .slider { - background-color: #03c4de; -} - -.tab-content .setting input[type=checkbox]:checked + .slider:before { - transform: translateX(1.4em); -} - -.tab-content#twitch .setting input[type=checkbox]:checked + .slider { - background-color: #a970ff; -} -.tab-content#youtube .setting input[type=checkbox]:checked + .slider { - background-color: #FF0000; -} -.tab-content#tiktok .setting input[type=checkbox]:checked + .slider { - background-color: #ff0050; -} - -.tab-content#kick .setting input[type=checkbox]:checked + .slider { - background-color: #48d415; -} - -.tab-content#extras .setting input[type=checkbox]:checked + .slider { - background-color: #00dd63; -} - -.tab-content#patreon .setting input[type=checkbox]:checked + .slider { - background-color: #ff5900; -} - -.tab-content#tipeee .setting input[type=checkbox]:checked + .slider { - background-color: #e02f44; -} - -.tab-content#kofi .setting input[type=checkbox]:checked + .slider { - background-color: #72a5f2; -} - -.tab-content#fourthwall .setting input[type=checkbox]:checked + .slider { - background-color: #0042ff; -} - -.tab-content .setting input[type=checkbox]:disabled + .slider { - background-color: #000 !important; -} - - - - -.slider-value { - display: inline-block; - font-style: normal; - font-size: 14px; - width: 100%; - padding: 5px; - background: #121212; - text-align: center; - border-radius: 100px; -} - - -footer { - position: sticky; - bottom: 0; - padding: 20px; - background: rgba(18,18,18,0.5); - backdrop-filter: blur(10px); - margin-top: 80px; - font-size: 14px; -} - -footer a { - display: inline-block; - margin: 10px 5px; - font-size: 20px; - color: #ffcc00; -} - -footer a svg { - width: 24px; - vertical-align: bottom; - fill: #ffcc00; -} - -footer a img { - width: 24px; - vertical-align: bottom; -} - -footer .nav-bar { - display: inline-flex; - flex-direction: row; - align-items: center; - justify-content: center; - font-size: 12px; - - width: 100%; -} - -footer .nav-bar a { - display: inline-block; - border-radius: 100px; - padding: 10px 15px; - margin: 0; - font-size: 16px; - text-decoration: none; - color: #FFF; - transition: all ease-in-out 300ms; -} - -footer .nav-bar a:hover { - color: #ffcc00; - background: rgba(0,0,0,0.40); -} - -footer .nav-bar a svg { - width: 20px; - fill: #FFF; - transition: all ease-in-out 300ms; -} - -footer .nav-bar a:hover svg { - fill: #ffcc00; -} - - -footer .nav-bar a.active { - color: #ffcc00; - background: rgba(0,0,0,0.20); -} - -footer .nav-bar a.active svg { - fill: #ffcc00; -} - -@media only screen and (max-width: 768px) { - - #chat-divided { - flex-direction: column; - } - - #chat-settings { - width: 100%; - } - - #chat-settings .field { - width: 100%; - display: block; - } - - #chat-settings .field input { - width: 100%; - margin: 10px 0; - } - - #chat-preview { - display: none; - } - - footer { font-size: 12px; } -} - - -.modal { - position: fixed; - top: 0; left: 0; - width: 100%; height: 100%; - background: rgba(0, 0, 0, 0.75); - display: flex; - align-items: center; - justify-content: center; - z-index: 999; -} - -.modal.hidden { - display: none; -} - -.modal-content { - background: #121212; - padding: 1.5em; - border-radius: 1em; - width: 640px; - box-shadow: 0 0 10px rgba(0, 0, 0, 0.25); - display: flex; - flex-direction: column; - gap: 1em; -} - - -.modal-content input[type=text], -.modal-content input[type=number], -.modal-content textarea { - font-family: "Inter", sans-serif; - border: none; - background:#222; - color: #FFF; - padding: 10px 20px; - border-radius: 10px; - outline: none; - margin-top: 10px; -} - - -.modal-content button { - font-family: "Inter", sans-serif; - font-weight: bold; - border: none; - padding: 15px 30px; - margin-top: 10px; - border-radius: 10px; - cursor: pointer; - background: #252525; - color: #FFF; - transition: .4s; - width: 100%; - font-size: 14px; -} - -.modal-content #confirmAddEmote { - background: #00dd63; -} - -.modal-content #cancelAddEmote { - background: #ff0000; -} - -.modal-content h3 { - margin: 0 0 0.5em; -} - -.modal-content label { - display: flex; - flex-direction: column; - font-size: 0.9em; -} - -.modal-buttons { - display: flex; - justify-content: flex-end; - gap: 1em; -} - - -#memberemotesbstatus.online i { - color: #00dd63; - text-shadow: 0 0 5px #00dd63; -} -#memberemotesbstatus.offline i { - color: #ff0000; - text-shadow: 0 0 5px #ff0000; -} \ No newline at end of file diff --git a/images/3k7a2BA.png b/images/img-empty.png similarity index 100% rename from images/3k7a2BA.png rename to images/img-empty.png diff --git a/index.html b/index.html deleted file mode 100644 index 9852b55..0000000 --- a/index.html +++ /dev/null @@ -1,417 +0,0 @@ - - - - - - ChatRD - Config - - - - - - - - - - - -
-
-

ChatRD - Setup

- -

Config

- -
-
-
- - - Streamer.Bot is Offline! - -
- -
-
- -
- -
Speaker.Bot is required for Text-to-Speech! Follow the tutorial.
- -
- -
- -
-
-
- - - - - -

General

-
-
-
- - -
- -
- - -
- -
- -
- -
- -
- -
The Chat Field is a BETA feature!
- -
- -
- -
The Chat Field also accepts /commands. Commands Supported.
- -
- -
Moderation is a BETA feature!
- -
- -
- -
Moderation Actions follows the Commands suported. Read More.
- -
- -
- - -
- -
- - -
- -
-
-
-
-
-
-
-
-
-
-
-
-
- - - - - -

Twitch

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - - - - -

YouTube

-
-
-
-
-
- -
- -
- -
-
-
-
- -
- -
YouTube API doesn't expose Member Emotes. Read more.
- -
- - -
- -
- - - - -
- - - -
-
-
- - - - - -

TikTok

-
-
-
-
-
-
-
-
-
-
- - - - - -

- - - - Kick

-
-
- -
Kick is a BETA feature! Read more.
- -
- -
- -
- -
- -
- -
Kick.Bot is required for events. Follow the tutorial.
- -
- -
-
-
-
-
-
-
- - - - - -

Donations

-
-
-
You need to connect Streamlabs to Streamer.Bot. Follow the tutorial.
- -
- -
You need to connect StreamElements to Streamer.Bot. Follow the tutorial.
- -
- -
-
-
-
- - - - - -

Patreon

-
-
-
You need to connect Patreon to Streamer.Bot. Follow the tutorial.
- -
- -
-
-
- - - - - -

TipeeeStream

-
-
-
You need to connect TipeeeStream to Streamer.Bot. Follow the tutorial.
- -
- -
-
-
- - - - - -

Ko-Fi

-
-
-
You need to connect Ko-Fi to Streamer.Bot. Follow the tutorial.
- -
- -
-
-
-
-
- - - - - -

Fourthwall

-
-
-
You need to connect Fourthwall to Streamer.Bot. Follow the tutorial.
- -
- -
- -
- -
- -
-
- -
-
-
- -
- -
-
-
- -
- - - -
- - -
- -

Made with ❀️ by VortisRD

-

- - - - - - - - - - -

-
-
- -
- -
-
- - - - - - - - diff --git a/js/app-mockup.js b/js/app-mockup.js deleted file mode 100644 index a83c51c..0000000 --- a/js/app-mockup.js +++ /dev/null @@ -1,1017 +0,0 @@ -/* ----------------------- */ -/* MOCKUP SYSTEM */ -/* ----------------------- */ - -let mockupInterval = null; -let isMockupActive = false; -const mockupDelay = 2500; // 2 seconds between events -let mockupConnectionState = false; // Track mock connection state - -// Sample data for mockup events -const mockData = { - avatars: [ - 'https://static-cdn.jtvnw.net/user-default-pictures-uv/dbdc9198-def8-11e9-8681-784f43822e80-profile_image-300x300.png', - 'https://static-cdn.jtvnw.net/user-default-pictures-uv/13e5fa74-defa-11e9-809c-784f43822e80-profile_image-300x300.png', - 'https://static-cdn.jtvnw.net/user-default-pictures-uv/215b7342-def9-11e9-9a66-784f43822e80-profile_image-300x300.png', - 'https://static-cdn.jtvnw.net/user-default-pictures-uv/ce57700a-def9-11e9-842d-784f43822e80-profile_image-300x300.png' - ], - users: [ - { name: 'PixelPunk' }, - { name: 'NoobMasterX' }, - { name: 'CrimsonCaster' }, - { name: 'LagBeast' }, - { name: 'SneakyZebra' }, - { name: 'TurboKoala' }, - { name: 'WaffleWizard' }, - { name: 'GameGoblin' }, - { name: 'EchoRift' }, - { name: 'PotionPete' }, - { name: 'ZapNoodle' }, - { name: 'BossMango' }, - { name: 'QuestFury' }, - { name: 'ShadowMuffin' }, - { name: 'FragRabbit' } - ], - messages: [ - "Hey everyone! How's the stream going?", - "This game looks awesome!", - "LOL that was hilarious", - "GG WP!", - "When are you playing Minecraft next?", - "Love the new overlay!", - "First time watching, this is great!", - "Can you explain that strategy again?", - "Greetings from Germany!", - "What's your favorite game?", - - "Let's gooooo!", - "That clutch tho πŸ”₯", - "I can't stop laughing πŸ˜‚", - "You just destroyed them!", - "What a play!", - "Did anyone else see that??", - "Streamer luck confirmed πŸ˜†", - "Please do that move again!", - "Bro you cracked?", - "This chat is wild tonight", - - "Can you shout out my friend?", - "What setup are you using?", - "Mic sounds super clean", - "W stream fr", - "Hydrate check! πŸ’§", - "Pet the dog on stream pls", - "That reaction time 😳", - "You're my comfort streamer 🧑", - "This game brings back memories", - "Why is this so intense omg", - - "Chat, what's your favorite snack?", - "That edit was slick", - "Mobile gang where you at?", - "Sheeesh πŸ₯Ά", - "This is better than Netflix", - "How long you been streaming?", - "Can we get some hype in the chat?", - "I wish I was this good", - "Can mods ban that guy?", - "Backseat gaming intensifies πŸ˜…", - - "This reminds me of old-school Twitch", - "Nice aim bot... jk (I hope)", - "Wanna 1v1?", - "The vibes are immaculate today", - "Who else is vibing with the music?", - "That moment needs to be clipped", - "Streamer out here cooking πŸ”₯", - "Yo, this community is chill", - "Day made. Thanks for the laughs!", - "Okay but that was actually insane" - ], - - emotes: [ - { - "id": "emotesv2_9eade28238d64e83b0219a9025d4692d", - "type": "Twitch", - "name": "AnotherRecord", - "startIndex": 24, - "endIndex": 36, - "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/emotesv2_9eade28238d64e83b0219a9025d4692d/default/dark/2.0" - }, - { - "id": "301428702", - "type": "Twitch", - "name": "BOP", - "startIndex": 20, - "endIndex": 22, - "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/301428702/default/dark/2.0" - }, - { - "id": "354", - "type": "Twitch", - "name": "4Head", - "startIndex": 14, - "endIndex": 18, - "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/354/default/dark/2.0" - }, - { - "id": "425618", - "type": "Twitch", - "name": "LUL", - "startIndex": 10, - "endIndex": 12, - "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/425618/default/dark/2.0" - }, - { - "id": "305954156", - "type": "Twitch", - "name": "PogChamp", - "startIndex": 0, - "endIndex": 7, - "imageUrl": "https://static-cdn.jtvnw.net/emoticons/v2/305954156/default/dark/2.0" - } - ], - emotesInsideMessages: [ - 'PogChamp', - 'LUL', - 'BOP', - '4Head', - 'AnotherRecord' - ], - rewards: [ - 'Highlight My Message', - 'Play Sound Effect', - 'Choose Next Game', - 'Song Request', - 'Dad Joke', - 'Hydration Check' - ], - announcements: [ - 'Welcome to the stream everyone!', - 'Don\'t forget to follow for stream notifications!', - 'We\'re going to raid someone awesome after this game!', - 'Thanks for all the subs today!', - 'New emotes coming next week!' - ], - badges: [ - { "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/28ac9d77-bba9-4281-aba9-716081aee210/3" }, - { "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/c4a29737-e8a5-4420-917a-314a447f083e/3" }, - { "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/ae1c6c62-c057-4fad-a1d4-663bf988701f/3" }, - { "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/bbbe0db0-a598-423e-86d0-f9fb98ca1933/3" }, - { "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/2de71f4f-b152-4308-a426-127a4cf8003a/3" }, - { "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/4149750c-9582-4515-9e22-da7d5437643b/3" }, - { "imageUrl": "https://static-cdn.jtvnw.net/badges/v1/5864739a-5e58-4623-9450-a2c0555ef90b/3" } - ], - badgeskick: [ - { "type": "broadcaster" }, - { "type": "sidekick" }, - { "type": "moderator" }, - { "type": "vip" }, - { "type": "sub_gifter" }, - { "type": "og" }, - { "type": "founder" }, - { "type": "verified" }, - { "type": "subscriber" }, - ], - superstickers: [ - { "imageUrl": "https://lh3.googleusercontent.com/G2OgWJkuvSullUPp2i09zG_WR0IpQu-6Ti4pFXn_FJ1OkR6zU5GdiP9cBavimQopETyojInsRCe8uefjJBqn=s148-rwa" }, - { "imageUrl": "https://lh3.googleusercontent.com/-21C0x6zYcDxpJVYKl8CCKroyjW2Hdvh2FWBipCTFhonaPy2cSJZWTGvmjsoBJu-LedOHQrw1Qu7TYXxIlxv=s148-rwa" }, - { "imageUrl": "https://lh3.googleusercontent.com/kpwCxm65pv0p2YMunCEHaYcD1A0TnwTg4uSJMDsBriu6cZSGOAjXw_CPvV5PajvWEq1LANypR_WHRpA7HU8=s148-rwa" }, - { "imageUrl": "https://lh3.googleusercontent.com/y4t53UFh4eWO9FmuXgELtXn0cWsZEAJOWCExbumx2vcNclm2VYJkd4Omo7lKLxOg78zaXBmukrN0ONPRDwM=s148-rwa" }, - { "imageUrl": "https://lh3.googleusercontent.com/aQTC6r0gjuns5TwJTMoA_mqOH3mizXxzlAJqh_CpLx8lWyKiUgS_EjTATRTX0Qzm8MlZyXAg7r6kFzlH8HgS=s148-rwa" }, - { "imageUrl": "https://lh3.googleusercontent.com/oUIeg07YsvEuUcF7wOg6U3o1dOCANoBWuF1DYr2jGPFOyQ-bEFRiFm-6gU3urJPaX_AqtZgsNpGb0KNimA=s148-rwa" }, - { "imageUrl": "https://lh3.googleusercontent.com/gauEuKs0cTW_YrtkKit45UrShY7KuK2-Kh9RV3H3Eirtx2KY6PHLeaDHbFz-l9OGMYISF0F57Wk2lzTiHw=s148-rwa" }, - { "imageUrl": "https://lh3.googleusercontent.com/PQlPxOdeVk_oY3D_Ow0JRXvV3AbVIEoApzvenbfgsAHoLF4_EgxCV7Dsd-kqMsCAqhHhNG0vUY2Ssoa03iW_=s148-rwa" }, - { "imageUrl": "https://lh3.googleusercontent.com/Cmmj_3s8DpgpuHdOhUmIZQU0Gmex9IISD2SNk4UQY-HA1jHfSPYCk6-gZ-PEpLKGHgyEfZNRCiAV_lHC_Q=s148-rwa" }, - ], - tiktokGifts: [ - { name: "Rose", coins: 1 }, - { name: "Finger Heart", coins: 5 }, - { name: "TikTok", coins: 10 }, - { name: "Confetti", coins: 100 }, - { name: "Galaxy", coins: 1000 } - ] -}; - -// Function to generate a random mockup event -function generateMockEvent() { - const eventTypes = [ - 'twitch-chat', 'twitch-chat', 'twitch-chat', 'twitch-chat', 'twitch-chat', - 'twitch-chat', 'twitch-chat', 'twitch-chat', 'twitch-chat', 'twitch-chat', - 'twitch-chat', 'twitch-chat', 'twitch-chat', 'twitch-chat', 'twitch-chat', - 'twitch-chat', 'twitch-chat', 'twitch-chat', 'twitch-chat', 'twitch-chat', - - 'twitch-follow', 'twitch-bits', 'twitch-sub', 'twitch-resub', - - 'twitch-giftsub', 'twitch-giftbomb', 'twitch-raid', - 'twitch-announcement', 'twitch-reward', 'twitch-gigantifyemote', - - 'youtube-chat', 'youtube-chat', 'youtube-chat', 'youtube-chat', 'youtube-chat', - 'youtube-chat', 'youtube-chat', 'youtube-chat', 'youtube-chat', 'youtube-chat', - 'youtube-superchat', 'youtube-supersticker', 'youtube-newsponsor', 'youtube-membermilestone', 'youtube-membergift', - - 'tiktok-chat', 'tiktok-chat', 'tiktok-chat', 'tiktok-chat', 'tiktok-chat', - 'tiktok-chat', 'tiktok-chat', 'tiktok-chat', 'tiktok-chat', 'tiktok-chat', - 'tiktok-follow', 'tiktok-sub', 'tiktok-gift', - - 'kick-chat', 'kick-chat', 'kick-chat', 'kick-chat', 'kick-chat', - 'kick-chat', 'kick-chat', 'kick-chat', 'kick-chat', 'kick-chat', - - 'kick-follow', 'kick-sub', - 'kick-giftsub', 'kick-giftbomb', 'kick-raid', - - 'patreon-membership', 'tipeeestream-tip', - - 'kofi-donation', 'kofi-sub', 'kofi-resub', 'kofi-order', - - 'fourthwall-donation', 'fourthwall-sub', 'fourthwall-order', - - 'streamlabs-tip', 'streamelements-tip', - ]; - - // Select random event type and user - - const fakeAvatar = mockData.avatars[Math.floor(Math.random() * mockData.avatars.length)]; - const eventType = eventTypes[Math.floor(Math.random() * eventTypes.length)]; - const user = mockData.users[Math.floor(Math.random() * mockData.users.length)]; - const announcement = mockData.announcements[Math.floor(Math.random() * mockData.announcements.length)]; - const reward = mockData.rewards[Math.floor(Math.random() * mockData.rewards.length)]; - const emote = mockData.emotes[Math.floor(Math.random() * mockData.emotes.length)]; - const emotesInsideMessages = mockData.emotesInsideMessages[Math.floor(Math.random() * mockData.emotesInsideMessages.length)]; - const messagetext = mockData.messages[Math.floor(Math.random() * mockData.messages.length)]; - const messageId = randomString(40); - - const shuffledBadges = [...mockData.badges].sort(() => Math.random() - 0.5); - const badgeCount = Math.floor(Math.random() * 3) + 1; // 1 to 3 - const badgeschosen = shuffledBadges.slice(0, badgeCount); - - const shuffledBadgesKick = [...mockData.badgeskick].sort(() => Math.random() - 0.5); - const badgeCountKick = Math.floor(Math.random() * 3) + 1; // 1 to 3 - const badgesChosenKick = shuffledBadgesKick.slice(0, badgeCountKick); - - const randomIndex = Math.floor(Math.random() * mockData.superstickers.length); - const randomStickerUrl = mockData.superstickers[randomIndex].imageUrl; - - const tiktokGift = mockData.tiktokGifts[Math.floor(Math.random() * mockData.tiktokGifts.length)]; - - const firstMessage = Math.random() < 0.1; - - switch(eventType) { - case 'twitch-chat' : - - var data = { - emotes: mockData.emotes, - message: { - username: user.name.toLowerCase(), - color: randomColor(), - displayName: user.name, - message: messagetext + ' ' + emotesInsideMessages, - firstMessage: firstMessage, - badges: badgeschosen, - }, - user: { - role: 1 - }, - messageId: messageId, - }; - - const ifHasReply = Math.random() < 0.05; - if (ifHasReply) { - data.message.isReply = true; - var replier = mockData.users[Math.floor(Math.random() * mockData.users.length)]; - data.message.reply = { - userName: replier.name, - msgBody: mockData.messages[Math.floor(Math.random() * mockData.messages.length)] - }; - } - - const ifHasShared = Math.random() < 0.05; - if (ifHasShared) { - data.isSharedChat = true; - var sharedParentUser = mockData.users[Math.floor(Math.random() * mockData.users.length)]; - - data.sharedChat = { - sourceRoom: { - name: sharedParentUser.name - } - }; - } - - - twitchChatMessage(data); - - break; - case 'twitch-follow' : - - var data = { - user_id: user.name.toLowerCase(), - user_name: user.name, - }; - - twitchFollowMessage(data); - - break; - case 'twitch-bits' : - - var data = { - - emotes: mockData.emotes, - user: { - id: user.name.toLowerCase(), - name: user.name - }, - message: { - bits: Math.floor(Math.random() * 10000) + 1, - message: messagetext, - }, - messageId: messageId, - }; - - twitchBitsMessage(data); - - break; - case 'twitch-sub' : - - var data = { - user: { - id: user.name.toLowerCase(), - name: user.name - }, - duration_months: 1, - sub_tier: parseInt(Math.floor(Math.random() * 3) + 1), - isPrime: Math.random() < 0.1, - text: messagetext - } - - twitchSubMessage(data); - - break; - case 'twitch-resub' : - - var data = { - user: { - id: user.name.toLowerCase(), - name: user.name - }, - cumulativeMonths: Math.floor(Math.random() * 50) + 1, - subTier: parseInt(Math.floor(Math.random() * 3) + 1), - isPrime: Math.random() < 0.1, - text: messagetext - } - - twitchReSubMessage(data); - - break; - case 'twitch-giftsub' : - - var gifterUser = mockData.users[Math.floor(Math.random() * mockData.users.length)]; - var data = { - user: { - id: user.name.toLowerCase(), - name: user.name - }, - recipient: { name: gifterUser.name }, - durationMonths: Math.floor(Math.random() * 50) + 1, - subTier: parseInt(Math.floor(Math.random() * 3) + 1), - cumlativeTotal: Math.floor(Math.random() * 200) + 1 - } - - twitchGiftMessage(data); - - break; - case 'twitch-giftbomb' : - - var data = { - user: { - id: user.name.toLowerCase(), - name: user.name - }, - total: Math.floor(Math.random() * 50) + 1, - sub_tier: parseInt(Math.floor(Math.random() * 3) + 1), - cumulative_total: Math.floor(Math.random() * 200) + 1 - } - - twitchGiftSubsMessage(data); - - break; - case 'twitch-raid' : - - var data = { - from_broadcaster_user_login: user.name.toLowerCase(), - from_broadcaster_user_name: user.name, - viewers: Math.floor(Math.random() * 200) + 1 - } - - twitchRaidMessage(data); - - break; - case 'twitch-announcement' : - - var data = { - messageId: messageId, - user: { - id: user.name.toLowerCase(), - name: user.name - }, - text: announcement, - parts: mockData.emotes - } - - twitchAnnouncementMessage(data); - - break; - case 'twitch-reward' : - - var data = { - user_id: user.name.toLowerCase(), - user_name: user.name, - user_input: announcement, - reward: { - title: reward - } - } - - twitchRewardRedemption(data); - - break; - - case 'youtube-chat' : - - var amIMod = Math.random() < 0.1; - var amISub = Math.random() < 0.1; - var amIOwner = Math.random() < 0.1; - - if (amIOwner == true) { - amIMod = false; - amISub = false; - } - - var data = { - user : { - id: user.name.toLowerCase(), - profileImageUrl: fakeAvatar, - name: user.name, - isVerified: Math.random() < 0.2, - isSponsor: amISub, - isModerator: amIMod, - isOwner: amIOwner, - }, - emotes: mockData.emotes, - message: messagetext, - eventId: messageId, - }; - - youTubeChatMessage(data); - - break; - case 'youtube-superchat' : - - var data = { - user: { - id: user.name.toLowerCase(), - name: user.name, - }, - eventId: messageId, - amount: '$' + Math.floor(Math.random() * 2000) + 1, - message : messagetext - }; - - youTubeSuperChatMessage(data); - - break; - case 'youtube-supersticker' : - - var data = { - user: { - id: user.name.toLowerCase(), - name: user.name - }, - eventId: messageId, - amount: '$' + Math.floor(Math.random() * 2000) + 1, - _fVK15WwYFFCcGLW0zi1jLCJXj3f: { - imageUrl: randomStickerUrl - } - }; - - youTubeSuperStickerMessage(data); - - - break; - case 'youtube-newsponsor' : - - var data = { - user: { - id: user.name.toLowerCase(), - name: user.name, - }, - eventId: messageId, - levelName: parseInt(Math.floor(Math.random() * 3) + 1), - months: 1 - }; - - youTubeNewSponsorMessage(data); - - break; - case 'youtube-membermilestone' : - - var data = { - user: { - id: user.name.toLowerCase(), - name: user.name, - }, - eventId: messageId, - levelName: parseInt(Math.floor(Math.random() * 3) + 1), - months: Math.floor(Math.random() * 50) + 1, - message: messagetext - }; - - youTubeNewSponsorMessage(data); - - - break; - case 'youtube-membergift' : - - var data = { - user : { - id: user.name.toLowerCase(), - name: user.name, - }, - tier: parseInt(Math.floor(Math.random() * 3) + 1), - count: Math.floor(Math.random() * 50) + 1, - eventId: messageId, - }; - - youTubeGiftedMembersMessage(data); - - break; - - case 'tiktok-chat' : - - var data = { - userId: user.name.toLowerCase(), - nickname: user.name, - profilePictureUrl: fakeAvatar, - isSubscriber: Math.random() < 0.2, - isModerator: Math.random() < 0.1, - isOwner: Math.random() < 0.05, - - emotes: {}, - - comment: messagetext, - - msgId: messageId, - }; - - tiktokChatMessage(data); - - break; - case 'tiktok-follow' : - - var data = { - userId: user.name.toLowerCase(), - nickname: user.name, - profilePictureUrl: fakeAvatar, - msgId: messageId, - }; - - tiktokFollowMessage(data); - - break; - case 'tiktok-sub' : - - var data = { - userId: user.name.toLowerCase(), - nickname: user.name, - profilePictureUrl: fakeAvatar, - msgId: messageId, - subMonth: Math.floor(Math.random() * 50) + 1 - }; - - tiktokSubMessage(data); - - break; - case 'tiktok-gift' : - - var data = { - userId: user.name.toLowerCase(), - nickname: user.name, - profilePictureUrl: fakeAvatar, - msgId: messageId, - - giftName: tiktokGift.name, - repeatCount: Math.floor(Math.random() * 50) + 1, - diamondCount: tiktokGift.coins, - }; - - tiktokGiftMessage(data); - - - break; - - - - - - - - - - - case 'kick-chat' : - - var data = { - id: messageId, - type: "message", - content: messagetext, - - sender: { - id: user.name.toLowerCase(), - slug: user.name.toLowerCase(), - username: user.name, - identity: { - color: randomColor(), - badges: badgesChosenKick - - } - } - }; - - const ifHasReplyOnKick = Math.random() < 0.05; - if (ifHasReplyOnKick) { - - var replier = mockData.users[Math.floor(Math.random() * mockData.users.length)]; - - data.metadata = { - original_message: { - content: mockData.messages[Math.floor(Math.random() * mockData.messages.length)] - }, - original_sender: { - username: replier.name - }, - } - - } - - - kickChatMessage(data); - - break; - - case 'kick-follow' : - - var data = { - userName: user.name.toLowerCase(), - user: user.name, - }; - - kickFollowMessage(data); - - break; - - case 'kick-sub' : - - var data = { - userName: user.name.toLowerCase(), - user: user.name, - cumulative: Math.floor(Math.random() * 50) + 1, - tier: 1 - } - - kickSubMessage(data); - - break; - - case 'kick-giftsub' : - - var gifted = mockData.users[Math.floor(Math.random() * mockData.users.length)]; - - var data = { - user: user.name, - userName: user.name.toLowerCase(), - recipientUser: gifted.name, - tier: 1, - totalSubsGifted: Math.floor(Math.random() * 200) + 1 - } - - kickGiftMessage(data); - - break; - - case 'kick-giftbomb' : - - var data = { - user: user.name, - userName: user.name.toLowerCase(), - tier: 1, - gifts: Math.floor(Math.random() * 200) + 1 - } - - kickGiftSubsMessage(data); - - break; - - - case 'kick-raid' : - - var data = { - user: user.name, - viewers: Math.floor(Math.random() * 200) + 1 - } - - kickRaidMessage(data); - - break; - - - - - - - - - - - - case 'patreon-membership' : - - var data = { - attributes: { - full_name: user.name, - will_pay_amount_cents: Math.floor(Math.random() * (10000 - 1000)) + 1000 - } - }; - - patreonMemberships(data); - - break; - - - - - - - - - - - - case 'tipeeestream-tip' : - - var data = { - user: user.name, - amount: Math.floor(Math.random() * 2000) + 1, - currency: 'USD', - message: messagetext - }; - - tipeeeStreamDonation(data); - - break; - - - - - - - - - - - - case 'kofi-donation' : - - var data = { - from: user.name, - amount: Math.floor(Math.random() * 2000) + 1, - currency: 'USD', - message: messagetext - }; - - kofiDonationMessage(data); - - break; - - - case 'kofi-sub' : - - var data = { - from: user.name, - amount: Math.floor(Math.random() * 2000) + 1, - currency: 'USD', - message: messagetext - }; - - kofiSubMessage(data); - - break; - - case 'kofi-resub' : - - var data = { - from: user.name, - amount: Math.floor(Math.random() * 2000) + 1, - currency: 'USD', - tier: parseInt(Math.floor(Math.random() * 3) + 1), - message: messagetext - }; - - kofiReSubMessage(data); - - break; - - case 'kofi-order' : - - var data = { - from: user.name, - amount: Math.floor(Math.random() * 200) + 1, - items: badgeschosen, - currency: 'USD', - message: messagetext - }; - - kofiOrderMessage(data); - - break; - - - - - - - - - - - - case 'fourthwall-donation' : - - var data = { - username: user.name, - amount: Math.floor(Math.random() * 2000) + 1, - currency: 'USD', - message: messagetext - }; - - fourthwallDonationMessage(data); - - break; - - - case 'fourthwall-sub' : - - var data = { - nickname: user.name, - amount: Math.floor(Math.random() * 2000) + 1, - currency: 'USD' - }; - - fourthwallSubMessage(data); - - break; - - - case 'fourthwall-order' : - - var data = { - username: user.name, - total: Math.floor(Math.random() * 200) + 1, - variants: [ - { - name: 'Fake Product', - image: 'images/3k7a2BA.png' - } - ], - currency: 'USD', - statmessageus: messagetext - }; - - fourthwallOrderMessage(data); - - break; - - - - - - - - - - - - case 'streamlabs-tip' : - - var data = { - from: user.name, - formattedAmount: Math.floor(Math.random() * 2000) + 1, - currency: 'USD', - message: messagetext - }; - - streamLabsEventMessage(data); - - break; - - case 'streamelements-tip' : - - var data = { - username: user.name,e, - amount: Math.floor(Math.random() * 2000) + 1, - currency: 'USD', - message: messagetext - }; - - streamElementsEventMessage(data); - - break; - } -} - -// Function to start the mockup system -function startMockupSystem() { - if (!isMockupActive) { - console.debug('Starting mockup system...'); - isMockupActive = true; - mockupConnectionState = false; - - // Add a notification about mockup mode - notifyInfo({ - title: "Streamer.Bot Disconnected", - text: "Running in mockup mode. Showing sample events." - }); - - // Start with a few initial events - for (let i = 0; i < 3; i++) { - setTimeout(() => generateMockEvent(), i * 500); - } - - // Set interval for regular events - mockupInterval = setInterval(generateMockEvent, mockupDelay); - - // Update statistics for demo - updateMockStatistics(); - } -} - -// Function to stop the mockup system -function stopMockupSystem() { - if (isMockupActive) { - console.debug('Stopping mockup system...'); - isMockupActive = false; - mockupConnectionState = true; - clearInterval(mockupInterval); - mockupInterval = null; - - document.querySelector('#statistics #twitch .viewers span').textContent = '0'; - document.querySelector('#statistics #youtube .viewers span').textContent = '0'; - document.querySelector('#statistics #youtube .likes span').textContent = '0'; - document.querySelector('#statistics #tiktok .viewers span').textContent = '0'; - document.querySelector('#statistics #tiktok .likes span').textContent = '0'; - document.querySelector('#statistics #kick .viewers span').textContent = '0'; - } -} - -// Function to update mock statistics -function updateMockStatistics() { - if (showPlatformStatistics) { - if (showTwitchViewers) { - document.querySelector('#statistics #twitch .viewers span').textContent = formatNumber(Math.floor(Math.random() * 500) + 50); - } - - if (showYouTubeStatistics) { - document.querySelector('#statistics #youtube .viewers span').textContent = formatNumber(Math.floor(Math.random() * 300) + 20); - document.querySelector('#statistics #youtube .likes span').textContent = formatNumber(Math.floor(Math.random() * 1000) + 100); - } - - if (showTikTokStatistics) { - document.querySelector('#statistics #tiktok .viewers span').textContent = formatNumber(Math.floor(Math.random() * 800) + 200); - document.querySelector('#statistics #tiktok .likes span').textContent = formatNumber(Math.floor(Math.random() * 5000) + 500); - } - - if (showKickViewers) { - document.querySelector('#statistics #kick .viewers span').textContent = formatNumber(Math.floor(Math.random() * 800) + 200); - } - } -} - - - - -function randomIntFromInterval(min, max) { - return Math.floor(Math.random() * (max - min + 1) + min); -} - - -function randomString(length) { - const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - let result = ""; - for (let i = 0; i < length; i++) { - result += chars.charAt(Math.floor(Math.random() * chars.length)); - } - return result; -} - -function randomColor() { - const randomColor = "hsl(" + Math.random() * 360 + ", 100%, 75%)"; - return randomColor; -} \ No newline at end of file diff --git a/js/app.js b/js/app.js deleted file mode 100644 index 041687b..0000000 --- a/js/app.js +++ /dev/null @@ -1,718 +0,0 @@ -/* ----------------------- */ -/* OPTIONS */ -/* ----------------------- */ - -const streamerBotServerAddress = getURLParam("streamerBotServerAddress", "127.0.0.1"); -const streamerBotServerPort = getURLParam("streamerBotServerPort", "8080"); - -const ttsSpeakerBotChat = getURLParam("ttsSpeakerBotChat", false); -const ttsSpeakerBotEvents = getURLParam("ttsSpeakerBotEvents", false); - -let streamerBotConnected = false; -const chatThreshhold = 50; - -const chatContainer = document.querySelector('#chat'); -const chatFontSize = getURLParam("chatFontSize", 1); -const chatBackground = getURLParam("chatBackground", "#121212"); -const chatBackgroundOpacity = getURLParam("chatBackgroundOpacity", 1); -const chatScrollBar = getURLParam("chatScrollBar", false); -const chatBiggerEmotes = getURLParam("chatBiggerEmotes", false); -const chatField = getURLParam("chatField", false); -const chatModeration = getURLParam("chatModeration", false); - -const currentLang = lang[getURLParam("language", 'ptbr')]; -const eventsMockup = getURLParam("eventsMockup", true); -const chatHorizontal = getURLParam("chatHorizontal", false); -const showPlatform = getURLParam("showPlatform", false); -const showAvatar = getURLParam("showAvatar", false); -const showTimestamps = getURLParam("showTimestamps", false); -const ampmTimeStamps = getURLParam("ampmTimeStamps", false); -const showBadges = getURLParam("showBadges", true); -const showPlatformStatistics = getURLParam("showPlatformStatistics", false); -const hideAfter = getURLParam("hideAfter", 0); -const ignoreChatters = getURLParam("ignoreChatters", ""); -const excludeCommands = getURLParam("excludeCommands", true); - -const userColors = new Map(); - -const ignoreUserList = ignoreChatters.split(',').map(item => item.trim().toLowerCase()) || []; - -chatContainer.style.zoom = chatFontSize; -if (chatScrollBar == false) { chatContainer.classList.add('noscrollbar'); } -if (chatField == true) { - const chatfieldelement = document.getElementById("chat-input"); - chatfieldelement.classList.add('enabled'); - chatfieldelement.querySelector('form input[type=text]').setAttribute('placeholder', currentLang.chatsendmessage); -} - -/* ----------------------- */ -/* START */ -/* ----------------------- */ - -document.body.style.backgroundColor = hexToRGBA(chatBackground,chatBackgroundOpacity); - -if (showPlatformStatistics == false) { document.querySelector('#statistics').style.display = 'none'; } -if (chatHorizontal == true) { chatContainer.parentElement.classList.add('horizontal'); } - -/* ----------------------- */ -/* STREAMER.BOT CONNECTION */ -/* ----------------------- */ - -const streamerBotClient = new StreamerbotClient({ - host: streamerBotServerAddress, - port: streamerBotServerPort, - onConnect: (data) => { - console.debug( currentLang.streamerbotconnected ); - console.debug(data); - streamerBotConnected = true; - notifySuccess({ - title: currentLang.streamerbotconnected, - text: `` - }); - if (eventsMockup == true) { - chatContainer.innerHTML = ''; - stopMockupSystem(); - } - }, - onDisconnect: () => { - console.error(currentLang.streamerbotdisconnected); - streamerBotConnected = false; - if (eventsMockup == true) { - startMockupSystem(); - } - - } -}); - - - - -/* ----------------------- */ -/* UTILITIES */ -/* ----------------------- */ - - - -async function addMessageToChat(userID, messageID, platform, data) { - - if (ttsSpeakerBotChat == true) { ttsSpeakerBotSays(data.userName, currentLang.ttschat, data.message); } - - let html = DOMPurify.sanitize(` -
-
- - ${data.classes.includes("first-message") ? '✨' : '' } - - ${!data.shared ? '' : data.shared} - - ${showTimestamps == true ? ''+whatTimeIsIt()+'' : ''} - - ${showPlatform == true ? '' : '' } - - ${showAvatar == true ? (data.avatar ? '' : '') : ''} - - ${showBadges == true ? ''+data.badges+'' : ''} - - ${data.userName}: - - ${!data.reply ? '' : data.reply} - - ${data.message} -
- - ${chatModeration == true && platform == 'twitch' ? `[CHATMODERATIONSNIPPETTWITCH]` : ''} - ${chatModeration == true && platform == 'youtube' ? `[CHATMODERATIONSNIPPETYOUTUBE]` : ''} - -
- `); - - - let chatmodtwitch = ` - - - - `; - - let chatmodyoutube = ` - - - `; - - html = html.replace('[CHATMODERATIONSNIPPETTWITCH]', chatmodtwitch); - html = html.replace('[CHATMODERATIONSNIPPETYOUTUBE]', chatmodyoutube); - - chatContainer.insertAdjacentHTML('afterbegin', html); - - const messageElement = document.getElementById(messageID); - - if (chatHorizontal == true) { - await adjustMessagesHorizontal(messageElement); - } - - if (hideAfter > 0) { - setTimeout(function () { - messageElement.style.opacity = 0; - setTimeout(function () { - messageElement.remove(); - }, 1000); - }, Math.floor(hideAfter * 1000)); - } - - removeExtraChatMessages(); -} - - - - -async function addEventToChat(userID, messageID, platform, data) { - - if (ttsSpeakerBotEvents == true) { ttsSpeakerBotSays(data.userName, '', data.message); } - - const html = DOMPurify.sanitize(` -
-
- ${!data.reply ? '' : data.reply} - - ${showPlatform == true ? '' : '' } - - - ${data.userName} - ${data.message} - -
-
- `); - - chatContainer.insertAdjacentHTML('afterbegin', html); - - const messageElement = document.getElementById(messageID); - - if (chatHorizontal == true) { - await adjustMessagesHorizontal(messageElement); - } - - if (hideAfter > 0) { - setTimeout(function () { - messageElement.style.opacity = 0; - setTimeout(function () { - messageElement.remove(); - }, 1000); - }, Math.floor(hideAfter * 1000)); - } - - removeExtraChatMessages(); -} - - - - - - - - - - - -async function adjustMessagesHorizontal(messageElement) { - const container = messageElement.querySelector('.animate__animated'); - if (!container) return; - - const images = container.querySelectorAll("img.emote"); - - function waitImageLoad(img) { - return new Promise((resolve) => { - if (img.complete) { - adjustEmotesWidthInMessage(img); - resolve(); - } - else { - img.addEventListener("load", () => { - adjustEmotesWidthInMessage(img); - resolve(); - }); - img.addEventListener("error", () => resolve()); - } - }); - } - - await Promise.all(Array.from(images).map(img => waitImageLoad(img))); - - const messageElementWidth = Math.floor(container.offsetWidth + 10) + 'px'; - - Object.assign(messageElement.style, { - width: messageElementWidth, - overflow: "visible" - }); -} - -function adjustEmotesWidthInMessage(img) { - const width = img.offsetWidth; - img.style.width = width + "px"; -} - - - - - - - - - - - - - - - - - -const whatTimeIsIt = () => { - const now = new Date(); - const hours24 = now.getHours(); - const minutes = now.getMinutes().toString().padStart(2, '0'); - const ampm = hours24 >= 12 ? 'PM' : 'AM'; - const hours12 = (hours24 % 12) || 12; - - if (ampmTimeStamps == true) { return `${hours12}:${minutes} ${ampm}`; } - else { return `${hours24}:${minutes}`; } -}; - - -function removeExtraChatMessages() { - const chatMessages = chatContainer.querySelectorAll('div.message'); - const total = chatMessages.length; - - if (total >= chatThreshhold) { - const toRemove = Math.floor(total * 0.25); // 25% do total - for (let i = 0; i < toRemove; i++) { - const last = chatContainer.lastElementChild; - if (last) chatContainer.removeChild(last); - } - } -} - - - -// Function to format large numbers (e.g., 1000 => '1K') -function formatNumber(num) { - if (num >= 1000000) { - let numStr = (num / 1000000).toFixed(1); - if (numStr.endsWith('.0')) { - numStr = numStr.slice(0, -2); - } - return numStr + 'M'; - } - else if (num >= 1000) { - let numStr = (num / 1000).toFixed(1); - if (numStr.endsWith('.0')) { - numStr = numStr.slice(0, -2); - } - return numStr + 'K'; - } - return num.toString(); -} - - -function formatCurrency(amount, currencyCode) { - return new Intl.NumberFormat(undefined, { - style: 'currency', - currency: currencyCode, - minimumFractionDigits: 0, - maximumFractionDigits: 2 - }).format(amount); -} - - - -function createRandomColor(platform, username) { - if (userColors.get(platform).has(username)) { - return userColors.get(platform).get(username); - } - else { - const randomColor = "hsl(" + Math.random() * 360 + ", 100%, 75%)"; - userColors.get(platform).set(username, randomColor); - return randomColor; - } -} - - -function createRandomString(length) { - const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - let result = ""; - for (let i = 0; i < length; i++) { - result += chars.charAt(Math.floor(Math.random() * chars.length)); - } - return result; -} - -function getURLParam(param, defaultValue) { - const chatQueryString = window.location.search; - const urlParams = new URLSearchParams(chatQueryString); - const paramVar = urlParams.get(param); - - switch (paramVar) { - case 'true': - return true; - - case 'false': - return false; - - case null: - case undefined: - return defaultValue; - - default: - return paramVar; - } -} - - -const pushNotify = (data) => { - - const SimpleNotify = { - effect: 'fade', - speed: 500, - customClass: 'toasty', - customIcon: '', - showIcon: true, - showCloseButton: true, - autoclose: true, - autotimeout: 5000, - notificationsGap: null, - notificationsPadding: null, - type: 'outline', - position: 'x-center bottom', - customWrapper: '', - }; - - const mergedData = { - ...SimpleNotify, - ...data - } - - new Notify (mergedData); -} - -const notifyError = (err) => { - err.status = 'error'; - pushNotify(err); -} - -const notifyInfo = (info) => { - info.status = 'info'; - pushNotify(info); -} - -const notifyWarning = (warn) => { - warn.status = 'warning'; - pushNotify(warn); -} - - -const notifySuccess = (success) => { - success.status = 'success'; - pushNotify(success); -} - - -function escapeRegex(string) { - return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); -} - - -async function ttsSpeakerBotSays(user, action, message) { - - if (streamerBotConnected == false) return; - - const ttstext = await cleanStringOfHTMLButEmotes(message); - const ttsmessage = user+' '+action+' '+ttstext; - - streamerBotClient.doAction( - { name : "TTS Event" }, - { - "ttsmessage": ttsmessage, - } - ).then( (ttsstuff) => { - console.debug('Sending TTS to Streamer.Bot', ttsstuff); - }); -} - - -async function cleanStringOfHTMLButEmotes(string) { - // Cria um elemento DOM temporΓ‘rio - const container = document.createElement('div'); - container.innerHTML = string; - - // Substitui ... por texto do alt - const emotes = container.querySelectorAll('img.emote[alt]'); - emotes.forEach(img => { - const altText = img.getAttribute('alt'); - const textNode = document.createTextNode(altText); - img.replaceWith(textNode); - }); - - // Remove todo o restante do HTML - return container.textContent || ""; -} - - -function stripStringFromHtml(html) { - let doc = new DOMParser().parseFromString(html, 'text/html'); - return doc.body.textContent || ""; -} - - -function hexToRGBA(hexadecimal,opacity) { - const hex = hexadecimal; - const alpha = parseFloat(opacity); - - // Converter hex para RGB - const r = parseInt(hex.substr(1, 2), 16); - const g = parseInt(hex.substr(3, 2), 16); - const b = parseInt(hex.substr(5, 2), 16); - - return `rgba(${r}, ${g}, ${b}, ${alpha})`; -} - - - -const chatInputSend = document.getElementById("chat-input-send"); -const chatInputForm = document.querySelector("#chat-input form"); -const chatInput = chatInputForm.querySelector("input[type=text]") -const chatSettings = document.getElementById("chat-input-settings"); - -chatInputForm.addEventListener("submit", function(event) { - event.preventDefault(); - - var chatSendPlatforms = []; - - const chatOnTwitch = document.querySelector('#chat-input #twitch input[type=checkbox]').checked; - const chatOnYoutube = document.querySelector('#chat-input #youtube input[type=checkbox]').checked; - const chatOnTiktok = document.querySelector('#chat-input #tiktok input[type=checkbox]').checked; - const chatOnKick = document.querySelector('#chat-input #kick input[type=checkbox]').checked; - - if (chatOnTwitch == true) { - chatSendPlatforms.push('twitch'); - } - - if (chatOnYoutube == true) { - chatSendPlatforms.push('youtube'); - } - - if (chatOnTiktok == true) { - chatSendPlatforms.push('tiktok'); - } - - if (chatOnKick == true) { - chatSendPlatforms.push('kick'); - } - - chatSendPlatforms = chatSendPlatforms.join(',') - - const chatInput = chatInputForm.querySelector("input[type=text]") - const chatInputText = chatInput.value; - - // Sends Message to Twitch and YouTube - streamerBotClient.doAction( - { name : "ChatRD Messages and Commands" }, - { - "type": "chat", - "platforms": chatSendPlatforms, - "message": chatInputText, - } - ).then( (sendchatstuff) => { - console.debug('Sending Chat to Streamer.Bot', sendchatstuff); - }); - - // Sends Message to Kick that are not commands - if (chatSendPlatforms.includes('kick')) { - if (!chatInputText.startsWith('/')) { - streamerBotClient.doAction( - { name : "ChatRD Kick Messages" }, - { - "message": chatInputText, - } - ).then( (sendchatstuff) => { - console.debug('Sending Kick Chat to Streamer.Bot', sendchatstuff); - }); - } - } - - // Sends Message to TikTok that are not commands - if (chatSendPlatforms.includes('tiktok')) { - if (!chatInputText.startsWith('/')) { - streamerBotClient.doAction( - { name : "ChatRD TikTok Messages" }, - { - "ttkmessage": chatInputText, - } - ).then( (sendchatstuff) => { - console.debug('Sending TikTok Chat to Streamer.Bot', sendchatstuff); - }); - } - } - - chatInput.value = ''; -}); - -chatInputSend.addEventListener("click", function () { - chatInputForm.requestSubmit(); -}); - - - - -async function executeModCommand(event, command) { - event.preventDefault(); - - if (streamerBotConnected == true) { - chatInput.value = command; - - chatInputForm.requestSubmit(); - } - else { - - notifyError({ - title: currentLang.streamerbotdisconnected, - text: `` - }); - } -} - - -let chatcommands = { - "Twitch" : [ - { "name" : "/me", "usage" : "[message]" }, - { "name" : "/announce", "usage" : "[message]" }, - { "name" : "/clear", "usage" : "" }, - { "name" : "/slow", "usage" : "[duration]" }, - { "name" : "/slowoff", "usage" : "" }, - { "name" : "/subscribers", "usage" : "" }, - { "name" : "/subscribersoff", "usage" : "" }, - { "name" : "/commercial", "usage" : "[duration]" }, - { "name" : "/timeout", "usage" : "[user] [duration] [reason]" }, - { "name" : "/untimeout", "usage" : "[user]" }, - { "name" : "/ban", "usage" : "[user] [duration] [reason]" }, - { "name" : "/unban", "usage" : "[user]" }, - { "name" : "/mod", "usage" : "[user]" }, - { "name" : "/unmod", "usage" : "[user]" }, - { "name" : "/vip", "usage" : "[user]" }, - { "name" : "/unvip", "usage" : "[user]" }, - { "name" : "/shoutout", "usage" : "[user]" }, - { "name" : "/raid", "usage" : "[user]" }, - { "name" : "/unraid", "usage" : "" } - ], - "YouTube" : [ - { "name" : "/yt/title", "usage" : "[title]" }, - { "name" : "/yt/description", "usage" : "[description]" }, - { "name" : "/yt/timeout", "usage" : "[user] [duration]" }, - { "name" : "/yt/ban", "usage" : "[user]" } - ] -}; - -let chatcurrentFocus = -1; - -const chatcommandslist = document.getElementById('chat-autocomplete-list'); - -chatInput.addEventListener('input', function () { - const value = this.value.trim(); - chatcommandslist.innerHTML = ''; - chatcurrentFocus = -1; - if (!value.startsWith('/')) return; - Object.entries(chatcommands).forEach(([groupName, commands]) => { - - const filtered = commands.filter(cmd => cmd.name.startsWith(value)); - - if (filtered.length === 0) return; - - const groupTitle = document.createElement('div'); - groupTitle.textContent = groupName; - chatcommandslist.appendChild(groupTitle); - filtered.forEach(cmd => { - const item = document.createElement('div'); - item.classList.add('autocomplete-item'); - item.innerHTML = `${cmd.name} ${cmd.usage}`; - item.addEventListener('click', () => { - chatInput.value = cmd.name + ' '; - chatcommandslist.innerHTML = ''; - }); - chatcommandslist.appendChild(item); - }); - }); -}); - - -chatInput.addEventListener('keydown', function (e) { - const items = chatcommandslist.querySelectorAll('.autocomplete-item'); - - if (items.length === 0) return; - - if (e.key === 'ArrowDown') { - chatcurrentFocus++; - highlightItem(items); - } - else if (e.key === 'ArrowUp') { - chatcurrentFocus--; - highlightItem(items); - } - - else if (e.key === 'Enter') { - e.preventDefault(); - if (chatcurrentFocus > -1 && items[chatcurrentFocus]) { - items[chatcurrentFocus].click(); - } - } -}); - - -function highlightItem(items) { - if (!items) return; - - items.forEach(item => item.classList.remove('active')); - - if (chatcurrentFocus >= items.length) chatcurrentFocus = 0; - if (chatcurrentFocus < 0) chatcurrentFocus = items.length - 1; - - items[chatcurrentFocus].classList.add('active'); - items[chatcurrentFocus].scrollIntoView({ block: "nearest" }); -} - - -document.addEventListener('click', function (e) { - if (e.target !== chatcommandslist) { - chatcommandslist.innerHTML = ''; - } -}); - - -document.addEventListener("DOMContentLoaded", function () { - - const settingsPanel = document.querySelector('#chat-input .settings'); - - chatSettings.addEventListener('click', function () { - settingsPanel.classList.toggle('active'); - chatSettings.classList.toggle('active'); - }); - - - const checkboxNames = ["chatOnTwitch", "chatOnYouTube", "chatOnTiktok", "chatOnKick"]; - - // Restore checkbox states from localStorage - checkboxNames.forEach(name => { - const checkbox = document.querySelector(`input[name="${name}"]`); - const savedValue = localStorage.getItem(name); - if (checkbox && savedValue !== null) { - checkbox.checked = savedValue === "true"; - } - }); - - // Save state to localStorage on change - checkboxNames.forEach(name => { - const checkbox = document.querySelector(`input[name="${name}"]`); - if (checkbox) { - checkbox.addEventListener("change", function () { - localStorage.setItem(name, checkbox.checked); - }); - } - }); -}); diff --git a/js/chatrd.js b/js/chatrd.js new file mode 100644 index 0000000..e69de29 diff --git a/js/fourthwall/module.js b/js/fourthwall/module.js deleted file mode 100644 index f4e83e4..0000000 --- a/js/fourthwall/module.js +++ /dev/null @@ -1,322 +0,0 @@ -const showFourthwallDonations = getURLParam("showFourthwallDonations", true); - -const showFourthwallOrders = getURLParam("showFourthwallOrders", true); -const showFourthwallShowImage = getURLParam("showFourthwallShowImage", true); -const showFourthwallBigImage = getURLParam("showFourthwallBigImage", true); - -const showFourthwallSubscriptions = getURLParam("showFourthwallSubscriptions", true); - -const showFourthwallGiftPurchase = getURLParam("showFourthwallGiftPurchase", true); -const showFourthwallShowGiftImage = getURLParam("showFourthwallShowGiftImage", true); -const showFourthwallBigGiftImage = getURLParam("showFourthwallBigGiftImage", true); - -const showFourthwallGiftDraw = getURLParam("showFourthwallGiftDraw", true); -const fourthWallGiftDrawCommand = getURLParam("fourthWallGiftDrawCommand", "!enter"); - -const fourthwallMessageHandlers = { - 'Fourthwall.Donation': (response) => { - console.debug('Fourthwall Donation', response.data); - fourthwallDonationMessage(response.data); - }, - 'Fourthwall.OrderPlaced': (response) => { - console.debug('Fourthwall Order', response.data); - fourthwallOrderMessage(response.data); - }, - 'Fourthwall.SubscriptionPurchased': (response) => { - console.debug('Fourthwall Sub', response.data); - fourthwallSubMessage(response.data); - }, - 'Fourthwall.GiftPurchase': (response) => { - console.debug('Fourthwall Gift', response.data); - fourthwallGiftMessage(response.data); - }, - 'Fourthwall.GiftDrawStarted': (response) => { - console.debug('Fourthwall Gift Draw Start', response.data); - fourthwallGiftDrawStartMessage(response.data); - }, - 'Fourthwall.GiftDrawEnded': (response) => { - console.debug('Fourthwall Gift Draw Start', response.data); - fourthwallGiftDrawEndMessage(response.data); - }, -}; - -for (const [event, handler] of Object.entries(fourthwallMessageHandlers)) { - streamerBotClient.on(event, handler); -} - - -async function fourthwallDonationMessage(data) { - - if (showFourthwallDonations == false) return; - - const { - username : userName, - amount, - currency, - message: text - } = data; - - const userID = createRandomString(40); - const messageID = createRandomString(40); - - var money = formatCurrency(amount,currency); - - const [avatar, message] = await Promise.all([ - '', - currentLang.fourthwall.donation({ - money: money, - message: text - }), - ]); - - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'fourthwall', messageData); -} - - -async function fourthwallOrderMessage(data) { - - if (showFourthwallOrders == false) return; - - const username = data.username; - const total = data.total; - const currency = data.currency; - const item = data.variants[0].name; - const itemsQuantity = data.variants.length; - const text = stripStringFromHtml(data.statmessageus); - const imageUrl = data.variants[0].image; - - const userID = createRandomString(40); - const messageID = createRandomString(40); - - var userName = ''; - if (username == undefined) { userName = currentLang.fourthwall.someone(); } - else { userName = username; } - - var money = ''; - if (total == 0) { money = 0; } - else { money = formatCurrency(total,currency); } - - var fourthWallImage = ''; - if (showFourthwallShowImage == true) { - fourthWallImage = imageUrl - } - - const [avatar, message] = await Promise.all([ - '', - currentLang.fourthwall.order({ - money: money, - firstItem: item, - items: itemsQuantity, - message: text, - image: fourthWallImage - }), - ]); - - const classes = ['order']; - if (showFourthwallBigImage == true) { - classes.push('giantimage'); - } - - const messageData = { - classes: classes.join(' '), - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'fourthwall', messageData); -} - - -async function fourthwallSubMessage(data) { - - if (showFourthwallSubscriptions == false) return; - - const { - nickname : userName, - amount, - currency - } = data; - - const userID = createRandomString(40); - const messageID = createRandomString(40); - - var money = formatCurrency(amount,currency); - - const [avatar, message] = await Promise.all([ - '', - currentLang.fourthwall.donation({ - money: money - }), - ]); - - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'fourthwall', messageData); -} - - -async function fourthwallGiftMessage(data) { - - if (showFourthwallGiftPurchase == false) return; - - const userName = data.username; - const total = data.total; - const currency = data.currency; - const gifts = data.gifts.length; - const item = data.offer.name; - const imageUrl = data.offer.imageUrl; - const text = stripStringFromHtml(data.statmessageus); - - const userID = createRandomString(40); - const messageID = createRandomString(40); - - var money = ''; - if (total == 0) { money = 0; } - else { money = formatCurrency(total,currency); } - - var fourthWallImage = ''; - if (showFourthwallShowGiftImage == true) { - fourthWallImage = imageUrl - } - - const [avatar, message] = await Promise.all([ - '', - currentLang.fourthwall.gift({ - money: money, - firstItem: item, - items: gifts, - message: text, - image: fourthWallImage - }), - ]); - - const classes = ['order']; - if (showFourthwallBigGiftImage == true) { - classes.push('giantimage'); - } - - const messageData = { - classes: classes.join(' '), - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'fourthwall', messageData); -} - -async function fourthwallGiftDrawStartMessage(data) { - - if (showFourthwallGiftDraw == false) return; - - const { - offer: { - name: itemName - }, - durationSeconds - } = data; - - var userName = ''; - const userID = createRandomString(40); - const messageID = createRandomString(40); - - const [avatar, message] = await Promise.all([ - '', - currentLang.fourthwall.drawstart({ - gift: itemName, - command: fourthWallGiftDrawCommand, - time: durationSeconds - }), - ]); - - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'fourthwall', messageData); -} - -async function fourthwallGiftDrawEndMessage(data) { - - if (showFourthwallGiftDraw == false) return; - - const { - gifts - } = data; - - var userName = ''; - const userID = createRandomString(40); - const messageID = createRandomString(40); - - const [avatar, message] = await Promise.all([ - '', - currentLang.fourthwall.drawend({ - winners: await getWinnersList(gifts) - }), - ]); - - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'fourthwall', messageData); -} - - - - -async function getWinnersList(gifts) { - const winners = gifts.map(gift => gift.winner).filter(Boolean); // Remove null/undefined - - const numWinners = winners.length; - - if (numWinners === 0) { return ""; } - if (numWinners === 1) { return winners[0]; } - if (numWinners === 2) { return `${winners[0]} and ${winners[1]}`; } - - // For 3 or more, use the Oxford comma style: A, B, and C - const allButLast = winners.slice(0, -1).join(", "); - const lastWinner = winners[winners.length - 1]; - return `${allButLast}, and ${lastWinner}`; -} diff --git a/js/kick/module.js b/js/kick/module.js deleted file mode 100644 index 5bc30d3..0000000 --- a/js/kick/module.js +++ /dev/null @@ -1,569 +0,0 @@ -const kickUserName = getURLParam("kickUserName", false); - -const showKickMessages = getURLParam("showKickMessages", true); -const showKickFollows = getURLParam("showKickFollows", true); -const showKickSubs = getURLParam("showKickSubs", true); -const showKickGiftedSubs = getURLParam("showKickGiftedSubs", true); -const showKickMassGiftedSubs = getURLParam("showKickMassGiftedSubs", true); -const showKickRaids = getURLParam("showKickRaids", true); -const showKickViewers = getURLParam("showKickViewers", true); - -const kickAvatars = new Map(); -const kick7TVEmojis = new Map(); - -if (showKickViewers == false) { document.querySelector('#statistics #kick').style.display = 'none'; } - -if (kickUserName) { - - const kickWebSocket = new WebSocket( - `wss://ws-us2.pusher.com/app/32cbd69e4b950bf97679?protocol=7&client=js&version=8.4.0-rc2&flash=false` - ); - - kickWebSocket.onerror = (error) => { - console.error("Kick WebSocket Error: " + error); - }; - - kickWebSocket.onopen = () => { - - kickGetUserInfo(kickUserName) - .then((userInfo) => { - console.log('Got Kick User Info', userInfo); - - (async () => { - const kick7TVEmotes = await get7TVEmotes(userInfo.user_id); - if (kick7TVEmotes != null) { - console.debug("Getting all Kick's 7TV Emojis + Globals", kick7TVEmotes); - - kick7TVEmotes.forEach(emote => { - kick7TVEmojis.set(emote.name, emote.url); - }); - } - })(); - - kickWebSocket.send( - JSON.stringify({ - event: "pusher:subscribe", - data: { - auth: null, - channel: `chatrooms.${userInfo.chatroom.id}.v2` - }, - }) - ); - - kickWebSocket.send( - JSON.stringify({ - event: "pusher:subscribe", - data: { - auth: null, - channel: `channel.${userInfo.chatroom.channel_id}` - }, - }) - ); - - setInterval(() => { - kickWebSocket.send( - JSON.stringify({ - event: "pusher:ping", - data: {}, - }) - ); - }, 60000); - - kickUpdateStatistics(userInfo); - setInterval(() => { - kickGetUserInfo(kickUserName) - .then((data) =>{ - kickUpdateStatistics(data); - }); - }, 15000); - - - }); - - }; - - kickWebSocket.onmessage = async ({ data }) => { - const parsed = JSON.parse(data); - const json = JSON.parse(parsed.data); - - if (!parsed.event.includes("pusher")) { - - switch (parsed.event) { - case "App\\Events\\ChatMessageEvent": - console.debug('Kick Chat', json); - kickChatMessage(json); - break; - - case "App\\Events\\MessageDeletedEvent": - kickChatMessageDeleted(json); - break; - - case "App\\Events\\UserBannedEvent": - kickUserBanned(json); - break; - - case "App\\Events\\ChatroomClearEvent": - kickChatClearMessages() - break; - - default: - console.debug('Kick Event From WebSocket', parsed.event, json); - } - - } - }; -} - -else { - console.debug('Kick User not set in ChatRD'); -} - - - -streamerBotClient.on('General.Custom', (response) => { - - - if (response.data.platform === 'Kick') { - - const data = response.data.data; - - switch (data.triggerCustomCodeEventName) { - case "kickFollow" : - console.debug('Kick Follow', data); - kickFollowMessage(data); - break; - case "kickSub" : - console.debug('Kick Sub', data); - kickSubMessage(data); - break; - case "kickGift" : - console.debug('Kick Sub Gift', data); - kickGiftMessage(data); - break; - case "kickGifts" : - console.debug('Kick Mass Sub Gift', data); - kickGiftSubsMessage(data); - break; - case "kickIncomingRaid" : - console.debug('Kick Raid', data); - kickRaidMessage(data); - break; - default: - //console.debug('Kick Event', response.data); - } - } - - -}); - - -async function kickChatMessage(data) { - - if (showKickMessages == false) return; - if (ignoreUserList.includes(data.sender.username.toLowerCase())) return; - if (data.content.startsWith("!") && excludeCommands == true) return; - - const { - id: messageId, - type, - content: text, - sender: { - id: userID, - slug: userSlug, - username: userName, - identity: { - color, - badges: badgesToParse - } - } - - } = data; - - const [avatar, message, badges] = await Promise.all([ - getKickAvatar(userSlug), - getKickEmotes(text), - getKickBadges(badgesToParse), - ]); - - const replyHTML = (type == "reply" ? - `
${data.metadata.original_sender.username}: ${await getKickEmotes(data.metadata.original_message.content)}
` : ''); - - const messageData = { - classes: '', - avatar, - badges, - userName, - color, - message, - shared: '', - reply: replyHTML, - }; - - addMessageToChat(userSlug, messageId, 'kick', messageData); -} - - - - - -async function kickFollowMessage(data) { - - if (showKickFollows == false) return; - - const { - userName : userID, - user : userName - } = data; - - const messageID = createRandomString(40); - - const [avatar, message] = await Promise.all([ - '', - currentLang.kick.follow(), - ]); - - const classes = 'follow'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'kick', messageData); -} - - - -async function kickSubMessage(data) { - - if (showKickSubs == false) return; - - const { - userName: userID, - user: userName, - tier, - cumulative - } = data; - - const messageID = createRandomString(40); - const [avatar, message] = await Promise.all([ - '', - currentLang.kick.sub({ - months : cumulative, - tier : tier - }) - ]); - - const classes = 'sub'; - - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - addEventToChat(userID, messageID, 'kick', messageData); -} - - - - -async function kickGiftMessage(data) { - - if (showKickSubs == false || showKickGiftedSubs == false) return; - - const { - user: userName, - userName: userID, - recipientUser: recipientName, - tier, - totalSubsGifted - } = data; - - const messageID = createRandomString(40); - - const [avatar, message] = await Promise.all([ - '', - currentLang.kick.gifted({ - gifted : recipientName, - tier : tier, - total : totalSubsGifted - }) - ]); - - const classes = 'sub'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'kick', messageData); -} - - - - -async function kickGiftSubsMessage(data) { - - if (showKickSubs == false || showKickMassGiftedSubs == false) return; - - const { - user: userName, - userName: userID, - tier, - gifts - } = data; - - const messageID = createRandomString(40); - - const [avatar, message] = await Promise.all([ - '', - currentLang.kick.giftedbomb({ - count : gifts, - tier : tier - }) - ]); - - const classes = 'sub'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - addEventToChat(userID, messageID, 'kick', messageData); -} - - - - -async function kickRaidMessage(data) { - - if (showKickRaids == false) return; - - const { - user: userName, - viewers - } = data; - - const userID = userName.toLowerCase(); - - const messageID = createRandomString(40); - const [avatar, message] = await Promise.all([ - '', - currentLang.kick.raid({ viewers : viewers }) - ]); - - const classes = 'raid'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'kick', messageData); -} - - - -async function kickChatMessageDeleted(data) { - document.getElementById(data.message.id)?.remove(); -} - - - -async function kickUserBanned(data) { - chatContainer.querySelectorAll(`[data-user="${data.user.slug}"]:not(.event)`).forEach(element => { - element.remove(); - }); -} - - - -async function kickChatClearMessages() { - chatContainer.querySelectorAll(`.kick:not(.event)`).forEach(element => { - element.remove(); - }); -} - - - -async function kickUpdateStatistics(data) { - - if (showPlatformStatistics == false || showKickViewers == false) return; - - if (data.livestream == null) { } - else { - const viewers = DOMPurify.sanitize(data.livestream.viewer_count); - document.querySelector('#statistics #kick .viewers span').textContent = formatNumber(viewers); - } - -} - - - - -async function kickGetUserInfo(user) { - const response = await fetch( `https://kick.com/api/v2/channels/${user}` ); - - if (response.status === 404) { - console.error("Kick user was not found!"); - return 404; - } - else { - const data = await response.json(); - return data; - } - -} - - -async function getKickAvatar(user) { - if (showAvatar == true) { - if (kickAvatars.has(user)) { - console.debug(`Kick avatar found for ${user}!`); - return kickAvatars.get(user); - } - else { - console.debug(`Kick avatar not found for ${user}! Trying to get it...`); - - const response = await kickGetUserInfo(user); - var newavatar = ''; - - if (response == 404) { - newavatar = 'https://kick.com/img/default-profile-pictures/default2.jpeg'; - } - else { - if (response.user.profile_pic == null) { - newavatar = 'https://kick.com/img/default-profile-pictures/default2.jpeg'; - } - else { - newavatar = response.user.profile_pic; - newavatar = newavatar.replace(/fullsize(?=\.webp)/, "medium"); - } - kickAvatars.set(user, newavatar); - } - - return newavatar; - } - } - -} - - -async function getKickEmotes(text) { - var message = await parseKickEmojis(text); - message = await parseKick7TVEmotes(message); - return message; -} - -async function parseKickEmojis(content) { - const message = content; - const messagewithemotes = message.replace(/\[emote:(\d+):([^\]]+)\]/g, (_, id, name) => { - return `${name}`; - }); - - return messagewithemotes; -} - -async function parseKick7TVEmotes(text) { - const words = text.split(/\s+/); - const parsedWords = words.map(word => { - const clean = word.replace(/[^\w]/g, ''); // remove pontuaΓ§Γ£o para comparar - if (kick7TVEmojis.has(clean)) { - const url = kick7TVEmojis.get(clean); - return word.replace(clean, `${clean}`); - } - return word; - }); - - return parsedWords.join(' '); -} - -async function get7TVEmotes(userid) { - const userSet = await fetch(`https://7tv.io/v3/users/kick/${userid}`); - - if (userSet.status === 404) { - console.debug("7TV Profile based on this Kick user was not found"); - return null; - } - - const userEmojis = await userSet.json(); - - const gettingAllKick7TVEmotes = userEmojis?.emote_set?.emotes?.map(emote => ({ - name: emote.name, - id: emote.id, - url: `https://cdn.7tv.app/emote/${emote.id}/1x.webp` - })) || []; - - const globalSet = await fetch(`https://7tv.io/v3/emote-sets/global`); - const globalEmojis = await globalSet.json(); - - const gettingAllGlobal7TVEmotes = globalEmojis?.emotes?.map(emote => ({ - name: emote.name, - id: emote.id, - url: `https://cdn.7tv.app/emote/${emote.id}/1x.webp` - })) || []; - - const SevenTVEmotesFusion = [...gettingAllKick7TVEmotes, ...gettingAllGlobal7TVEmotes]; - return SevenTVEmotesFusion; -} - - - -async function getKickBadges(badges) { - const badgesArray = []; - - badges.forEach(badge => { - switch (badge.type) { - case "broadcaster": - badgesArray.push(''); - break; - case "sidekick": - badgesArray.push(''); - break; - case "moderator": - badgesArray.push(''); - break; - case "vip": - badgesArray.push(''); - break; - case "sub_gifter": - badgesArray.push(''); - break; - case "og": - badgesArray.push(''); - break; - case "founder": - badgesArray.push(''); - break; - case "subscriber": - badgesArray.push(''); - break; - case "verified": - badgesArray.push(''); - break; - } - }); - - return badgesArray.join(' '); -} \ No newline at end of file diff --git a/js/kofi/module.js b/js/kofi/module.js deleted file mode 100644 index 93087b3..0000000 --- a/js/kofi/module.js +++ /dev/null @@ -1,188 +0,0 @@ -const showKofiSubscriptions = getURLParam("showKofiSubscriptions", true); -const showKofiDonations = getURLParam("showKofiDonations", true); -const showKofiOrders = getURLParam("showKofiOrders", true); - -const kofiMessageHandlers = { - 'Kofi.Donation': (response) => { - console.debug('Kofi Donation', response.data); - kofiDonationMessage(response.data); - }, - 'Kofi.Subscription': (response) => { - console.debug('Kofi Sub', response.data); - kofiSubMessage(response.data); - }, - 'Kofi.Resubscription': (response) => { - console.debug('Kofi Resub', response.data); - kofiReSubMessage(response.data); - }, - 'Kofi.ShopOrder': (response) => { - console.debug('Kofi Order', response.data); - kofiOrderMessage(response.data); - }, -}; - -for (const [event, handler] of Object.entries(kofiMessageHandlers)) { - streamerBotClient.on(event, handler); -} - - -async function kofiDonationMessage(data) { - - if (showKofiDonations == false) return; - - const { - from : userName, - amount, - currency, - message: text - } = data; - - const userID = createRandomString(40); - const messageID = createRandomString(40); - - var money = formatCurrency(amount,currency); - - const [avatar, message] = await Promise.all([ - '', - currentLang.kofi.donation({ - money: money, - message: text - }), - ]); - - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'kofi', messageData); -} - - -async function kofiSubMessage(data) { - - if (showKofiSubscriptions == false) return; - - const { - from : userName, - amount, - currency, - message: text - } = data; - - const userID = createRandomString(40); - const messageID = createRandomString(40); - - var money = formatCurrency(amount,currency); - - const [avatar, message] = await Promise.all([ - '', - currentLang.kofi.sub({ - money: money, - message: text - }), - ]); - - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'kofi', messageData); -} - - -async function kofiReSubMessage(data) { - - if (showKofiSubscriptions == false) return; - - const { - from : userName, - amount, - currency, - tier, - message: text - } = data; - - const userID = createRandomString(40); - const messageID = createRandomString(40); - - var money = formatCurrency(amount,currency); - - const [avatar, message] = await Promise.all([ - '', - currentLang.kofi.resub({ - money: money, - tier: tier, - message: text - }), - ]); - - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'kofi', messageData); -} - - -async function kofiOrderMessage(data) { - - if (showKofiOrders == false) return; - const { - from : userName, - amount, - currency, - items - } = data; - - const userID = createRandomString(40); - const messageID = createRandomString(40); - - var money = ''; - - if (amount == 0) { money = 0; } - else { money = formatCurrency(amount,currency); } - - var itemsQuantity = items.length - - const [avatar, message] = await Promise.all([ - '', - currentLang.kofi.order({ - money: money, - items: itemsQuantity - }), - ]); - - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'kofi', messageData); -} \ No newline at end of file diff --git a/js/lang.js b/js/lang.js new file mode 100644 index 0000000..e69de29 diff --git a/js/lang/en.js b/js/lang/en.js deleted file mode 100644 index 7174052..0000000 --- a/js/lang/en.js +++ /dev/null @@ -1,166 +0,0 @@ -const en = { - streamerbotconnected: 'Streamer.bot Online!', - streamerbotdisconnected: 'Streamer.bot Disconnected!', - - ttschat: 'said', - - chatsendmessage: 'Send Message', - - twitch : { - firstMessage : () => `First chatter`, - follow : () => ` followed the channel`, - announcement : () => `
πŸ“’ Announcement
`, - channelpoints : ({ title }) => `
Channel Points - ${title}
`, - bits : ({ bits, message }) => ` cheered ${bits} bits${message ? '
'+message : ''}`, - - sub : ({ months, isPrime, tier }) => ` subscribed for - ${isPrime == true ? '' : ''} - ${months || 1 } ${months == 1 ? 'month' : 'months'} - (${isPrime == true ? 'Prime' : 'Tier '+tier.toString().charAt(0)})`, - - resub : ({ months, isPrime, tier, message }) => ` subscribed for - ${isPrime == true ? '' : ''} - ${months || 1 } ${months == 1 ? 'month' : 'months'} - (${isPrime == true ? 'Prime' : 'Tier '+tier.toString().charAt(0)}) - ${message ? '
'+message : '' }`, - - gifted : ({ gifted, months, tier }) => ` gifted - ${months || 1 } ${months == 1 ? 'month' : 'months'} - of Tier ${tier.toString().charAt(0)} ${months == 1 ? 'sub' : 'subs'} - to ${gifted}`, - - giftedbomb : ({ count, total, tier }) => ` gifted ${count} subs (Tier ${tier.toString().charAt(0)}) to the Community, ${total || 1} ${total == 1 ? 'gift' : 'gifts'} in total`, - - raid : ({ viewers }) => ` raided the channel with ${viewers} viewers` - - }, - - - youtube : { - superchat : ({ money, message }) => ` superchatted ${money} - ${message ? '
'+message : ''} - `, - - supersticker : ({ money, sticker }) => ` - ${sticker ? '
': ''} - sent a supersticker of ${money} - ${sticker ? '': ''} - `, - - member : ({ months, tier, message }) => ` became a member for - - ${months || 1 } ${months && months > 1 ? 'months' : 'month'} - (Tier ${tier}) - ${message ? '
'+message : ''}`, - - giftedmembers : ({ total, tier }) => ` gifted ${total} ${total == 1 ? 'membership' : 'memberships'} (Tier ${tier}) to the channel`, - - giftedtrainmembers : ({ gifted, tier }) => ` gifted a membership - (${tier}) - to ${gifted}`, - - }, - - - streamlabs : { - tip : ({ money, message }) => ` donated πŸͺ™ ${money}${message ? '
'+message : ''}`, - }, - - - streamelements : { - tip : ({ money, message }) => ` donated πŸͺ™ ${money}${message ? '
'+message : ''}`, - }, - - - tiktok : { - follow : () => ` followed the channel`, - likes : (likes) => `sent ${likes} likes`, - sub : ({ months }) => ` subscribed for ${months || 1 } ${(months && months > 1) ? 'months' : 'month'}`, - gift : ({ gift, count, coins }) => ` gifted ${gift} x${count} (πŸͺ™ ${coins} ${(coins && coins > 1) ? 'coins' : 'coin'})`, - - }, - - kick : { - follow : () => ` followed the channel`, - - sub : ({ months, tier }) => ` subscribed for - ${months || 1 } ${months == 1 ? 'month' : 'months'} - (Tier ${tier})`, - - gifted : ({ gifted, tier, total }) => ` gifted - ${total || 1 } ${total == 1 ? 'sub' : 'subs'} - (Tier ${tier}) - to ${gifted}`, - - giftedbomb : ({ count, tier }) => ` gifted ${count} subs (Tier ${tier}) to the Community`, - - raid : ({ viewers }) => ` raided the channel with ${viewers} viewers` - - }, - - patreon: { - membership: ({ money }) => ` pledged a membership ($${money})` - - }, - - tipeeestream : { - tip : ({ money, message }) => ` donated πŸͺ™ ${money}${message ? '
'+message : ''}`, - }, - - kofi : { - donation : ({ money, message }) => ` donated πŸͺ™ ${money}${message ? '
'+message : ''}`, - sub : ({ money, tier, message }) => ` subscribed (${money}) ${tier ? '(Tier '+tier+')' : ''}${message ? '
'+message : ''}`, - resub : ({ money, tier, message }) => ` resubscribed ${money} ${tier ? '(Tier '+tier+')' : ''}${message ? '
'+message : ''}`, - order : ({ money, items }) => ` ordered ${items} ${items == 1 ? 'item' : 'items'} (${money == 0 ? 'Free' : money})`, - }, - - fourthwall : { - someone : () => `Someone`, - - donation : ({ money, message }) => ` donated πŸͺ™ ${money}${message ? '
'+message : ''}`, - sub : ({ money }) => ` subscribed (${money})`, - - order : ({ - money, - firstItem, - items, - message, - image, - - }) => ` - ${image ? '
': ''} - ordered ${firstItem} ${items > 1 ? 'and '+(items - 1)+' other '+((items - 1) == 1 ? 'item' : 'items')+'' : ''} - (${money == 0 ? 'Free' : money}) - ${message.trim() ? '
'+message : ''} - ${image ? '': ''} - `, - - gift : ({ - money, - firstItem, - items, - message, - image, - - }) => ` - ${image ? '
': ''} - gifted ${items}x ${firstItem} - (${money == 0 ? 'Free' : money}) - ${message.trim() ? '
'+message : ''} - ${image ? '': ''} - `, - - - - drawstart : ({ gift, command, time }) => ` - Giveaway started! -
Type ${command} to have a chance to win ${gift}. You have ${time} seconds!`, - - drawend : ({ winners }) => ` - πŸŽ‰ Giveaway Ended! -
Congratulations ${winners}`, - - - - }, -} \ No newline at end of file diff --git a/js/lang/es.js b/js/lang/es.js deleted file mode 100644 index 038dfef..0000000 --- a/js/lang/es.js +++ /dev/null @@ -1,156 +0,0 @@ -const es = { - streamerbotconnected: 'Β‘Streamer.bot en lΓ­nea!', - streamerbotdisconnected: 'Β‘Streamer.bot desconectado!', - ttschat: 'dijo', - - chatsendmessage: 'Enviar mensaje', - - twitch : { - firstMessage : () => `Primeira mensaje`, - follow : () => ` siguiΓ³ el canal`, - announcement : () => `
πŸ“’ Anuncio
`, - channelpoints : ({ title }) => `
Puntos del canal - ${title}
`, - bits : ({ bits, message }) => ` enviΓ³ ${bits} bits${message ? '
'+message : ''}`, - - sub : ({ months, isPrime, tier }) => ` se suscribiΓ³ por - ${isPrime == true ? '' : ''} - ${months || 1 } ${months == 1 ? 'mes' : 'meses'} - (${isPrime == true ? 'Prime' : 'Tier '+tier.toString().charAt(0)})`, - - resub : ({ months, isPrime, tier, message }) => ` se volviΓ³ a suscribir por - ${isPrime == true ? '' : ''} - ${months || 1 } ${months == 1 ? 'mes' : 'meses'} - (${isPrime == true ? 'Prime' : 'Tier '+tier.toString().charAt(0)}) - ${message ? '
'+message : '' }`, - - gifted : ({ gifted, months, tier }) => ` regalΓ³ - ${months || 1 } ${months == 1 ? 'mes' : 'meses'} - de Tier ${tier.toString().charAt(0)} ${months == 1 ? 'suscripciΓ³n' : 'suscripciones'} - a ${gifted}`, - - giftedbomb : ({ count, total, tier }) => ` regalΓ³ ${count} suscripciones (Tier ${tier.toString().charAt(0)}) a la comunidad, ${total || 1} ${total == 1 ? 'regalo' : 'regalos'} en total`, - - raid : ({ viewers }) => ` hizo una raid al canal con ${viewers} espectadores` - }, - - youtube : { - superchat : ({ money, message }) => ` enviΓ³ un superchat ${money} - ${message ? '
'+message : ''} - `, - - supersticker : ({ money, sticker }) => ` - ${sticker ? '
': ''} - enviΓ³ un supersticker de ${money} - ${sticker ? '': ''} - `, - - member : ({ months, tier, message }) => ` se hizo miembro por - - ${months || 1 } ${months && months > 1 ? 'meses' : 'mes'} - (Tier ${tier}) - ${message ? '
'+message : ''}`, - - giftedmembers : ({ total, tier }) => ` regalΓ³ ${total} ${total == 1 ? 'membresΓ­a' : 'membresΓ­as'} (Tier ${tier}) al canal`, - - giftedtrainmembers : ({ gifted, tier }) => ` regalΓ³ una membresΓ­a - (Tier ${tier}) - a ${gifted}`, - }, - - streamlabs : { - tip : ({ money, message }) => ` donΓ³ πŸͺ™ ${money}${message ? '
'+message : ''}`, - }, - - streamelements : { - tip : ({ money, message }) => ` donΓ³ πŸͺ™ ${money}${message ? '
'+message : ''}`, - }, - - tiktok : { - follow : () => ` siguiΓ³ el canal`, - likes : (likes) => `enviΓ³ ${likes} likes`, - sub : ({ months }) => ` se suscribiΓ³ por ${months || 1 } ${(months && months > 1) ? 'meses' : 'mes'}`, - gift : ({ gift, count, coins }) => ` regalΓ³ ${gift} x${count} (πŸͺ™ ${coins} ${(coins && coins > 1) ? 'monedas' : 'moneda'})`, - }, - - kick : { - follow : () => ` siguiΓ³ el canal`, - - sub : ({ months, tier }) => ` se suscribiΓ³ por - ${months || 1 } ${months == 1 ? 'mes' : 'meses'} - (Tier ${tier})`, - - gifted : ({ gifted, tier, total }) => ` regalΓ³ - ${total || 1 } ${total == 1 ? 'suscripciΓ³n' : 'suscripciones'} - (Tier ${tier}) - a ${gifted}`, - - giftedbomb : ({ count, tier }) => ` regalΓ³ ${count} suscripciones (Tier ${tier}) a la comunidad`, - - raid : ({ viewers }) => ` hizo una raid al canal con ${viewers} espectadores` - - }, - - patreon: { - membership: ({ money }) => ` apoyΓ³ con una membresΓ­a ($${money})` - - }, - - tipeeestream : { - tip : ({ money, message }) => ` donΓ³ πŸͺ™ ${money}${message ? '
'+message : ''}`, - }, - - kofi : { - donation : ({ money, message }) => ` donΓ³ πŸͺ™ ${money}${message ? '
'+message : ''}`, - sub : ({ money, tier, message }) => ` se suscribiΓ³ (${money}) ${tier ? '(Tier '+tier+')' : ''}${message ? '
'+message : ''}`, - resub : ({ money, tier, message }) => ` renovΓ³ la suscripciΓ³n ${money} ${tier ? '(Tier '+tier+')' : ''}${message ? '
'+message : ''}`, - order : ({ money, items }) => ` comprΓ³ ${items} ${items == 1 ? 'artΓ­culo' : 'artΓ­culos'} (${money == 0 ? 'Gratis' : money})`, - }, - - fourthwall : { - someone : () => `Alguien`, - - donation : ({ money, message }) => ` donΓ³ πŸͺ™ ${money}${message ? '
'+message : ''}`, - sub : ({ money }) => ` se suscribiΓ³ (${money})`, - - order : ({ - money, - firstItem, - items, - message, - image, - - }) => ` - ${image ? '
': ''} - comprΓ³ ${firstItem} ${items > 1 ? 'y '+(items - 1)+' '+((items - 1) == 1 ? 'artΓ­culo' : 'artΓ­culos')+'' : ''} - (${money == 0 ? 'Gratis' : money}) - ${message.trim() ? '
'+message : ''} - ${image ? '': ''} - `, - - gift : ({ - money, - firstItem, - items, - message, - image, - - }) => ` - ${image ? '
': ''} - regalΓ³ ${items}x ${firstItem} - (${money == 0 ? 'Gratis' : money}) - ${message.trim() ? '
'+message : ''} - ${image ? '': ''} - `, - - - - drawstart : ({ gift, command, time }) => ` - Β‘Sorteo iniciado! -
Escribe ${command} para tener la oportunidad de ganar ${gift}. Β‘Tienes ${time} segundos!`, - - drawend : ({ winners }) => ` - πŸŽ‰ Β‘Sorteo finalizado! -
Felicitaciones ${winners}`, - }, -} - diff --git a/js/lang/lang.js b/js/lang/lang.js deleted file mode 100644 index 3d1e47b..0000000 --- a/js/lang/lang.js +++ /dev/null @@ -1,5 +0,0 @@ -const lang = { - ptbr : ptbr, - en : en, - es: es -} \ No newline at end of file diff --git a/js/lang/ptbr.js b/js/lang/ptbr.js deleted file mode 100644 index 344b58d..0000000 --- a/js/lang/ptbr.js +++ /dev/null @@ -1,162 +0,0 @@ -const ptbr = { - streamerbotconnected: 'Streamer.bot Conectado!', - streamerbotdisconnected: 'Streamer.bot Desconectado!', - ttschat: 'disse', - - chatsendmessage: 'Enviar mensagem', - - twitch : { - firstMessage : () => `Primeira mensagem`, - follow : () => ` seguiu o canal`, - announcement : () => `
πŸ“’ AnΓΊncio
`, - channelpoints : ({ title }) => `
Pontos do Canal - ${title}
`, - bits : ({ bits, message }) => ` doou ${bits} bits${message ? '
'+message : ''}`, - - sub : ({ months, isPrime, tier }) => ` se inscreveu por - ${isPrime == true ? '' : ''} - ${months || 1 } ${months == 1 ? 'mΓͺs' : 'meses'} - (${isPrime == true ? 'Prime' : 'Tier '+tier.toString().charAt(0)})`, - - resub : ({ months, isPrime, tier, message }) => ` se inscreveu por - ${isPrime == true ? '' : ''} - ${months || 1 } ${months == 1 ? 'mΓͺs' : 'meses'} - (${isPrime == true ? 'Prime' : 'Tier '+tier.toString().charAt(0)}) - ${message ? '
'+message : '' }`, - - gifted : ({ gifted, months, tier }) => ` doou - ${months || 1 } ${months == 1 ? 'mΓͺs' : 'meses'} - de Tier ${tier.toString().charAt(0)} - para ${gifted}`, - - giftedbomb : ({ count, total, tier }) => ` doou ${count} inscriΓ§Γ΅es (Tier ${tier.toString().charAt(0)}) para a Comunidade, totalizando ${total || 1} ${total == 1 ? 'doaΓ§Γ£o' : 'doaΓ§Γ΅es'}`, - - raid : ({ viewers }) => ` raidou o canal com ${viewers} pessoas` - - }, - - - youtube : { - superchat : ({ money, message }) => ` fez um superchat de ${money} - ${message ? '
'+message : ''} - `, - - supersticker : ({ money, sticker }) => ` - ${sticker ? '
': ''} - enviou um super sticker de ${money} - ${sticker ? '': ''} - `, - - member : ({ months, tier, message }) => ` se inscreveu por - - ${months || 1 } ${months && months > 1 ? 'meses' : 'mΓͺs'} - (Tier ${tier}) - ${message ? '
'+message : ''}`, - - giftedmembers : ({ total, tier }) => ` doou ${total} ${total == 1 ? 'inscriΓ§Γ£o' : 'inscriΓ§Γ΅es'} (Tier ${tier}) para o canal`, - - giftedtrainmembers : ({ gifted, tier }) => ` doou uma assinatura - (${tier}) - para ${gifted}`, - - }, - - - streamlabs : { - tip : ({ money, message }) => ` doou πŸͺ™ ${money}${message ? '
'+message : ''}`, - }, - - - streamelements : { - tip : ({ money, message }) => ` doou πŸͺ™ ${money}${message ? '
'+message : ''}`, - }, - - - tiktok : { - follow : () => ` seguiu o canal`, - likes : (likes) => `mandou ${likes} likes`, - sub : ({ months }) => ` se inscreveu por ${months || 1 } ${(months && months > 1) ? 'meses' : 'mΓͺs'}`, - gift : ({ gift, count, coins }) => ` doou ${gift} x${count} (πŸͺ™ ${coins} ${(coins && coins > 1) ? 'moedas' : 'moeda'})`, - - }, - - kick : { - follow : () => ` seguiu o canal`, - - sub : ({ months, tier }) => ` se inscreveu por - ${months || 1 } ${months == 1 ? 'mΓͺs' : 'meses'} - (Tier ${tier})`, - - gifted : ({ gifted, tier, total }) => ` doou - ${total || 1 } ${total == 1 ? 'inscriΓ§Γ£o' : 'inscriΓ§Γ΅es'} - (Tier ${tier}) - para ${gifted}`, - - giftedbomb : ({ count, tier }) => ` doou ${count} inscriΓ§Γ΅es (Tier ${tier}) para a Comunidade`, - - raid : ({ viewers }) => ` raidou o canal com ${viewers} pessoas` - - }, - - patreon: { - membership: ({ money }) => ` apoiou com uma assinatura ($${money})` - - }, - - tipeeestream : { - tip : ({ money, message }) => ` doou πŸͺ™ ${money}${message ? '
'+message : ''}`, - }, - - kofi : { - donation : ({ money, message }) => ` doou πŸͺ™ ${money}${message ? '
'+message : ''}`, - sub : ({ money, tier, message }) => ` se inscreveu (${money}) ${tier ? '(Tier '+tier+')' : ''}${message ? '
'+message : ''}`, - resub : ({ money, tier, message }) => ` se reninscreveu ${money} ${tier ? '(Tier '+tier+')' : ''}${message ? '
'+message : ''}`, - order : ({ money, items }) => ` comprou ${items} ${items == 1 ? 'item' : 'itens'} (${money == 0 ? 'GrΓ‘tis' : money})`, - }, - - fourthwall : { - someone : () => `AlguΓ©m`, - - donation : ({ money, message }) => ` doou πŸͺ™ ${money}${message ? '
'+message : ''}`, - sub : ({ money }) => ` se inscreveu (${money})`, - - order : ({ - money, - firstItem, - items, - message, - image, - - }) => ` - ${image ? '
': ''} - comprou ${firstItem} ${items > 1 ? 'e '+(items - 1)+' '+((items - 1) == 1 ? 'item' : 'items')+'' : ''} - (${money == 0 ? 'GrΓ‘tis' : money}) - ${message.trim() ? '
'+message : ''} - ${image ? '': ''} - `, - - gift : ({ - money, - firstItem, - items, - message, - image, - - }) => ` - ${image ? '
': ''} - presenteou ${items}x ${firstItem} - (${money == 0 ? 'GrΓ‘tis' : money}) - ${message.trim() ? '
'+message : ''} - ${image ? '': ''} - `, - - - - drawstart : ({ gift, command, time }) => ` - Sorteio iniciado! -
Digite ${command} para concorrer a ${gift}. VocΓͺ tem ${time} segundos!`, - - drawend : ({ winners }) => ` - πŸŽ‰ Sorteio Encerrado! -
ParabΓ©ns ${winners}`, - }, -} \ No newline at end of file diff --git a/js/patreon/module.js b/js/patreon/module.js deleted file mode 100644 index 415c820..0000000 --- a/js/patreon/module.js +++ /dev/null @@ -1,46 +0,0 @@ -const showPatreonMemberships = getURLParam("showPatreonMemberships", true); - -const patreonHandlers = { - 'Patreon.PledgeCreated': (response) => { - console.debug('Patreon Membership', response.data); - patreonMemberships(response.data); - }, -}; -for (const [event, handler] of Object.entries(patreonHandlers)) { - streamerBotClient.on(event, handler); -} - - - -async function patreonMemberships(data) { - - if (showPatreonMemberships == false) return; - - const { - attributes: { - full_name: userName, - will_pay_amount_cents: money - } - } = data; - - const userID = createRandomString(40); - const messageID = createRandomString(40); - - const [avatar, message] = await Promise.all([ - '', - currentLang.patreon.membership({ - money : (money / 100).toFixed(2) - }) - ]); - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - addEventToChat(userID, messageID, 'patreon', messageData); -} diff --git a/js/sb.js b/js/sb.js new file mode 100644 index 0000000..ae47216 --- /dev/null +++ b/js/sb.js @@ -0,0 +1,25 @@ +/* ----------------------- */ +/* STREAMER.BOT CONNECTION */ +/* ----------------------- */ + +const streamerBotServerAddress = "127.0.0.1"; +const streamerBotServerPort = "8080"; + +const streamerBotClient = new StreamerbotClient({ + host: streamerBotServerAddress, + port: streamerBotServerPort, + + onConnect: (data) => { + console.log(`Streamer.bot successfully connected!`) + console.debug(data); + + notifySuccess({ + title: 'Connected to Streamer.bot', + text: `` + }); + }, + + /*onDisconnect: () => { + console.error(`Streamer.bot disconnected`); + }*/ +}); \ No newline at end of file diff --git a/js/settings.js b/js/settings.js deleted file mode 100644 index 46c69b4..0000000 --- a/js/settings.js +++ /dev/null @@ -1,452 +0,0 @@ -let streamerBotClient; -let streamerBotConnected = false; - -async function saveSettingsToLocalStorage() { - const checkboxes = document.querySelectorAll("input[type=checkbox]:not(.avoid)"); - const textfields = document.querySelectorAll("input[type=text]:not(.avoid)"); - const numberfields = document.querySelectorAll("input[type=number]:not(.avoid)"); - const colorfields = document.querySelectorAll("input[type=color]:not(.avoid)"); - const selects = document.querySelectorAll("select:not(.avoid)"); - - const hiddenField = document.querySelector("textarea[name=youTubeCustomEmotes]:not(.avoid)"); - - const ranges = document.querySelectorAll("input[type=range]:not(.avoid)"); - - const settings = {}; - - checkboxes.forEach((checkbox) => { - settings[checkbox.name] = checkbox.checked; - }); - ranges.forEach((range) => { - settings[range.name] = range.value; - }); - textfields.forEach((textfield) => { - settings[textfield.name] = textfield.value; - }); - numberfields.forEach((numberfield) => { - settings[numberfield.name] = numberfield.value; - }); - colorfields.forEach((colorfield) => { - settings[colorfield.name] = colorfield.value; - }); - selects.forEach((select) => { - settings[select.name] = select.value; - }); - - localStorage.setItem("chatWidgetSettings", JSON.stringify(settings)); - - if (streamerBotConnected == true) { - streamerBotClient.doAction( - { name : "YouTube Custom Emotes" }, - { - "chatrdytcustomemotes": JSON.stringify(hiddenField.value.trim()), - } - ).then( (setglobals) => { - console.debug('Saving YouTube Emotes from Streamer.Bot', setglobals); - }); - } - -} - - -async function loadSettingsFromLocalStorage() { - const saved = localStorage.getItem("chatWidgetSettings"); - if (!saved) return; - - const settings = JSON.parse(saved); - console.log(settings); - - Object.keys(settings).forEach((key) => { - const input = document.querySelector(`[name="${key}"]`); - if (input) { - if (input.type === "checkbox") { - input.checked = settings[key]; - } - else { - input.value = settings[key]; - } - } - }); - - - document.querySelector('#font-value').textContent = Math.floor(document.querySelector('#font-slider').value * 100) + '%'; - - - var streamerBotServerAddress = document.querySelector('input[type=text][name=streamerBotServerAddress]').value; - var streamerBotServerPort = document.querySelector('input[type=text][name=streamerBotServerPort]').value; - - streamerBotClient = new StreamerbotClient({ - host: streamerBotServerAddress, - port: streamerBotServerPort, - onConnect: (data) => { - streamerBotConnected = true; - - document.querySelector('#memberemotesbstatus').classList.remove('offline'); - document.querySelector('#memberemotesbstatus').classList.add('online'); - document.querySelector('#memberemotesbstatus span').textContent = 'Streamer.Bot is Online!'; - - streamerBotClient.getGlobals().then( (getglobals) => { - const settings = JSON.parse(getglobals.variables.chatrdytcustomemotes.value); - console.debug('Getting YouTube Emotes from Streamer.Bot', settings); - const textarea = document.querySelector("textarea[name=youTubeCustomEmotes]"); - textarea.value = settings; - - populateEmoteList(); - }); - - }, - onDisconnect: () => { - console.error('Streamer.bot Disconnected!'); - - streamerBotConnected = false; - - document.querySelector('#memberemotesbstatus').classList.remove('online'); - document.querySelector('#memberemotesbstatus').classList.add('offline'); - document.querySelector('#memberemotesbstatus span').textContent = 'Streamer.Bot is Offline!'; - } - }); - -} - - -async function pushChangeEvents() { - const checkboxes = document.querySelectorAll("input[type=checkbox]:not(.avoid)"); - const textfields = document.querySelectorAll("input[type=text]:not(.avoid)"); - const numberfields = document.querySelectorAll("input[type=number]:not(.avoid)"); - const colorfields = document.querySelectorAll("input[type=color]:not(.avoid)"); - const selects = document.querySelectorAll("select:not(.avoid)"); - - const ranges = document.querySelectorAll("input[type=range]:not(.avoid)"); - - checkboxes.forEach((checkbox) => { - checkbox.addEventListener('change', () => { - generateUrl(); - saveSettingsToLocalStorage(); - }); - }); - textfields.forEach((textfield) => { - textfield.addEventListener('input', () => { - generateUrl(); - saveSettingsToLocalStorage(); - }); - }); - numberfields.forEach((numberfield) => { - numberfield.addEventListener('input', () => { - generateUrl(); - saveSettingsToLocalStorage(); - }); - }); - colorfields.forEach((colorfield) => { - colorfield.addEventListener('change', () => { - generateUrl(); - saveSettingsToLocalStorage(); - }); - }); - selects.forEach((select) => { - select.addEventListener('change', () => { - generateUrl(); - saveSettingsToLocalStorage(); - }); - }); - textfields.forEach((textfield) => { - textfield.addEventListener('input', () => { - generateUrl(); - saveSettingsToLocalStorage(); - }); - }); - - ranges.forEach((range) => { - range.addEventListener('change', () => { - generateUrl(); - saveSettingsToLocalStorage(); - }); - }); - - document.querySelector('#font-slider').addEventListener('input', function () { - document.querySelector('#font-value').textContent = Math.floor(this.value * 100) + '%'; - }); - - document.querySelector('#bg-opacity-slider').addEventListener('input', function () { - document.querySelector('#bg-opacity-value').textContent = this.value; - }); -} - - -async function generateUrl() { - document.getElementById("outputUrl").value = ''; - - - var baseUrl = 'https://vortisrd.github.io/chatrd/chat.html'; - - const checkboxes = document.querySelectorAll("input[type=checkbox]:not(.avoid)"); - const textfields = document.querySelectorAll("input[type=text]:not(.avoid)"); - const numberfields = document.querySelectorAll("input[type=number]:not(.avoid)"); - const colorfields = document.querySelectorAll("input[type=color]:not(.avoid)"); - const selects = document.querySelectorAll("select:not(.avoid)"); - - const ranges = document.querySelectorAll("input[type=range]:not(.avoid)"); - - const params = new URLSearchParams(); - - selects.forEach((select) => { - params.set(select.name, select.value); - }); - ranges.forEach((range) => { - params.set(range.name, range.value); - }); - checkboxes.forEach((checkbox) => { - params.set(checkbox.name, checkbox.checked); - }); - colorfields.forEach((colorfield) => { - params.set(colorfield.name, colorfield.value); - }); - textfields.forEach((textfield) => { - params.set(textfield.name, textfield.value); - }); - numberfields.forEach((numberfield) => { - params.set(numberfield.name, numberfield.value); - }); - - document.getElementById("outputUrl").value = baseUrl + '?' + params.toString(); - document.querySelector('#chat-preview iframe').src = 'chat.html?'+params.toString(); -} - -async function copyUrl() { - - const output = document.getElementById("outputUrl") - const value = output.value; - - const button = document.querySelector('.url-bar button'); - const buttonDefaulText = 'Copy URL'; - - navigator.clipboard.writeText(value) - .then(() => { - - button.textContent = 'ChatRD URL Copied!'; - button.style.backgroundColor = "#00dd63"; - - setTimeout(() => { - button.textContent = buttonDefaulText; - button.removeAttribute('style'); - }, 3000); - }) - .catch(err => { - console.error("Failed to copy: ", err); - }); - -} - - -async function setupAddEmoteModal() { - const modal = document.getElementById("addEmoteModal"); - const nameInput = document.getElementById("newEmoteName"); - const urlInput = document.getElementById("newEmoteURL"); - const confirmBtn = document.getElementById("confirmAddEmote"); - const cancelBtn = document.getElementById("cancelAddEmote"); - const addButton = document.querySelector("#youtube .emote-item:last-child .add"); - const textarea = document.querySelector("textarea[name=youTubeCustomEmotes]"); - - if (!modal || !addButton || !textarea) return; - - // Show modal - addButton.onclick = () => { - if (streamerBotConnected == true) { - nameInput.value = ""; - urlInput.value = ""; - modal.classList.remove("hidden"); - nameInput.focus(); - } - else { - alert("Streamer.bot is Offline!"); - return; - } - }; - - // Cancel - cancelBtn.onclick = () => { - modal.classList.add("hidden"); - }; - - // Confirm - confirmBtn.onclick = () => { - const name = nameInput.value.trim(); - const url = urlInput.value.trim(); - - if (!name || !url) { - alert("Both fields are required."); - return; - } - - let emotes; - try { - emotes = JSON.parse(textarea.value); - } catch (err) { - console.error("Invalid JSON", err); - alert("Emote data is invalid."); - return; - } - - if (emotes[name]) { - alert(`Emote "${name}" already exists.`); - return; - } - - // Add and update - emotes[name] = url; - textarea.value = JSON.stringify(emotes, null, 4); - modal.classList.add("hidden"); - populateEmoteList(); - }; -} - - - -async function populateEmoteList() { - const textarea = document.querySelector("textarea[name=youTubeCustomEmotes]"); - const emoteList = document.querySelector("#youtube .emote-list"); - - if (!textarea || !emoteList) return; - - const addButtonSpan = emoteList.querySelector(".emote-item:last-child"); - - // Remove all emote items except the add button - emoteList.querySelectorAll(".emote-item").forEach(item => { - if (item !== addButtonSpan) { - item.remove(); - } - }); - - let emotes; - try { - emotes = JSON.parse(textarea.value); - } catch (e) { - console.error("Invalid JSON in YouTube Emotes textarea", e); - return; - } - - // Recreate each emote item - for (const [emoteName, emoteUrl] of Object.entries(emotes)) { - const span = document.createElement("span"); - span.classList.add("emote-item"); - span.innerHTML = ` - - ${emoteName} - - `; - - // Add delete handler directly to the button - const deleteBtn = span.querySelector(".delete"); - deleteBtn.addEventListener("click", () => { - if (confirm(`Are you sure you want to delete '${emoteName}'?`)) { - delete emotes[emoteName]; - textarea.value = JSON.stringify(emotes, null, 4); - populateEmoteList(); // Re-render everything - } - }); - - emoteList.insertBefore(span, addButtonSpan); - } - - setupAddEmoteModal(); - generateUrl(); - saveSettingsToLocalStorage(); -} - - - -const accordionButtons = document.querySelectorAll("button.accordion"); - -accordionButtons.forEach(button => { - button.addEventListener("click", () => { - const targetId = button.getAttribute("data-target"); - const target = document.getElementById(targetId); - const icon = button.querySelector("i"); - - if (!target || !target.classList.contains("accordion-container")) return; - - const isOpen = target.classList.contains("open"); - - // Fecha todos os outros accordions - document.querySelectorAll(".accordion-container.open").forEach(container => { - if (container !== target) { - container.classList.remove("open"); - container.style.maxHeight = null; - - const otherButton = document.querySelector(`button.accordion[data-target="${container.id}"]`); - if (otherButton) { - const otherIcon = otherButton.querySelector("i"); - if (otherIcon) otherIcon.className = "fa-solid fa-chevron-down"; - } - } - }); - - // Alterna o atual - if (!isOpen) { - target.classList.add("open"); - target.style.maxHeight = target.scrollHeight + "px"; - if (icon) icon.className = "fa-solid fa-chevron-up"; - - // Espera a animaΓ§Γ£o terminar para scrollar - target.addEventListener("transitionend", function handler(e) { - if (e.propertyName === "max-height") { - target.removeEventListener("transitionend", handler); - - const offset = target.getBoundingClientRect().top + window.scrollY - 60; - window.scrollTo({ - top: offset, - behavior: "smooth" - }); - } - }); - } - - else { - target.classList.remove("open"); - target.style.maxHeight = null; - if (icon) icon.className = "fa-solid fa-chevron-down"; - } - }); -}); - - - - - - - -window.addEventListener('load', () => { - loadSettingsFromLocalStorage(); - generateUrl(); - pushChangeEvents(); - populateEmoteList(); - - - document.querySelectorAll('.nav-bar a').forEach(anchor => { - anchor.addEventListener('click', function (e) { - e.preventDefault(); - - // Remove todas as classes dos links dentro da nav-bar - document.querySelectorAll('.nav-bar a').forEach(link => { - link.classList.remove('active'); - }); - - this.classList.add('active'); - - const targetId = this.getAttribute('href'); - const targetElement = document.querySelector(targetId); - - if (targetElement) { - - const offset = 60; // ajusta 20px acima - const y = targetElement.getBoundingClientRect().top + window.scrollY - offset; - - window.scrollTo({ - top: y, - behavior: 'smooth' - }); - } - }); - }); - - -}); diff --git a/js/streamelements/module.js b/js/streamelements/module.js deleted file mode 100644 index 94f4131..0000000 --- a/js/streamelements/module.js +++ /dev/null @@ -1,46 +0,0 @@ -const showStreamElementsTips = getURLParam("showStreamElementsTips", true); - -const streamElementsHandlers = { - 'StreamElements.Tip': (response) => { - console.debug('StreamElements Event', response.data); - streamElementsEventMessage(response.data); - }, -}; -for (const [event, handler] of Object.entries(streamElementsHandlers)) { - streamerBotClient.on(event, handler); -} - - - -async function streamElementsEventMessage(data) { - - if (showStreamElementsTips == false) return; - - const { - username: userName, - amount: moneyFromUser, - currency: currencyFromUser, - message: messageFromUser, - } = data; - - const userID = createRandomString(40); - const messageID = createRandomString(40); - const [avatar, message] = await Promise.all([ - '', - currentLang.streamlabs.tip({ - money : formatCurrency(moneyFromUser,currencyFromUser), - message : messageFromUser - }) - ]); - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - addEventToChat(userID, messageID, 'streamelements', messageData); -} diff --git a/js/streamlabs/module.js b/js/streamlabs/module.js deleted file mode 100644 index f357bca..0000000 --- a/js/streamlabs/module.js +++ /dev/null @@ -1,44 +0,0 @@ -const showStreamlabsDonations = getURLParam("showStreamlabsDonations", true); - -const streamLabsHandlers = { - 'Streamlabs.Donation': (response) => { - console.debug('StreamLabs Event', response.data); - streamLabsEventMessage(response.data); - }, -}; -for (const [event, handler] of Object.entries(streamLabsHandlers)) { - streamerBotClient.on(event, handler); -} - -async function streamLabsEventMessage(data) { - - if (showStreamlabsDonations == false) return; - - const { - from: userName, - formattedAmount: moneyFromUser, - currency: currencyFromUser, - message: messageFromUser, - } = data; - - const userID = createRandomString(40); - const messageID = createRandomString(40); - const [avatar, message] = await Promise.all([ - '', - currentLang.streamlabs.tip({ - money : formatCurrency(moneyFromUser,currencyFromUser), - message : messageFromUser - }) - ]); - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - addEventToChat(userID, messageID, 'streamlabs', messageData); -} \ No newline at end of file diff --git a/js/tiktok/module.js b/js/tiktok/module.js deleted file mode 100644 index 4a61f8f..0000000 --- a/js/tiktok/module.js +++ /dev/null @@ -1,283 +0,0 @@ -/* ----------------------------------------------------------------------------------------- */ -/* TikFinity >< Streamer.Bot */ -/* ----------------------------------------------------------------------------------------- */ -/* In Streamer.bot, go into Servers/Clients, then Websocket clients, */ -/* and add the server info for TikFinity Desktop App. */ -/* ----------------------------------------------------------------------------------------- */ -/* If it's also running on the same computer, the address will be: ws://127.0.0.1:21213/ */ -/* ----------------------------------------------------------------------------------------- */ - -const showTikTokMessages = getURLParam("showTikTokMessages", true); -const showTikTokFollows = getURLParam("showTikTokFollows", true); -const showTikTokLikes = getURLParam("showTikTokLikes", true); -const showTikTokGifts = getURLParam("showTikTokGifts", true); -const showTikTokSubs = getURLParam("showTikTokSubs", true); -const showTikTokStatistics = getURLParam("showTikTokStatistics", true); - -userColors.set('tiktok', new Map()); - -if (showTikTokStatistics == false) { document.querySelector('#statistics #tiktok').style.display = 'none'; } - - - -streamerBotClient.on('General.Custom', (response) => { - if (response.data.platform === 'TikTok') { - - let json = response.data; - let jsonData = json.data.data; - - switch (json.data.event) { - case 'roomUser' : - tiktokUpdateStatistics(jsonData, 'viewers'); - break; - case 'like' : - tiktokUpdateStatistics(jsonData, 'likes'); - //console.log('TikTok Likes', jsonData); - tiktokLikesMessage(jsonData); - break; - case 'chat' : - console.log('TikTok Chat', jsonData); - tiktokChatMessage(jsonData); - break; - case 'follow' : - console.log('TikTok Follow', jsonData); - tiktokFollowMessage(jsonData); - break; - case 'subscribe' : - console.log('TikTok Sub', jsonData); - tiktokSubMessage(jsonData); - break; - case 'gift' : - console.log('TikTok Gift', jsonData); - tiktokGiftMessage(jsonData); - break; - default: - //console.debug(json); - } - } - -}); - - - - -async function tiktokChatMessage(data) { - - if (showTikTokMessages == false) return; - if (ignoreUserList.includes(data.nickname.toLowerCase())) return; - if (data.comment.startsWith("!") && excludeCommands == true) return; - - - const { - userId: userID, - msgId: messageID, - profilePictureUrl: avatar, - comment: message, - emotes, - nickname: userName, - isSubscriber, - isModerator, - } = data; - - const badgesHTML = [ - isSubscriber && '', - isModerator && '', - ].filter(Boolean).join(''); - - const classes = [ - isSubscriber && 'sub', - isModerator && 'mod', - ].filter(Boolean); - - var fullmessage = message; - - if (emotes.length > 0) { - emotes.forEach(emote => { - var emotetoadd = ` `; - var position = emote.placeInComment; - fullmessage = [fullmessage.slice(0, position), emotetoadd, fullmessage.slice(position)].join(''); - }); - } - - const messageData = { - classes: classes.join(' '), - avatar, - badges: badgesHTML, - userName, - color: await createRandomColor('tiktok', userID), - message: fullmessage, - reply: '', - }; - - addMessageToChat(userID, messageID, 'tiktok', messageData); -} - - - -async function tiktokFollowMessage(data) { - - if (showTikTokFollows == false) return; - - const { - userId: userID, - msgId: messageID, - profilePictureUrl: avatar, - nickname: userName, - } = data; - - const message = currentLang.tiktok.follow(); - const classes = 'follow' - - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'tiktok', messageData); -} - - - - -async function tiktokLikesMessage(data) { - - if (showTikTokLikes == false) return; - - const { - userId: userID, - msgId: messageID, - profilePictureUrl: avatar, - nickname: userName, - likeCount: likesSent - } = data; - - var likeCountTotal = parseInt(likesSent); - - // Search for Previous Likes from the Same User - const previousLikeContainer = chatContainer.querySelector(`div.message.likes[data-user="${userID}"]`); - - // If found, fetches the previous likes, deletes the element - // and then creates a new count with a sum of the like count - if (previousLikeContainer) { - const likeCountElem = previousLikeContainer.querySelector('.likecount'); - if (likeCountElem) { - var likeCountPrev = parseInt(likeCountElem.textContent); - likeCountTotal = Math.floor(likeCountPrev + likeCountTotal); - previousLikeContainer.remove(); - } - } - - - const message = currentLang.tiktok.likes(likeCountTotal) - const classes = 'likes' - - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'tiktok', messageData); -} - - - - -async function tiktokSubMessage(data) { - - if (showTikTokSubs == false) return; - - const { - userId: userID, - msgId: messageID, - profilePictureUrl: avatar, - nickname: userName, - } = data; - - const message = currentLang.tiktok.sub({ - months : data.subMonth - }); - - const classes = 'sub' - - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'tiktok', messageData); -} - - - -async function tiktokGiftMessage(data) { - - if (showTikTokGifts == false) return; - if (data.giftType === 1 && !data.repeatEnd) {} - else { - const { - userId: userID, - msgId: messageID, - profilePictureUrl: avatar, - nickname: userName, - } = data; - - var coins = Math.floor(data.repeatCount*data.diamondCount); - - const message = currentLang.tiktok.gift({ - gift : data.giftName, - count : data.repeatCount, - coins : coins - }); - - const classes = 'gift' - - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'tiktok', messageData); - } -} - - - - - - -async function tiktokUpdateStatistics(data, type) { - - if (showPlatformStatistics == false || showTikTokStatistics == false) return; - - if (type == 'viewers') { - const viewers = DOMPurify.sanitize(data.viewerCount); - document.querySelector('#statistics #tiktok .viewers span').textContent = formatNumber(viewers); - } - - if (type == 'likes') { - const likes = DOMPurify.sanitize(data.totalLikeCount); - document.querySelector('#statistics #tiktok .likes span').textContent = formatNumber(likes); - } - - -} \ No newline at end of file diff --git a/js/tipeeestream/module.js b/js/tipeeestream/module.js deleted file mode 100644 index cf5d310..0000000 --- a/js/tipeeestream/module.js +++ /dev/null @@ -1,47 +0,0 @@ -const showTipeeeDonations = getURLParam("showTipeeeDonations", true); - -const tipeeeHandlers = { - 'TipeeeStream.Donation': (response) => { - console.debug('TipeeeStream Donation', response.data); - tipeeeStreamDonation(response.data); - }, -}; -for (const [event, handler] of Object.entries(tipeeeHandlers)) { - streamerBotClient.on(event, handler); -} - - - -async function tipeeeStreamDonation(data) { - - if (showTipeeeDonations == false) return; - - const { - user: userName, - amount, - currency, - message: text - } = data; - - const userID = createRandomString(40); - const messageID = createRandomString(40); - - const [avatar, message] = await Promise.all([ - '', - currentLang.tipeeestream.tip({ - money : formatCurrency(amount,currency), - message: text - }) - ]); - const classes = ''; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - addEventToChat(userID, messageID, 'tipeeestream', messageData); -} diff --git a/js/twitch/module.js b/js/twitch/module.js deleted file mode 100644 index 8106af5..0000000 --- a/js/twitch/module.js +++ /dev/null @@ -1,640 +0,0 @@ -const showTwitchMessages = getURLParam("showTwitchMessages", true); -const showTwitchFollows = getURLParam("showTwitchFollows", true); -const showTwitchBits = getURLParam("showTwitchBits", true); -const showTwitchAnnouncements = getURLParam("showTwitchAnnouncements", true); -const showTwitchSubs = getURLParam("showTwitchSubs", true); -const showTwitchGiftedSubs = getURLParam("showTwitchGiftedSubs", true); -const showTwitchGiftedSubsUserTrain = getURLParam("showTwitchGiftedSubsUserTrain", true); -const showTwitchMassGiftedSubs = getURLParam("showTwitchMassGiftedSubs", true); -const showTwitchRewardRedemptions = getURLParam("showTwitchRewardRedemptions", true); -const showTwitchRaids = getURLParam("showTwitchRaids", true); -const showTwitchSharedChat = getURLParam("showTwitchSharedChat", true); -const showTwitchPronouns = getURLParam("showTwitchPronouns", false); -const showTwitchViewers = getURLParam("showTwitchViewers", true); - -const avatars = new Map(); -const pronouns = new Map(); - -if (showTwitchViewers == false) { document.querySelector('#statistics #twitch').style.display = 'none'; } - -const twitchMessageHandlers = { - 'Twitch.ChatMessage': (response) => { - console.debug('Twitch Chat', response.data); - twitchChatMessage(response.data); - }, - 'Twitch.Follow': (response) => { - console.debug('Twitch Follow', response.data); - twitchFollowMessage(response.data); - }, - 'Twitch.Announcement': (response) => { - console.debug('Twitch Announcements', response.data); - twitchAnnouncementMessage(response.data); - }, - 'Twitch.Cheer': (response) => { - console.debug('Twitch Cheer/Bits', response.data); - twitchBitsMessage(response.data); - }, - 'Twitch.AutomaticRewardRedemption': (response) => { - console.debug('Twitch Auto Reward Redemption', response.data); - twitchChatMessageGiantEmote(response.data); - }, - 'Twitch.RewardRedemption': (response) => { - console.debug('Twitch Reward Redemption', response.data); - twitchRewardRedemption(response.data); - }, - 'Twitch.Sub': (response) => { - console.debug('Twitch Sub', response.data); - twitchSubMessage(response.data); - }, - 'Twitch.ReSub': (response) => { - console.debug('Twitch Resub', response.data); - twitchReSubMessage(response.data); - }, - 'Twitch.GiftSub': (response) => { - console.debug('Twitch Gift Sub', response.data); - twitchGiftMessage(response.data); - - }, - 'Twitch.GiftBomb': (response) => { - console.debug('Twitch Gift Bomb', response.data); - twitchGiftSubsMessage(response.data); - }, - 'Twitch.Raid': (response) => { - console.debug('Twitch Raid', response.data); - twitchRaidMessage(response.data); - }, - 'Twitch.ChatMessageDeleted': (response) => { - console.debug('Twitch Chat Deleted', response.data); - twitchChatMessageDeleted(response.data); - }, - 'Twitch.UserBanned': (response) => { - console.debug('Twitch Ban', response.data); - twitchUserBanned(response.data); - }, - 'Twitch.UserTimedOut': (response) => { - console.debug('Twitch Timeout', response.data); - twitchUserBanned(response.data); - }, - 'Twitch.ViewerCountUpdate': (response) => { - console.debug('Twitch View Count Update', response.data); - twitchUpdateStatistics(response.data); - }, - 'Twitch.ChatCleared': (response) => { - console.debug('Twitch Chat Clear', response.data); - twitchChatClearMessages(); - } -}; - -for (const [event, handler] of Object.entries(twitchMessageHandlers)) { - streamerBotClient.on(event, handler); -} - - -async function twitchChatMessage(data) { - - if (showTwitchMessages == false) return; - if (ignoreUserList.includes(data.message.username.toLowerCase())) return; - if (data.message.message.startsWith("!") && excludeCommands == true) return; - - const { - message: { - username: userID, - color, - displayName: fullUserName, - message : text, - firstMessage, - isReply, - reply: replyData, - }, - isSharedChat, - messageId, - } = data; - - const [avatar, message, badges] = await Promise.all([ - getTwitchAvatar(userID), - getTwitchEmotes(data), - getTwitchBadges(data), - ]); - - const classes = firstMessage ? ['first-message'] : []; - - if (data.user.role == 4) { - classes.push('streamer'); - } - - const replyHTML = isReply ? - `
${replyData.userName}: ${replyData.msgBody}
` : - ''; - - var sharedChat = ''; - if (isSharedChat) { - if (showTwitchSharedChat == true) { - if (!data.sharedChat.primarySource) - { - var sharedChat = `
- ${data.sharedChat.sourceRoom.name} - -
`; - } - } - else if (!data.sharedChat.primarySource && showTwitchSharedChat == false) { - return; - } - } - - let userName = fullUserName; - - if (showTwitchPronouns == true) { - let userPronouns = await getUserPronouns('twitch', data.message.username); - userName = userPronouns + fullUserName; - } - - const messageData = { - classes: classes.join(' '), - avatar, - badges, - userName, - color, - message, - shared: sharedChat, - reply: replyHTML, - }; - - addMessageToChat(userID, messageId, 'twitch', messageData); -} - - - -async function twitchChatMessageGiantEmote(data) { - - if (showTwitchMessages == false) return; - - const { - user_login: userID, - gigantified_emote: { id: emoteGigantify } - } = data; - const userMessages = chatContainer.querySelectorAll(`.twitch.message[data-user="${userID}"]`); - - if (userMessages.length === 0) return; - - const firstMessage = userMessages[0]; - const emoteImages = firstMessage.querySelectorAll(`img[data-emote-id="${emoteGigantify}"]`); - - if (emoteImages.length === 0) return; - - emoteImages.forEach(img => { - img.classList.add("gigantify"); - if (img.src.endsWith("2.0")) { - img.src = img.src.replace("2.0", "3.0"); - } - }); -} - - - -async function twitchFollowMessage(data) { - - if (showTwitchFollows == false) return; - - const { - user_id : userID, - user_name : userName - } = data; - - const messageID = createRandomString(40); - - const [avatar, message] = await Promise.all([ - '', - currentLang.twitch.follow(), - ]); - - const classes = 'follow'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'twitch', messageData); -} - - - -async function twitchBitsMessage(data) { - - if (showTwitchBits == false) return; - - const { - messageId : messageID, - user : { - id : userID, - name : userName - } - } = data; - - data.message.message = data.message.message.replace(/\bCheer\d+\b/g, '').replace(/\s+/g, ' ').trim(); - - const [avatar, message] = await Promise.all([ - '', - currentLang.twitch.bits({ - bits: data.message.bits, - message : await getTwitchEmotes(data) - }), - ]); - - const classes = 'bits'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'twitch', messageData); -} - - - -async function twitchAnnouncementMessage(data) { - - if (showTwitchAnnouncements == false) return; - - const { - messageId : messageID, - user : { - id : userID, - name : userName - } - } = data; - - - data.message = { - message: await getTwitchAnnouncementEmotes(data) - }; - - - const replyHTML = currentLang.twitch.announcement(); - - const [avatar, message] = await Promise.all([ - '', - ` ${data.message.message}` - ]); - - const classes = 'announcement'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: replyHTML, - }; - - addEventToChat(userID, messageID, 'twitch', messageData); -} - - -async function twitchRewardRedemption(data) { - - if (showTwitchRewardRedemptions == false) return; - - const { - user_id : userID, - user_name : userName, - } = data; - const messageID = createRandomString(40); - const replyHTML = currentLang.twitch.channelpoints({ title : data.reward.title }); - const [avatar, message] = await Promise.all([ - '', - ` ${data.user_input}` - ]); - const classes = 'rewards-redemption'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: replyHTML, - }; - - addEventToChat(userID, messageID, 'twitch', messageData); -} - - -async function twitchSubMessage(data) { - - if (showTwitchSubs == false) return; - - const { - user : { - id : userID, - name : userName - } - } = data; - - const messageID = createRandomString(40); - const [avatar, message] = await Promise.all([ - '', - currentLang.twitch.sub({ - months : data.duration_months, - isPrime : data.isPrime, - tier : data.sub_tier - }) - ]); - - const classes = 'sub'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - addEventToChat(userID, messageID, 'twitch', messageData); -} - - -async function twitchReSubMessage(data) { - - if (showTwitchSubs == false) return; - - const { - user : { - id : userID, - name : userName - }, - text - } = data; - - const messageID = createRandomString(40); - const messagetext = await getTwitchEmotesOnParts(data); - - const [avatar, message] = await Promise.all([ - '', - currentLang.twitch.resub({ - months : data.cumulativeMonths, - isPrime : data.isPrime, - tier : data.subTier, - message : messagetext - }) - ]); - - const classes = 'sub'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'twitch', messageData); -} - - -async function twitchGiftMessage(data) { - - if (data.fromCommunitySubGift === false) { - if (showTwitchSubs == false || showTwitchGiftedSubs == false) return; - } - else { - if (showTwitchSubs == false || showTwitchGiftedSubsUserTrain == false) return; - } - - - const { - user : { - id : userID, - name : userName - } - } = data; - - const messageID = createRandomString(40); - - const [avatar, message] = await Promise.all([ - '', - currentLang.twitch.gifted({ - gifted : data.recipient.name, - months : data.durationMonths, - tier : data.subTier, - total : data.cumlativeTotal - }) - ]); - - const classes = 'sub'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'twitch', messageData); -} - - - -async function twitchGiftSubsMessage(data) { - - if (showTwitchSubs == false || showTwitchMassGiftedSubs == false) return; - - const { - user : { - id : userID, - name : userName - } - } = data; - - const messageID = createRandomString(40); - - const [avatar, message] = await Promise.all([ - '', - currentLang.twitch.giftedbomb({ - count : data.total, - tier : data.sub_tier, - total : data.cumulative_total - }) - ]); - - const classes = 'sub'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - addEventToChat(userID, messageID, 'twitch', messageData); -} - - -async function twitchRaidMessage(data) { - - if (showTwitchRaids == false) return; - - const { - from_broadcaster_user_login: userID, - from_broadcaster_user_name: userName - } = data; - - const messageID = createRandomString(40); - const [avatar, message] = await Promise.all([ - '', - currentLang.twitch.raid({ viewers : data.viewers }) - ]); - - const classes = 'raid'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - }; - - addEventToChat(userID, messageID, 'twitch', messageData); -} - - -async function twitchChatMessageDeleted(data) { - document.getElementById(data.messageId)?.remove(); -} - - -async function twitchUserBanned(data) { - chatContainer.querySelectorAll(`[data-user="${data.user_login}"]`).forEach(element => { - element.remove(); - }); -} - - -async function twitchChatClearMessages() { - chatContainer.querySelectorAll(`.twitch:not(.event)`).forEach(element => { - element.remove(); - }); -} - - -async function twitchUpdateStatistics(data) { - if (showPlatformStatistics == false || showTwitchViewers == false) return; - - const viewers = DOMPurify.sanitize(data.viewerCount); - document.querySelector('#statistics #twitch .viewers span').textContent = formatNumber(viewers); -} - - -async function getTwitchEmotes(data) { - const message = data.message.message; - const emotes = data.emotes; - const words = message.split(" "); - emotes.sort((a, b) => b.startIndex - a.startIndex); - for (let i = 0; i < words.length; i++) { - emotes.forEach(emote => { - if (words[i] === emote.name) { - words[i] = `${emote.name}`; - } - }); - } - return words.join(" "); -} - - -async function getTwitchAnnouncementEmotes(data) { - const message = data.text; - const emotes = data.parts; - const words = message.split(" "); - emotes.sort((a, b) => b.startIndex - a.startIndex); - for (let i = 0; i < words.length; i++) { - emotes.forEach(emote => { - if (words[i] === emote.text) { - words[i] = `${emote.text}`; - } - }); - } - return words.join(" "); -} - -async function getTwitchEmotesOnParts(data) { - const parts = data?.parts; - const message = data.text; - - if (!Array.isArray(parts)) { - return message; - } - - return parts.map(part => { - if (part.type === 'text') { - return message; - } else if (part.type === 'emote') { - return `${part.text}`; - } - }).join(''); -} - -async function getTwitchBadges(data) { - const badges = data.message.badges; - var htmlBadges = ''; - badges.forEach((badge) => { - htmlBadges += ``; - }); - return htmlBadges; -} - - -async function getTwitchAvatar(user) { - if (showAvatar == true) { - if (avatars.has(user)) { - console.debug(`Twitch avatar found for ${user}!`); - return avatars.get(user); - } - else { - console.debug(`Twitch avatar not found for ${user}! Getting it from DECAPI!`); - var decapi = await fetch('https://decapi.me/twitch/avatar/' + user); - var newavatar = await decapi.text() - - if (!newavatar) { newavatar = 'https://static-cdn.jtvnw.net/user-default-pictures-uv/cdd517fe-def4-11e9-948e-784f43822e80-profile_image-300x300.png'; } - - avatars.set(user, newavatar); - return newavatar; - } - } -} - - -async function getUserPronouns(platform, username) { - if (pronouns.has(username)) { - console.debug(`Pronouns found for ${username}. Getting it from Map...`) - return pronouns.get(username); - } - else { - console.debug(`Pronouns not found for ${username}. Retrieving...`) - - const response = await streamerBotClient.getUserPronouns(platform, username); - const pronoun = response.pronoun.userFound ? `${response.pronoun.pronounSubject}/${response.pronoun.pronounObject}` : ''; - - pronouns.set(username, pronoun); - - return pronoun; - } -} diff --git a/js/youtube/module.js b/js/youtube/module.js deleted file mode 100644 index 0a916d3..0000000 --- a/js/youtube/module.js +++ /dev/null @@ -1,455 +0,0 @@ -const showYouTubeMessages = getURLParam("showYouTubeMessages", true); -const showYouTubeSuperChats = getURLParam("showYouTubeSuperChats", true); -const showYouTubeSuperStickers = getURLParam("showYouTubeSuperStickers", true); -const showYouTubeSuperStickerGif = getURLParam("showYouTubeSuperStickerGif", true); -const showYouTubeSuperStickerFullSize = getURLParam("showYouTubeSuperStickerFullSize", false); -const showYouTubeMemberships = getURLParam("showYouTubeMemberships", true); -const showYouTubeGiftMemberships = getURLParam("showYouTubeGiftMemberships", true); -const showYouTubeMembershipsTrain = getURLParam("showYouTubeMembershipsTrain", true); -const showYouTubeStatistics = getURLParam("showYouTubeStatistics", true); - -let youTubeCustomEmotes = []; - -let youTubeBTTVEmotes = []; - -userColors.set('youtube', new Map()); - -if (showYouTubeStatistics == false) { document.querySelector('#statistics #youtube').style.display = 'none'; } - -const youtubeMessageHandlers = { - 'YouTube.Message': (response) => { - console.debug('YouTube Chat', response.data); - youTubeChatMessage(response.data); - }, - 'YouTube.UserBanned': (response) => { - console.debug('YouTube Timeout/Hide/Ban', response.data); - youTubeUserBanned(response.data); - }, - 'YouTube.SuperChat': (response) => { - console.debug('YouTube SuperChat', response.data); - youTubeSuperChatMessage(response.data); - }, - 'YouTube.SuperSticker': (response) => { - console.debug('YouTube Super Sticker', response.data); - youTubeSuperStickerMessage(response.data); - }, - 'YouTube.NewSponsor': (response) => { - console.debug('YouTube New Member', response.data); - youTubeNewSponsorMessage(response.data); - }, - 'YouTube.MemberMileStone': (response) => { - console.debug('YouTube Member Milestone', response.data); - youTubeNewSponsorMessage(response.data); - }, - 'YouTube.MembershipGift': (response) => { - console.debug('YouTube Gifted Membership', response.data); - youTubeGiftedMembersMessage(response.data); - }, - 'YouTube.GiftMembershipReceived': (response) => { - console.debug('YouTube Gifted Membership Bomb', response.data); - YouTubeGiftReceivedMessage(response.data); - }, - 'YouTube.StatisticsUpdated': (response) => { - console.debug(response.data); - youTubeUpdateStatistics(response.data); - } -}; - - -for (const [event, handler] of Object.entries(youtubeMessageHandlers)) { - streamerBotClient.on(event, handler); -} - - - -async function youTubeChatMessage(data) { - - if (showYouTubeMessages == false) return; - if (ignoreUserList.includes(data.user.name.toLowerCase())) return; - if (data.message.startsWith("!") && excludeCommands == true) return; - - if (streamerBotConnected == true) { - if (youTubeCustomEmotes.length == 0) { - streamerBotClient.getGlobals().then( (getglobals) => { - youTubeCustomEmotes = JSON.parse(JSON.parse(getglobals.variables.chatrdytcustomemotes.value)); - console.debug('Getting YouTube Emotes from Streamer.Bot', youTubeCustomEmotes); - }); - } - } - - const { - user: { - id: userID, - profileImageUrl: avatar, - name: userName, - isVerified, - isSponsor, - isModerator, - isOwner, - }, - eventId: messageID, - } = data; - - var messageHTML = await getYouTubeEmotes(data); - - const badgesHTML = [ - isVerified && '', - isSponsor && '', - isModerator && '', - isOwner && '', - ].filter(Boolean).join(''); - - const classes = [ - isSponsor && 'sub', - isModerator && 'mod', - isOwner && 'owner', - ].filter(Boolean); - - const messageData = { - classes: classes.join(' '), - avatar, - badges: badgesHTML, - userName, - color: await createRandomColor('youtube', userID), - message : messageHTML, - reply: '', - }; - addMessageToChat(userID, messageID, 'youtube', messageData); -} - - -async function youTubeUserBanned(data) { - chatContainer.querySelectorAll(`[data-user="${data.bannedUser.id}"]:not(.event)`).forEach(element => { - element.remove(); - }); -} - - -async function youTubeSuperChatMessage(data) { - - if (showYouTubeSuperChats == false) return; - - const { - user: { - id: userID, - name: userName, - }, - eventId: messageID, - amount, - message : textmessage - } = data; - - var money = amount; - var messagewithemotes = await getYouTubeEmotes(textmessage); - - const [avatar, message] = await Promise.all([ - ``, - currentLang.youtube.superchat({ - money : money, - message : messagewithemotes - }) - ]); - - const classes = 'superchat'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - } - addEventToChat(userID, messageID, 'youtube', messageData); -} - - -async function youTubeSuperStickerMessage(data) { - - if (showYouTubeSuperStickers == false) return; - - const { - user: { - id: userID, - name: userName, - }, - eventId: messageID, - amount - } = data; - - var money = amount; - var youtubeStickerUrl = ''; - - if (showYouTubeSuperStickerGif == true) { - youtubeStickerUrl = await getYouTubeStickerImage(data); - } - - const [avatar, message] = await Promise.all([ - ``, - currentLang.youtube.supersticker({ - money : money, - sticker : youtubeStickerUrl - }) - ]); - - const classes = ['supersticker']; - if (showYouTubeSuperStickerFullSize == true) { - classes.push('giantsupersticker'); - } - - const messageData = { - classes: classes.join(' '), - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - } - addEventToChat(userID, messageID, 'youtube', messageData); -} - -async function youTubeNewSponsorMessage(data) { - - if (showYouTubeMemberships == false) return; - - const { - user: { - id: userID, - name: userName, - }, - eventId: messageID, - levelName, - months, - message: messagetext, - } = data; - - var messagewithemotes = ''; - - if (messagetext) { - messagewithemotes = await getYouTubeEmotes(messagetext); - } - - const [avatar, message] = await Promise.all([ - ``, - currentLang.youtube.member({ - months : months, - tier : levelName, - message: messagewithemotes - }) - ]); - - const classes = 'member'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - } - addEventToChat(userID, messageID, 'youtube', messageData); -} - - -async function youTubeGiftedMembersMessage(data) { - - if (showYouTubeGiftMemberships == false) return; - - const { - user: { - id: userID, - name: userName, - }, - eventId: messageID, - tier, - count - } = data; - const [avatar, message] = await Promise.all([ - ``, - currentLang.youtube.giftedmembers({ - total : count, - tier : tier - }) - ]); - const classes = 'giftedmembers'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - } - addEventToChat(userID, messageID, 'youtube', messageData); -} - -async function YouTubeGiftReceivedMessage(data) { - - if (showYouTubeMembershipsTrain == false) return; - - const { - user: { - id: userID, - name: userName, - }, - gifter: { - id : gifterUserId, - name: gifterUserName - }, - eventId: messageID, - tier - } = data; - - const [avatar, message] = await Promise.all([ - ``, - currentLang.youtube.giftedmembers({ - gifted : gifterUserName, - tier : tier - }) - ]); - - const classes = 'giftedtrainmembers'; - const messageData = { - classes: classes, - avatar, - badges: '', - userName, - color: '#FFF', - message, - reply: '', - } - addEventToChat(gifterUserId, messageID, 'youtube', messageData); -} - - -async function youTubeUpdateStatistics(data) { - - if (showYouTubeStatistics == false) return; - - const viewers = DOMPurify.sanitize(data.concurrentViewers); - const likes = DOMPurify.sanitize(data.likeCount); - document.querySelector('#statistics #youtube .viewers span').textContent = formatNumber(viewers); - document.querySelector('#statistics #youtube .likes span').textContent = formatNumber(likes); -} - - -async function getYouTubeEmotes(data) { - let message = data.message; - const channelId = data.broadcast?.channelId; - if (!channelId) return message; - - // Carrega os emotes do canal BTTV se ainda nΓ£o estiverem carregados - if (youTubeBTTVEmotes.length === 0) { - try { - const res = await fetch(`https://api.betterttv.net/3/cached/users/youtube/${channelId}`); - const emoteData = await res.json(); - console.debug('Getting YouTube BTTV Channel Emojis', `https://api.betterttv.net/3/cached/users/youtube/${channelId}`, emoteData); - youTubeBTTVEmotes = [ - ...(emoteData.sharedEmotes || []), - ...(emoteData.channelEmotes || []) - ]; - } catch (err) { - console.warn("Failed to load BTTV emotes:", err); - } - } - - // Cria o mapa de emotes - const emoteMap = new Map(); - - // BTTV emotes - for (const emote of youTubeBTTVEmotes) { - const imageUrl = `https://cdn.betterttv.net/emote/${emote.id}/1x`; - const emoteElement = `${emote.code}`; - emoteMap.set(emote.code, { html: emoteElement, raw: emote.code }); - } - - // YouTube emotes (ex: :hand-pink-waving:) - if (data.emotes) { - for (const emote of data.emotes) { - const emoteElement = `${emote.name}`; - emoteMap.set(emote.name, { html: emoteElement, raw: emote.name }); - } - } - - // Custom Member Emotes (tambΓ©m com dois-pontos) - if (data.user.isSponsor === true || data.user.isOwner === true) { - for (const [name, url] of Object.entries(youTubeCustomEmotes)) { - const emoteElement = `${name}`; - emoteMap.set(`:${name}:`, { html: emoteElement, raw: `:${name}:` }); - } - } - - // Usa DOMParser para substituir apenas nΓ³s de texto - const parser = new DOMParser(); - const doc = parser.parseFromString(`
${message}
`, 'text/html'); - const container = doc.body.firstChild; - - function escapeRegex(string) { - return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - } - - function replaceEmotesInText(text) { - // Ordena por tamanho decrescente pra evitar conflitos entre nomes parecidos - const sorted = Array.from(emoteMap.values()).sort((a, b) => b.raw.length - a.raw.length); - - for (const { raw, html } of sorted) { - const escaped = escapeRegex(raw); - - // Emotes com dois-pontos: :emote: β†’ permitem colados - const isDelimited = raw.startsWith(':') && raw.endsWith(':'); - const regex = isDelimited - ? new RegExp(escaped, 'g') - : new RegExp(`(?