Skip to content

Commit

Permalink
DiscordChatExporterPy 2.0 (#28)
Browse files Browse the repository at this point in the history
* reconstruct

* README

* README

* adjust guild arg

* README

* Removing discord.py from setup and minors

* README update

* README update

* Support for forks which change namespace

* Solved edited messages bug and custom limit type

* Solved message reference bugs

* Solved emoji in button converting twice

* Support for Menu Interactions

* Fix dropdown icon alignment

* Add support for icons in selectmenus

* Emoji exception for SSLError

* Revert "Emoji exception for SSLError"

This reverts commit 5ac06d7.

* Display disabled components as disabled

* Removing w3 xmlns reference on msg references

* Updating README

* Attempt conflict resolve #2

* Versioning
  • Loading branch information
mahtoid authored Feb 15, 2022
1 parent 1a7cf3c commit 21d8cfc
Show file tree
Hide file tree
Showing 57 changed files with 1,679 additions and 1,506 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README.rst
include LICENSE
recursive-include chat_exporter/chat_exporter_html *.html
recursive-include chat_exporter/html *.html
recursive-include *.py
50 changes: 31 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DiscordChatExporterPy

.. |language| image:: https://img.shields.io/github/languages/top/mahtoid/discordchatexporterpy

DiscordChatExporterPy is a Python plugin for your discord.py bot, allowing you to export a discord channels history within a guild.
DiscordChatExporterPy is a Python lib for your discord.py (or forks) bot, allowing you to export Discord channel history in to a HTML file.

Installing
----------
Expand All @@ -25,6 +25,8 @@ To install the repository, run the command:
git clone https://github.com/mahtoid/DiscordChatExporterPy
**NOTE: If you are using discord.py 1.7.3, please use chat-exporter v1.7.3**

Usage
-----
**Basic Usage**
Expand All @@ -44,18 +46,15 @@ Usage
@bot.event
async def on_ready():
print("Live: " + bot.user.name)
chat_exporter.init_exporter(bot)
@bot.command()
async def save(ctx):
await chat_exporter.quick_export(channel, guild)
async def save(ctx: commands.Context):
await chat_exporter.quick_export(ctx.channel)
if __name__ == "__main__":
bot.run("BOT_TOKEN_HERE")
*Optional: If you want the transcript to display Members (Role) Colours then enable the Members Intent.
Passing 'guild' is optional and is only necessary when using enhanced-dpy.*
**Customisable Usage**

Expand All @@ -66,20 +65,27 @@ Passing 'guild' is optional and is only necessary when using enhanced-dpy.*
...
@bot.command()
async def save(ctx, limit: int, tz_info):
transcript = await chat_exporter.export(ctx.channel, guild, limit, tz_info)
async def save(ctx: commands.Context, limit: int, tz_info):
transcript = await chat_exporter.export(
ctx.channel,
limit=limit,
tz_info=tz_info,
)
if transcript is None:
return
transcript_file = discord.File(io.BytesIO(transcript.encode()),
filename=f"transcript-{ctx.channel.name}.html")
transcript_file = discord.File(
io.BytesIO(transcript.encode()),
filename=f"transcript-{ctx.channel.name}.html",
)
await ctx.send(file=transcript_file)
*Optional: limit and tz_info are both optional, but can be used to limit the amount of messages transcribed or set a 'local' (pytz) timezone for
the bot to transcribe message times to. Passing 'guild' is optional and is only necessary when using enhanced-dpy.*

| *Optional: limit and tz_info are both optional.*
| *'limit' is to set the amount of messages to acquire from the history.*
| *'tz_info' is to set your own custom timezone.*
|
**Raw Usage**

.. code:: py
Expand All @@ -89,21 +95,27 @@ the bot to transcribe message times to. Passing 'guild' is optional and is only
...
@bot.command()
async def purge(ctx, tz_info):
async def purge(ctx: commands.Context, tz_info):
deleted_messages = await ctx.channel.purge()
transcript = await chat_exporter.raw_export(channel, guild, deleted_messages, tz_info)
transcript = await chat_exporter.raw_export(
ctx.channel,
messages=deleted_messages,
tz_info=tz_info,
)
if transcript is None:
return
transcript_file = discord.File(io.BytesIO(transcript.encode()),
filename=f"transcript-{ctx.channel.name}.html")
transcript_file = discord.File(
io.BytesIO(transcript.encode()),
filename=f"transcript-{ctx.channel.name}.html",
)
await ctx.send(file=transcript_file)
*Optional: tz_info is optional, but can be used to set a 'local' (pytz) timezone for the bot to transcribe message times to.
Passing 'guild' is optional and is only necessary when using enhanced-dpy.*
| *Optional: tz_info is optional.*
| *'tz_info' is to set your own custom timezone.*
Screenshots
-----------
Expand Down
8 changes: 7 additions & 1 deletion chat_exporter/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
from chat_exporter.chat_exporter import export, raw_export, quick_export, init_exporter
from chat_exporter.chat_exporter import export, raw_export, quick_export

__all__ = (
export,
raw_export,
quick_export,
)
54 changes: 0 additions & 54 deletions chat_exporter/build_components.py

This file was deleted.

87 changes: 0 additions & 87 deletions chat_exporter/build_html.py

This file was deleted.

Loading

0 comments on commit 21d8cfc

Please sign in to comment.