InteractionsChatExporter


NameInteractionsChatExporter JSON
Version 2.5.4 PyPI version JSON
download
home_page
SummaryA simple Discord chat exporter for Interactions.py Discord bots.
upload_time2023-04-22 23:43:07
maintainer
docs_urlNone
author
requires_python>=3.6
licenseGPL-3.0-only
keywords chat exporter discord chat exporter discord discordpy disnake pycord nextcord
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">

  <h2>InteractionsChatExporter</h2>

  <p>
    Export Discord chats with your interactions.py bots!
    <br />
  </p>
</div>

---
## Installation

To install the library to your virtual environment, for bot usage, run the command:
```sh 
pip install InteractionsChatExporter
```

To clone the repository locally, run the command:
```sh
git clone https://github.com/DylZZZ/InteractionsChatExporter
```

<p align="right">(<a href="#top">back to top</a>)</p>

---
## Usage

There are currently 3 methods (functions) to `InteractionsChatExporter` which you can use to export your chat.<br/>
_Expand the blocks below to learn the functions, arguments and usages._
<details><summary><b>Basic Usage</b></summary>

`.quick_export()` is the simplest way of using chat-exporter.

Using the _quick_export_ function will gather the history of the channel you give, build the transcript then post the file and embed directly to the channel - returning a message object gathered from the message it posted.

This is mostly seen as a demo function, as opposed to a command you should actually use. 

**Required Argument(s):**<br/>
`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather.

**Optional Argument(s):**<br/>
`bot`: `commands.Bot` object to gather members who are no longer in your guild.

**Return Argument:**<br/>
`discord.Message`: The message _quick_export_ will send, containing the embed and exported chat file.

**Example:**
```python
import discord
import chat_exporter
from discord.ext import commands

intents = discord.Intents.default()
intents.members = True
intents.message_content = True

bot = commands.Bot(command_prefix="!", intents=intents)

...

@bot.command()
async def save(ctx: commands.Context):
    await chat_exporter.quick_export(ctx.channel)

...
```

</details>

<details><summary><b>Customisable Usage</b></summary>

`.export()` is the most efficient and flexible method to export a chat using chat-exporter.

Using the _export_ function will generate a transcript using the channel you pass in, along with using any of the custom kwargs passed in to set limits, timezone, 24h formats and more (listed below).

This would be the main function to use within chat-exporter.

**Required Argument(s):**<br/>
`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather.

**Optional Argument(s):**<br/>
`limit`: Integer value to set the limit (amount of messages) the chat exporter gathers when grabbing the history (default=unlimited).<br/>
`tz_info`: String value of a [TZ Database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) to set a custom timezone for the exported messages (default=UTC)<br/>
`military_time`: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format)<br/>
`fancy_times`: Boolean value which toggles the 'fancy times' (Today|Yesterday|Day)<br/>
`bot`: `commands.Bot` object to gather members who are no longer in your guild.

**Return Argument:**<br/>
`transcript`: The HTML build-up for you to construct the HTML File with Discord.

**Example:**
```python
import io

...

@bot.command()
async def save(ctx: commands.Context, limit: int = 100, tz_info: str = "UTC", military_time: bool = True):
    transcript = await chat_exporter.export(
        ctx.channel,
        limit=limit,
        tz_info=tz_info,
        military_time=military_time,
        bot=bot,
    )

    if transcript is None:
        return

    transcript_file = discord.File(
        io.BytesIO(transcript.encode()),
        filename=f"transcript-{ctx.channel.name}.html",
    )

    await ctx.send(file=transcript_file)
```
</details>
<details><summary><b>Raw Usage</b></summary>

`.raw_export()` is for the crazy people who like to do their own thing when using chat-exporter.

Using the _raw_export_ function will generate a transcript using the list of messages you pass in, along with using any of the custom kwargs passed in to set limits, timezone, 24h formats and more (listed below).

This would be for people who want to filter what content to export.

**Required Argument(s):**<br/>
`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather (this is just for padding the header).<br/>
`messages`: A list of Message objects which you wish to export to an HTML file.

**Optional Argument(s):**<br/>
`tz_info`: String value of a [TZ Database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) to set a custom timezone for the exported messages (default=UTC)<br/>
`military_time`: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format)<br/>
`fancy_times`: Boolean value which toggles the 'fancy times' (Today|Yesterday|Day)<br/>
`bot`: `commands.Bot` object to gather members who are no longer in your guild.

**Return Argument:**<br/>
`transcript`: The HTML build-up for you to construct the HTML File with Discord.

**Example:**
```python
import io

...

@bot.command()
async def purge(ctx: commands.Context, tz_info: str, military_time: bool):
    deleted_messages = await ctx.channel.purge()

    transcript = await chat_exporter.raw_export(
        ctx.channel,
        messages=deleted_messages,
        tz_info=tz_info,
        military_time=military_time,
        bot=bot,
    )

    if transcript is None:
        return

    transcript_file = discord.File(
        io.BytesIO(transcript.encode()),
        filename=f"transcript-{ctx.channel.name}.html",
    )

    await ctx.send(file=transcript_file)
```
</details>

<p align="right">(<a href="#top">back to top</a>)</p>

---
## Screenshots

<details><summary><b>General</b></summary>
<ol>
    <details><summary>Discord</summary>
    <img src="https://raw.githubusercontent.com/mahtoid/DiscordChatExporterPy/master/.screenshots/channel_output.png">
    </details>
    <details><summary>Chat-Exporter</summary>
    <img src="https://raw.githubusercontent.com/mahtoid/DiscordChatExporterPy/master/.screenshots/html_output.png">
    </details>
</ol>
</details>
<p align="right">(<a href="#top">back to top</a>)</p>


---
## Additional Functions

<details><summary><b>Link Function</b></summary>
Downloading exported chats can build up a bunch of unwanted files on your PC which can get annoying, additionally - not everyone wants to download content from Discord.

Due to these pain, and many requests - I have built a fancy PHP script which will show the transcript file within a browser.<br/>
<ol>
<details><summary>quick_link</summary>
Similar in design to `.quick_export()` this is a bit of a demo function to produce a link and to give you an embed.

**Required Argument(s):**<br/>
`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather.<br/>
`message`: The Discord message containing the transcript file

**Return Argument:**<br/>
`discord.Message`: The message _quick_link_ will send, containing the embed.

**Example:**
```python
import chat_exporter

...

@bot.command()
async def save(ctx: commands.Context):
    message = await chat_exporter.quick_export(ctx.channel)
    await chat_exporter.quick_link(ctx.channel, message)
```
</details>

<details><summary>link</summary>
A simple function to return the link you will need to view the transcript online.

**Required Argument(s):**<br/>
`message`: The Discord message containing the transcript file

**Return Argument:**<br/>
`link`: The link to view the transcript file online

**Example:**
```python
import io

import chat_exporter

...

@bot.command()
async def save(ctx: commands.Context):
    transcript = await chat_exporter.export(ctx.channel)
    
    if transcript is None:
        return

    transcript_file = discord.File(
        io.BytesIO(transcript.encode()),
        filename=f"transcript-{ctx.channel.name}.html",
    )

    message = await ctx.send(file=transcript_file)
    link = await chat_exporter.link(message)

    await ctx.send("Click this link to view the transcript online: " + link)
```
</details>
</ol>

_Please note that the PHP script does NOT store any information.<br/>
It simply makes a request to the given URL and echos (prints) the content for you to be able to view it._

</details>

---
## Attributions

*This is a fork of [DiscordChatExporterPy](https://github.com/mahtoid/DiscordChatExporterPy) full credits go to him.*
*This project borrows CSS and HTML code from [Tyrrrz's C# DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter/) repository.*

<p align="right">(<a href="#top">back to top</a>)</p>


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "InteractionsChatExporter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "chat exporter,discord chat exporter,discord,discordpy,disnake,pycord,nextcord",
    "author": "",
    "author_email": "mahtoid <info@mahto.id>",
    "download_url": "https://files.pythonhosted.org/packages/ad/d7/5abb0dca6ed97440bfc060f668aa8eefb76d0e6bd621a713285fc59707c9/InteractionsChatExporter-2.5.4.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n\n  <h2>InteractionsChatExporter</h2>\n\n  <p>\n    Export Discord chats with your interactions.py bots!\n    <br />\n  </p>\n</div>\n\n---\n## Installation\n\nTo install the library to your virtual environment, for bot usage, run the command:\n```sh \npip install InteractionsChatExporter\n```\n\nTo clone the repository locally, run the command:\n```sh\ngit clone https://github.com/DylZZZ/InteractionsChatExporter\n```\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n---\n## Usage\n\nThere are currently 3 methods (functions) to `InteractionsChatExporter` which you can use to export your chat.<br/>\n_Expand the blocks below to learn the functions, arguments and usages._\n<details><summary><b>Basic Usage</b></summary>\n\n`.quick_export()` is the simplest way of using chat-exporter.\n\nUsing the _quick_export_ function will gather the history of the channel you give, build the transcript then post the file and embed directly to the channel - returning a message object gathered from the message it posted.\n\nThis is mostly seen as a demo function, as opposed to a command you should actually use. \n\n**Required Argument(s):**<br/>\n`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather.\n\n**Optional Argument(s):**<br/>\n`bot`: `commands.Bot` object to gather members who are no longer in your guild.\n\n**Return Argument:**<br/>\n`discord.Message`: The message _quick_export_ will send, containing the embed and exported chat file.\n\n**Example:**\n```python\nimport discord\nimport chat_exporter\nfrom discord.ext import commands\n\nintents = discord.Intents.default()\nintents.members = True\nintents.message_content = True\n\nbot = commands.Bot(command_prefix=\"!\", intents=intents)\n\n...\n\n@bot.command()\nasync def save(ctx: commands.Context):\n    await chat_exporter.quick_export(ctx.channel)\n\n...\n```\n\n</details>\n\n<details><summary><b>Customisable Usage</b></summary>\n\n`.export()` is the most efficient and flexible method to export a chat using chat-exporter.\n\nUsing the _export_ function will generate a transcript using the channel you pass in, along with using any of the custom kwargs passed in to set limits, timezone, 24h formats and more (listed below).\n\nThis would be the main function to use within chat-exporter.\n\n**Required Argument(s):**<br/>\n`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather.\n\n**Optional Argument(s):**<br/>\n`limit`: Integer value to set the limit (amount of messages) the chat exporter gathers when grabbing the history (default=unlimited).<br/>\n`tz_info`: String value of a [TZ Database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) to set a custom timezone for the exported messages (default=UTC)<br/>\n`military_time`: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format)<br/>\n`fancy_times`: Boolean value which toggles the 'fancy times' (Today|Yesterday|Day)<br/>\n`bot`: `commands.Bot` object to gather members who are no longer in your guild.\n\n**Return Argument:**<br/>\n`transcript`: The HTML build-up for you to construct the HTML File with Discord.\n\n**Example:**\n```python\nimport io\n\n...\n\n@bot.command()\nasync def save(ctx: commands.Context, limit: int = 100, tz_info: str = \"UTC\", military_time: bool = True):\n    transcript = await chat_exporter.export(\n        ctx.channel,\n        limit=limit,\n        tz_info=tz_info,\n        military_time=military_time,\n        bot=bot,\n    )\n\n    if transcript is None:\n        return\n\n    transcript_file = discord.File(\n        io.BytesIO(transcript.encode()),\n        filename=f\"transcript-{ctx.channel.name}.html\",\n    )\n\n    await ctx.send(file=transcript_file)\n```\n</details>\n<details><summary><b>Raw Usage</b></summary>\n\n`.raw_export()` is for the crazy people who like to do their own thing when using chat-exporter.\n\nUsing the _raw_export_ function will generate a transcript using the list of messages you pass in, along with using any of the custom kwargs passed in to set limits, timezone, 24h formats and more (listed below).\n\nThis would be for people who want to filter what content to export.\n\n**Required Argument(s):**<br/>\n`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather (this is just for padding the header).<br/>\n`messages`: A list of Message objects which you wish to export to an HTML file.\n\n**Optional Argument(s):**<br/>\n`tz_info`: String value of a [TZ Database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) to set a custom timezone for the exported messages (default=UTC)<br/>\n`military_time`: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format)<br/>\n`fancy_times`: Boolean value which toggles the 'fancy times' (Today|Yesterday|Day)<br/>\n`bot`: `commands.Bot` object to gather members who are no longer in your guild.\n\n**Return Argument:**<br/>\n`transcript`: The HTML build-up for you to construct the HTML File with Discord.\n\n**Example:**\n```python\nimport io\n\n...\n\n@bot.command()\nasync def purge(ctx: commands.Context, tz_info: str, military_time: bool):\n    deleted_messages = await ctx.channel.purge()\n\n    transcript = await chat_exporter.raw_export(\n        ctx.channel,\n        messages=deleted_messages,\n        tz_info=tz_info,\n        military_time=military_time,\n        bot=bot,\n    )\n\n    if transcript is None:\n        return\n\n    transcript_file = discord.File(\n        io.BytesIO(transcript.encode()),\n        filename=f\"transcript-{ctx.channel.name}.html\",\n    )\n\n    await ctx.send(file=transcript_file)\n```\n</details>\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n---\n## Screenshots\n\n<details><summary><b>General</b></summary>\n<ol>\n    <details><summary>Discord</summary>\n    <img src=\"https://raw.githubusercontent.com/mahtoid/DiscordChatExporterPy/master/.screenshots/channel_output.png\">\n    </details>\n    <details><summary>Chat-Exporter</summary>\n    <img src=\"https://raw.githubusercontent.com/mahtoid/DiscordChatExporterPy/master/.screenshots/html_output.png\">\n    </details>\n</ol>\n</details>\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n\n---\n## Additional Functions\n\n<details><summary><b>Link Function</b></summary>\nDownloading exported chats can build up a bunch of unwanted files on your PC which can get annoying, additionally - not everyone wants to download content from Discord.\n\nDue to these pain, and many requests - I have built a fancy PHP script which will show the transcript file within a browser.<br/>\n<ol>\n<details><summary>quick_link</summary>\nSimilar in design to `.quick_export()` this is a bit of a demo function to produce a link and to give you an embed.\n\n**Required Argument(s):**<br/>\n`channel`: `discord.TextChannel` object, whether `ctx.channel` or any channel you gather.<br/>\n`message`: The Discord message containing the transcript file\n\n**Return Argument:**<br/>\n`discord.Message`: The message _quick_link_ will send, containing the embed.\n\n**Example:**\n```python\nimport chat_exporter\n\n...\n\n@bot.command()\nasync def save(ctx: commands.Context):\n    message = await chat_exporter.quick_export(ctx.channel)\n    await chat_exporter.quick_link(ctx.channel, message)\n```\n</details>\n\n<details><summary>link</summary>\nA simple function to return the link you will need to view the transcript online.\n\n**Required Argument(s):**<br/>\n`message`: The Discord message containing the transcript file\n\n**Return Argument:**<br/>\n`link`: The link to view the transcript file online\n\n**Example:**\n```python\nimport io\n\nimport chat_exporter\n\n...\n\n@bot.command()\nasync def save(ctx: commands.Context):\n    transcript = await chat_exporter.export(ctx.channel)\n    \n    if transcript is None:\n        return\n\n    transcript_file = discord.File(\n        io.BytesIO(transcript.encode()),\n        filename=f\"transcript-{ctx.channel.name}.html\",\n    )\n\n    message = await ctx.send(file=transcript_file)\n    link = await chat_exporter.link(message)\n\n    await ctx.send(\"Click this link to view the transcript online: \" + link)\n```\n</details>\n</ol>\n\n_Please note that the PHP script does NOT store any information.<br/>\nIt simply makes a request to the given URL and echos (prints) the content for you to be able to view it._\n\n</details>\n\n---\n## Attributions\n\n*This is a fork of [DiscordChatExporterPy](https://github.com/mahtoid/DiscordChatExporterPy) full credits go to him.*\n*This project borrows CSS and HTML code from [Tyrrrz's C# DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter/) repository.*\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-only",
    "summary": "A simple Discord chat exporter for Interactions.py Discord bots.",
    "version": "2.5.4",
    "split_keywords": [
        "chat exporter",
        "discord chat exporter",
        "discord",
        "discordpy",
        "disnake",
        "pycord",
        "nextcord"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aed7eb04f3998f99a6f828f3b590c95a40cbaa5c381803ec94cda9da7927961a",
                "md5": "d35d6989b5a54797ca8a8ccfd6d348df",
                "sha256": "ba60c1b643ef33d8455c0371c77c10179f6f6b8fd1060cc22e38ec6573776764"
            },
            "downloads": -1,
            "filename": "InteractionsChatExporter-2.5.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d35d6989b5a54797ca8a8ccfd6d348df",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 57817,
            "upload_time": "2023-04-22T23:43:05",
            "upload_time_iso_8601": "2023-04-22T23:43:05.936526Z",
            "url": "https://files.pythonhosted.org/packages/ae/d7/eb04f3998f99a6f828f3b590c95a40cbaa5c381803ec94cda9da7927961a/InteractionsChatExporter-2.5.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "add75abb0dca6ed97440bfc060f668aa8eefb76d0e6bd621a713285fc59707c9",
                "md5": "2059c6f36af0538b9e1ab03e06831c19",
                "sha256": "b947c88d79fed5e0ad8854d09fa8264528f0b8894f1018830f7e160314e642a6"
            },
            "downloads": -1,
            "filename": "InteractionsChatExporter-2.5.4.tar.gz",
            "has_sig": false,
            "md5_digest": "2059c6f36af0538b9e1ab03e06831c19",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 46686,
            "upload_time": "2023-04-22T23:43:07",
            "upload_time_iso_8601": "2023-04-22T23:43:07.827714Z",
            "url": "https://files.pythonhosted.org/packages/ad/d7/5abb0dca6ed97440bfc060f668aa8eefb76d0e6bd621a713285fc59707c9/InteractionsChatExporter-2.5.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-22 23:43:07",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "interactionschatexporter"
}
        
Elapsed time: 0.05979s