spectre-html-transcripts 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +153 -0
- package/dist/downloader/images.d.ts +43 -0
- package/dist/downloader/images.js +125 -0
- package/dist/downloader/images.js.map +1 -0
- package/dist/generator/index.d.ts +20 -0
- package/dist/generator/index.js +79 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/renderers/attachment.d.ts +24 -0
- package/dist/generator/renderers/attachment.js +49 -0
- package/dist/generator/renderers/attachment.js.map +1 -0
- package/dist/generator/renderers/components/Button.d.ts +9 -0
- package/dist/generator/renderers/components/Button.js +19 -0
- package/dist/generator/renderers/components/Button.js.map +1 -0
- package/dist/generator/renderers/components/Container.d.ts +5 -0
- package/dist/generator/renderers/components/Container.js +22 -0
- package/dist/generator/renderers/components/Container.js.map +1 -0
- package/dist/generator/renderers/components/Media Gallery.d.ts +6 -0
- package/dist/generator/renderers/components/Media Gallery.js +39 -0
- package/dist/generator/renderers/components/Media Gallery.js.map +1 -0
- package/dist/generator/renderers/components/Select Menu.d.ts +5 -0
- package/dist/generator/renderers/components/Select Menu.js +41 -0
- package/dist/generator/renderers/components/Select Menu.js.map +1 -0
- package/dist/generator/renderers/components/Spacing.d.ts +6 -0
- package/dist/generator/renderers/components/Spacing.js +17 -0
- package/dist/generator/renderers/components/Spacing.js.map +1 -0
- package/dist/generator/renderers/components/Thumbnail.d.ts +5 -0
- package/dist/generator/renderers/components/Thumbnail.js +16 -0
- package/dist/generator/renderers/components/Thumbnail.js.map +1 -0
- package/dist/generator/renderers/components/section/Section.d.ts +10 -0
- package/dist/generator/renderers/components/section/Section.js +21 -0
- package/dist/generator/renderers/components/section/Section.js.map +1 -0
- package/dist/generator/renderers/components/section/SectionAccessory.d.ts +6 -0
- package/dist/generator/renderers/components/section/SectionAccessory.js +19 -0
- package/dist/generator/renderers/components/section/SectionAccessory.js.map +1 -0
- package/dist/generator/renderers/components/section/SectionContent.d.ts +6 -0
- package/dist/generator/renderers/components/section/SectionContent.js +15 -0
- package/dist/generator/renderers/components/section/SectionContent.js.map +1 -0
- package/dist/generator/renderers/components/styles.d.ts +29 -0
- package/dist/generator/renderers/components/styles.js +110 -0
- package/dist/generator/renderers/components/styles.js.map +1 -0
- package/dist/generator/renderers/components/utils.d.ts +36 -0
- package/dist/generator/renderers/components/utils.js +98 -0
- package/dist/generator/renderers/components/utils.js.map +1 -0
- package/dist/generator/renderers/components.d.ts +15 -0
- package/dist/generator/renderers/components.js +62 -0
- package/dist/generator/renderers/components.js.map +1 -0
- package/dist/generator/renderers/content.d.ts +31 -0
- package/dist/generator/renderers/content.js +137 -0
- package/dist/generator/renderers/content.js.map +1 -0
- package/dist/generator/renderers/embed.d.ts +12 -0
- package/dist/generator/renderers/embed.js +53 -0
- package/dist/generator/renderers/embed.js.map +1 -0
- package/dist/generator/renderers/message.d.ts +7 -0
- package/dist/generator/renderers/message.js +69 -0
- package/dist/generator/renderers/message.js.map +1 -0
- package/dist/generator/renderers/reply.d.ts +7 -0
- package/dist/generator/renderers/reply.js +59 -0
- package/dist/generator/renderers/reply.js.map +1 -0
- package/dist/generator/renderers/systemMessage.d.ts +13 -0
- package/dist/generator/renderers/systemMessage.js +133 -0
- package/dist/generator/renderers/systemMessage.js.map +1 -0
- package/dist/generator/transcript.d.ts +10 -0
- package/dist/generator/transcript.js +86 -0
- package/dist/generator/transcript.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +148 -0
- package/dist/index.js.map +1 -0
- package/dist/static/client.d.ts +2 -0
- package/dist/static/client.js +30 -0
- package/dist/static/client.js.map +1 -0
- package/dist/test.js +65 -0
- package/dist/types.d.ts +75 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/buildProfiles.d.ts +11 -0
- package/dist/utils/buildProfiles.js +41 -0
- package/dist/utils/buildProfiles.js.map +1 -0
- package/dist/utils/djsAdapter.d.ts +9 -0
- package/dist/utils/djsAdapter.js +96 -0
- package/dist/utils/djsAdapter.js.map +1 -0
- package/dist/utils/embeds.d.ts +1 -0
- package/dist/utils/embeds.js +17 -0
- package/dist/utils/embeds.js.map +1 -0
- package/dist/utils/extend.d.ts +8 -0
- package/dist/utils/extend.js +8 -0
- package/dist/utils/extend.js.map +1 -0
- package/dist/utils/utils.d.ts +14 -0
- package/dist/utils/utils.js +44 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# `spectre-html-transcripts` (Selfbot v13)
|
|
2
|
+
|
|
3
|
+
[](https://discord.gg/WxG8XWjvmX)
|
|
4
|
+
[](http://npmjs.org/package/spectre-html-transcripts)
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
Spectre HTML Transcripts is a node.js module to generate nice looking HTML transcripts. Processes discord markdown like **bold**, _italics_, ~~strikethroughs~~, and more. Nicely formats attachments and embeds. Built in XSS protection, preventing users from inserting arbitrary html tags.
|
|
9
|
+
|
|
10
|
+
This module can format the following:
|
|
11
|
+
|
|
12
|
+
- Discord flavored markdown
|
|
13
|
+
- Uses [discord-markdown-parser](https://github.com/ItzDerock/discord-markdown-parser)
|
|
14
|
+
- Allows for complex markdown syntax to be parsed properly
|
|
15
|
+
- Embeds
|
|
16
|
+
- System messages
|
|
17
|
+
- Join messages
|
|
18
|
+
- Message Pins
|
|
19
|
+
- Boost messages
|
|
20
|
+
- Slash commands
|
|
21
|
+
- Will show the name of the command in the same style as Discord
|
|
22
|
+
- Buttons
|
|
23
|
+
- Reactions
|
|
24
|
+
- Attachments
|
|
25
|
+
- Images, videos, audio, and generic files
|
|
26
|
+
- Replies
|
|
27
|
+
- Mentions
|
|
28
|
+
- Threads
|
|
29
|
+
|
|
30
|
+
**This fork targets [discord.js-selfbot-v13](https://github.com/aiko-chan-ai/discord.js-selfbot-v13) (selfbot) and supports its v3.x releases.**
|
|
31
|
+
|
|
32
|
+
Styles from [@derockdev/discord-components](https://github.com/ItzDerock/discord-components).
|
|
33
|
+
Behind the scenes, this package uses React SSR to generate a static site.
|
|
34
|
+
|
|
35
|
+
## Selfbot (discord.js-selfbot-v13) notes ⚠️
|
|
36
|
+
|
|
37
|
+
**This fork is tailored to work with `discord.js-selfbot-v13` (v3.x).** Install it in your project and ensure it's available as a peer dependency:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install discord.js-selfbot-v13@^3.7.1
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
> **Note:** Using selfbots may violate Discord's Terms of Service. Use at your own risk.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Credits
|
|
48
|
+
|
|
49
|
+
This package is a complete overhaul (a fork) of the original `discord-html-transcripts` project by ItzDerock. All credits for the original concept and base code go to him. Please give the original project a star ⭐ and/or support the original creator on [Ko-fi](https://ko-fi.com/derock).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 👋 Support
|
|
54
|
+
|
|
55
|
+
For support, please open a thread on [this](https://discord.gg/WxG8XWjvmX) server or send a DM to `qorp` on Discord. / Pour tout support, ouvrez un thread sur ce serveur ou envoyez un DM à `qorp` sur Discord.
|
|
56
|
+
|
|
57
|
+
## 🖨️ Example Output
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+
## 📝 Usage
|
|
62
|
+
|
|
63
|
+
### Example usage using the built in message fetcher.
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
const spectreTranscripts = require('spectre-html-transcripts');
|
|
67
|
+
// or (if using typescript) import * as spectreTranscripts from 'spectre-html-transcripts';
|
|
68
|
+
|
|
69
|
+
const channel = message.channel; // or however you get your TextChannel
|
|
70
|
+
|
|
71
|
+
// Must be awaited
|
|
72
|
+
const attachment = await spectreTranscripts.createTranscript(channel);
|
|
73
|
+
|
|
74
|
+
channel.send({
|
|
75
|
+
files: [attachment],
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Or if you prefer, you can pass in your own messages.
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
const spectreTranscripts = require('spectre-html-transcripts');
|
|
83
|
+
// or (if using typescript) import * as spectreTranscripts from 'spectre-html-transcripts';
|
|
84
|
+
|
|
85
|
+
const messages = someWayToGetMessages(); // Must be Collection<string, Message> or Message[]
|
|
86
|
+
const channel = someWayToGetChannel(); // Used for ticket name, guild icon, and guild name
|
|
87
|
+
|
|
88
|
+
// Must be awaited
|
|
89
|
+
const attachment = await spectreTranscripts.generateFromMessages(messages, channel);
|
|
90
|
+
|
|
91
|
+
channel.send({
|
|
92
|
+
files: [attachment],
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## ⚙️ Configuration
|
|
97
|
+
|
|
98
|
+
Both methods of generating a transcript allow for an option object as the last parameter.
|
|
99
|
+
**All configuration options are optional!**
|
|
100
|
+
|
|
101
|
+
### Built in Message Fetcher
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
const attachment = await discordTranscripts.createTranscript(channel, {
|
|
105
|
+
limit: -1, // Max amount of messages to fetch. `-1` recursively fetches.
|
|
106
|
+
returnType: 'attachment', // Valid options: 'buffer' | 'string' | 'attachment' Default: 'attachment' OR use the enum ExportReturnType
|
|
107
|
+
filename: 'transcript.html', // Only valid with returnType is 'attachment'. Name of attachment.
|
|
108
|
+
saveImages: false, // Download all images and include the image data in the HTML (allows viewing the image even after it has been deleted) (! WILL INCREASE FILE SIZE !)
|
|
109
|
+
footerText: "Exported {number} message{s}", // Change text at footer, don't forget to put {number} to show how much messages got exported, and {s} for plural
|
|
110
|
+
callbacks: {
|
|
111
|
+
// register custom callbacks for the following:
|
|
112
|
+
resolveChannel: (channelId: string) => Awaitable<Channel | null>,
|
|
113
|
+
resolveUser: (userId: string) => Awaitable<User | null>,
|
|
114
|
+
resolveRole: (roleId: string) => Awaitable<Role | null>,
|
|
115
|
+
resolveImageSrc: (
|
|
116
|
+
attachment: APIAttachment,
|
|
117
|
+
message: APIMessage
|
|
118
|
+
) => Awaitable<string | null | undefined>
|
|
119
|
+
},
|
|
120
|
+
poweredBy: true, // Whether to include the "Powered by spectre-html-transcripts" footer
|
|
121
|
+
hydrate: true, // Whether to hydrate the html server-side
|
|
122
|
+
filter: (message) => true // Filter messages, e.g. (message) => !message.author.bot
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Providing your own messages
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
const attachment = await discordTranscripts.generateFromMessages(messages, channel, {
|
|
130
|
+
// Same as createTranscript, except no limit or filter
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Compressing images
|
|
135
|
+
|
|
136
|
+
If `saveImages` is set to `true`, all images will be downloaded and stored in the file _as-is_. You can optionally enable compression by installing the `sharp` module and setting the following options:
|
|
137
|
+
|
|
138
|
+
```js
|
|
139
|
+
callbacks: {
|
|
140
|
+
resolveImageSrc: new TranscriptImageDownloader()
|
|
141
|
+
.withMaxSize(5120) // 5MB in KB
|
|
142
|
+
.withCompression(40, true) // 40% quality, convert to webp
|
|
143
|
+
.build(),
|
|
144
|
+
},
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Note that, in a more advanced setup, you could store a copy of the files and return an entirely new URL pointing to your own image hosting site by implementing a custom `resolveImageSrc` function.
|
|
148
|
+
|
|
149
|
+
## 🤝 Enjoy the package?
|
|
150
|
+
|
|
151
|
+
Give it a star ⭐ and/or support the original creator on [Ko-fi](https://ko-fi.com/derock).
|
|
152
|
+
|
|
153
|
+
This package is a complete overhaul (fork) of the original `discord-html-transcripts` project by ItzDerock. All credits for the original concept and base code go to him. Thanks !
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { WebpOptions } from 'sharp';
|
|
2
|
+
type Awaitable<T> = T | Promise<T>;
|
|
3
|
+
/**
|
|
4
|
+
* Callback used to save an image attachment.
|
|
5
|
+
* The returned string is the URL that will be used in the transcript.
|
|
6
|
+
*
|
|
7
|
+
* `undefined` indicates to use the original attachment URL.
|
|
8
|
+
* `null` indicates to not include the attachment in the transcript.
|
|
9
|
+
* `string` indicates to use the returned URL as the attachment URL (base64 or remote image).
|
|
10
|
+
*/
|
|
11
|
+
export type ResolveImageCallback = (attachment: any, message: any) => Awaitable<string | null | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* Builder to build a image saving callback.
|
|
14
|
+
*/
|
|
15
|
+
export declare class TranscriptImageDownloader {
|
|
16
|
+
private static log;
|
|
17
|
+
private log;
|
|
18
|
+
private maxFileSize?;
|
|
19
|
+
private compression?;
|
|
20
|
+
private token?;
|
|
21
|
+
/**
|
|
22
|
+
* If provided, the downloader will attach this token to requests as an Authorization header
|
|
23
|
+
* (useful for fetching private CDN resources from DMs with selfbot tokens)
|
|
24
|
+
*/
|
|
25
|
+
withToken(token: string): this;
|
|
26
|
+
/**
|
|
27
|
+
* Sets the maximum file size for *each* individual image.
|
|
28
|
+
* @param size The maximum file size in kilobytes
|
|
29
|
+
*/
|
|
30
|
+
withMaxSize(size: number): this;
|
|
31
|
+
/**
|
|
32
|
+
* Sets the compression quality for each image. This requires `sharp` to be installed.
|
|
33
|
+
* Optionally, images can be converted to WebP format which is smaller in size.
|
|
34
|
+
* @param quality The quality of the image (1 lowest - 100 highest). Lower quality means smaller file size.
|
|
35
|
+
* @param convertToWebP Whether to convert the image to WebP format
|
|
36
|
+
*/
|
|
37
|
+
withCompression(quality?: number, convertToWebP?: boolean, options?: Omit<WebpOptions, 'quality' | 'force'>): this;
|
|
38
|
+
/**
|
|
39
|
+
* Builds the image saving callback.
|
|
40
|
+
*/
|
|
41
|
+
build(): ResolveImageCallback;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.TranscriptImageDownloader = void 0;
|
|
40
|
+
const undici_1 = require("undici");
|
|
41
|
+
const debug_1 = __importDefault(require("debug"));
|
|
42
|
+
/**
|
|
43
|
+
* Builder to build a image saving callback.
|
|
44
|
+
*/
|
|
45
|
+
class TranscriptImageDownloader {
|
|
46
|
+
constructor() {
|
|
47
|
+
this.log = TranscriptImageDownloader.log;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* If provided, the downloader will attach this token to requests as an Authorization header
|
|
51
|
+
* (useful for fetching private CDN resources from DMs with selfbot tokens)
|
|
52
|
+
*/
|
|
53
|
+
withToken(token) {
|
|
54
|
+
this.token = token;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Sets the maximum file size for *each* individual image.
|
|
59
|
+
* @param size The maximum file size in kilobytes
|
|
60
|
+
*/
|
|
61
|
+
withMaxSize(size) {
|
|
62
|
+
this.maxFileSize = size;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Sets the compression quality for each image. This requires `sharp` to be installed.
|
|
67
|
+
* Optionally, images can be converted to WebP format which is smaller in size.
|
|
68
|
+
* @param quality The quality of the image (1 lowest - 100 highest). Lower quality means smaller file size.
|
|
69
|
+
* @param convertToWebP Whether to convert the image to WebP format
|
|
70
|
+
*/
|
|
71
|
+
withCompression(quality = 80, convertToWebP = false, options = {}) {
|
|
72
|
+
if (quality < 1 || quality > 100)
|
|
73
|
+
throw new Error('Quality must be between 1 and 100');
|
|
74
|
+
// try and import sharp
|
|
75
|
+
Promise.resolve().then(() => __importStar(require('sharp'))).catch((err) => {
|
|
76
|
+
console.error(err);
|
|
77
|
+
console.error(`[spectre-html-transcripts] Failed to import 'sharp'. Image compression requires the 'sharp' package to be installed. Either install sharp or remove the compression options.`);
|
|
78
|
+
});
|
|
79
|
+
this.compression = { quality, convertToWebP, options };
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Builds the image saving callback.
|
|
84
|
+
*/
|
|
85
|
+
build() {
|
|
86
|
+
return async (attachment) => {
|
|
87
|
+
// if the attachment is not an image, return null
|
|
88
|
+
if (!attachment.width || !attachment.height)
|
|
89
|
+
return undefined;
|
|
90
|
+
// if the max file size is set, check if the file size is within the limit
|
|
91
|
+
if (this.maxFileSize && attachment.size > this.maxFileSize * 1024)
|
|
92
|
+
return undefined;
|
|
93
|
+
// fetch the image
|
|
94
|
+
this.log(`Fetching attachment ${attachment.id}: ${attachment.url}`);
|
|
95
|
+
const requestOptions = {}; // typed instead of any
|
|
96
|
+
if (this.token)
|
|
97
|
+
requestOptions.headers = { authorization: this.token };
|
|
98
|
+
const response = await (0, undici_1.request)(attachment.url, requestOptions).catch((err) => {
|
|
99
|
+
console.error(`[spectre-html-transcripts] Failed to download image for transcript: `, err);
|
|
100
|
+
return null;
|
|
101
|
+
});
|
|
102
|
+
if (!response)
|
|
103
|
+
return undefined;
|
|
104
|
+
const mimetype = response.headers['content-type'];
|
|
105
|
+
const buffer = await response.body.arrayBuffer().then((res) => Buffer.from(res)); // typed res
|
|
106
|
+
this.log(`Finished fetching ${attachment.id} (${buffer.length} bytes)`);
|
|
107
|
+
// if the compression options are set, compress the image
|
|
108
|
+
if (this.compression) {
|
|
109
|
+
const sharp = await Promise.resolve().then(() => __importStar(require('sharp')));
|
|
110
|
+
this.log(`Compressing ${attachment.id} with 'sharp'`);
|
|
111
|
+
const sharpbuf = await sharp
|
|
112
|
+
.default(buffer)
|
|
113
|
+
.webp(Object.assign({ quality: this.compression.quality, force: this.compression.convertToWebP, effort: 2 }, this.compression.options))
|
|
114
|
+
.toBuffer({ resolveWithObject: true });
|
|
115
|
+
this.log(`Finished compressing ${attachment.id} (${sharpbuf.info.size} bytes)`);
|
|
116
|
+
return `data:image/${sharpbuf.info.format};base64,${sharpbuf.data.toString('base64')}`;
|
|
117
|
+
}
|
|
118
|
+
// return the base64 string
|
|
119
|
+
return `data:${mimetype};base64,${buffer.toString('base64')}`;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.TranscriptImageDownloader = TranscriptImageDownloader;
|
|
124
|
+
TranscriptImageDownloader.log = (0, debug_1.default)('spectre-html-transcripts:TranscriptImageDownloader');
|
|
125
|
+
//# sourceMappingURL=images.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.js","sourceRoot":"","sources":["../../src/downloader/images.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,mCAAiC;AACjC,kDAA0B;AAe1B;;GAEG;AACH,MAAa,yBAAyB;IAAtC;QAEU,QAAG,GAAG,yBAAyB,CAAC,GAAG,CAAC;IAmG9C,CAAC;IAxFC;;;OAGG;IACH,SAAS,CAAC,KAAa;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,IAAY;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,OAAO,GAAG,EAAE,EAAE,aAAa,GAAG,KAAK,EAAE,UAAkD,EAAE;QACvG,IAAI,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QAEvF,uBAAuB;QACvB,kDAAO,OAAO,IAAE,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YAC5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-selfbot-v13';
|
|
2
|
+
type Awaitable<T> = T | Promise<T>;
|
|
3
|
+
import type { ResolveImageCallback } from '../downloader/images';
|
|
4
|
+
export type RenderMessageContext = {
|
|
5
|
+
messages: Message[];
|
|
6
|
+
channel: Channel;
|
|
7
|
+
callbacks: {
|
|
8
|
+
resolveImageSrc: ResolveImageCallback;
|
|
9
|
+
resolveChannel: (channelId: string) => Awaitable<Channel | null>;
|
|
10
|
+
resolveUser: (userId: string) => Awaitable<User | null>;
|
|
11
|
+
resolveRole: (roleId: string) => Awaitable<Role | null>;
|
|
12
|
+
};
|
|
13
|
+
poweredBy?: boolean;
|
|
14
|
+
footerText?: string;
|
|
15
|
+
saveImages: boolean;
|
|
16
|
+
favicon: 'guild' | string;
|
|
17
|
+
hydrate: boolean;
|
|
18
|
+
};
|
|
19
|
+
export default function render({ messages, channel, callbacks, ...options }: RenderMessageContext): Promise<string>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
var _a;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.default = render;
|
|
19
|
+
const djsAdapter_1 = require("../utils/djsAdapter");
|
|
20
|
+
const static_1 = require("react-dom/static");
|
|
21
|
+
const react_1 = __importDefault(require("react"));
|
|
22
|
+
const buildProfiles_1 = require("../utils/buildProfiles");
|
|
23
|
+
const client_1 = require("../static/client");
|
|
24
|
+
const fs_1 = require("fs");
|
|
25
|
+
const path_1 = __importDefault(require("path"));
|
|
26
|
+
const hydrate_1 = require("@derockdev/discord-components-core/hydrate");
|
|
27
|
+
const transcript_1 = __importDefault(require("./transcript"));
|
|
28
|
+
const utils_1 = require("../utils/utils");
|
|
29
|
+
// read the package.json file and get the @derockdev/discord-components-core version
|
|
30
|
+
let discordComponentsVersion = '^3.6.1';
|
|
31
|
+
try {
|
|
32
|
+
const packagePath = path_1.default.join(__dirname, '..', '..', 'package.json');
|
|
33
|
+
const packageJSON = JSON.parse((0, fs_1.readFileSync)(packagePath, 'utf8'));
|
|
34
|
+
discordComponentsVersion = (_a = packageJSON.dependencies['@derockdev/discord-components-core']) !== null && _a !== void 0 ? _a : discordComponentsVersion;
|
|
35
|
+
// eslint-disable-next-line no-empty
|
|
36
|
+
}
|
|
37
|
+
catch (_b) { } // ignore errors
|
|
38
|
+
async function render(_a) {
|
|
39
|
+
var _b, _c, _d;
|
|
40
|
+
var { messages, channel, callbacks } = _a, options = __rest(_a, ["messages", "channel", "callbacks"]);
|
|
41
|
+
const profiles = (0, buildProfiles_1.buildProfiles)(messages);
|
|
42
|
+
const { prelude } = await (0, static_1.prerenderToNodeStream)(react_1.default.createElement("html", null,
|
|
43
|
+
react_1.default.createElement("head", null,
|
|
44
|
+
react_1.default.createElement("meta", { charSet: "utf-8" }),
|
|
45
|
+
react_1.default.createElement("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }),
|
|
46
|
+
react_1.default.createElement("link", { rel: "icon", type: "image/png", href: options.favicon === 'guild'
|
|
47
|
+
? (0, djsAdapter_1.isDMBasedChannel)(channel)
|
|
48
|
+
? undefined
|
|
49
|
+
: ((_d = (_c = (_b = channel.guild) === null || _b === void 0 ? void 0 : _b.iconURL) === null || _c === void 0 ? void 0 : _c.call(_b, { size: 16, extension: 'png' })) !== null && _d !== void 0 ? _d : undefined)
|
|
50
|
+
: options.favicon }),
|
|
51
|
+
react_1.default.createElement("title", null, (0, djsAdapter_1.isDMBasedChannel)(channel) ? 'Direct Messages' : channel.name),
|
|
52
|
+
react_1.default.createElement("script", { dangerouslySetInnerHTML: {
|
|
53
|
+
__html: client_1.scrollToMessage,
|
|
54
|
+
} }),
|
|
55
|
+
!options.hydrate && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
56
|
+
react_1.default.createElement("script", { dangerouslySetInnerHTML: {
|
|
57
|
+
__html: `window.$discordMessage={profiles:${JSON.stringify(await profiles)}}`,
|
|
58
|
+
} }),
|
|
59
|
+
react_1.default.createElement("script", { type: "module", src: `https://cdn.jsdelivr.net/npm/@derockdev/discord-components-core@${discordComponentsVersion}/dist/derockdev-discord-components-core/derockdev-discord-components-core.esm.js` })))),
|
|
60
|
+
react_1.default.createElement("body", { style: {
|
|
61
|
+
margin: 0,
|
|
62
|
+
minHeight: '100vh',
|
|
63
|
+
} },
|
|
64
|
+
react_1.default.createElement(transcript_1.default, Object.assign({ messages: messages, channel: channel, callbacks: callbacks }, options))),
|
|
65
|
+
options.hydrate && react_1.default.createElement("script", { dangerouslySetInnerHTML: { __html: client_1.revealSpoiler } })));
|
|
66
|
+
const markup = await (0, utils_1.streamToString)(prelude);
|
|
67
|
+
if (options.hydrate) {
|
|
68
|
+
const result = await (0, hydrate_1.renderToString)(markup, {
|
|
69
|
+
beforeHydrate: async (document) => {
|
|
70
|
+
document.defaultView.$discordMessage = {
|
|
71
|
+
profiles: await profiles,
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
return result.html;
|
|
76
|
+
}
|
|
77
|
+
return markup;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js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;YACJ,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Message } from 'discord.js-selfbot-v13';
|
|
3
|
+
type AttachmentType = any;
|
|
4
|
+
import type { RenderMessageContext } from '..';
|
|
5
|
+
/**
|
|
6
|
+
* Renders all attachments for a message
|
|
7
|
+
* @param message
|
|
8
|
+
* @param context
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function Attachments(props: {
|
|
12
|
+
message: Message;
|
|
13
|
+
context: RenderMessageContext;
|
|
14
|
+
}): Promise<React.JSX.Element>;
|
|
15
|
+
/**
|
|
16
|
+
* Renders one Discord Attachment
|
|
17
|
+
* @param props - the attachment and rendering context
|
|
18
|
+
*/
|
|
19
|
+
export declare function Attachment({ attachment, context, message, }: {
|
|
20
|
+
attachment: AttachmentType;
|
|
21
|
+
context: RenderMessageContext;
|
|
22
|
+
message: Message;
|
|
23
|
+
}): Promise<React.JSX.Element>;
|
|
24
|
+
export {};
|