All Projects → mahtoid → DiscordChatExporterPy

mahtoid / DiscordChatExporterPy

Licence: GPL-3.0 license
A simple Discord chat exporter for Python Discord bots.

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to DiscordChatExporterPy

DingoLingo
A Discord music bot written in Python with support for Youtube, SoundCloud, Spotify, Bandcamp, Twitter, and custom files.
Stars: ✭ 183 (+154.17%)
Mutual labels:  discordpy, pycord
Discord-multipurpose-bot
A repository with JavaScript and Python versions of the same type of discord commands.
Stars: ✭ 27 (-62.5%)
Mutual labels:  discordpy, pycord
ExcelExport
Classes to generate Excel/CSV Report in ASP.NET Core
Stars: ✭ 39 (-45.83%)
Mutual labels:  export
Neutron-Bot
A discord bot which aims to be the only bot a server will need.
Stars: ✭ 15 (-79.17%)
Mutual labels:  discordpy
spreadsheet
Yii2 extension for export to Excel
Stars: ✭ 79 (+9.72%)
Mutual labels:  export
skinner
Skin export / import tools for Autodesk Maya
Stars: ✭ 68 (-5.56%)
Mutual labels:  export
evernote-backup
Backup & export all Evernote notes and notebooks
Stars: ✭ 104 (+44.44%)
Mutual labels:  export
Data-Export
Data-Export支持将链上数据导出到MySQL、ES等便于进行大数据处理的存储介质中,解决区块链数据复杂查询、分析、可视化和处理的问题。
Stars: ✭ 37 (-48.61%)
Mutual labels:  export
signal-media-exporter
A script to export media files from Signal Desktop.
Stars: ✭ 19 (-73.61%)
Mutual labels:  export
great-migration
Copy objects from Rackspace to S3
Stars: ✭ 15 (-79.17%)
Mutual labels:  export
arctee
Atomic tee
Stars: ✭ 22 (-69.44%)
Mutual labels:  export
Fortnite-LobbyBot
No description or website provided.
Stars: ✭ 38 (-47.22%)
Mutual labels:  discordpy
NanoBot
[Discontinued] A music, fun, Overwatch, and moderation bot written in discord.py.
Stars: ✭ 11 (-84.72%)
Mutual labels:  discordpy
browserexport
backup and parse browser history databases (chrome, firefox, safari, and other chrome/firefox derivatives)
Stars: ✭ 54 (-25%)
Mutual labels:  export
icingaweb2-module-pdfexport
PDF export functionality for Icinga Web 2
Stars: ✭ 27 (-62.5%)
Mutual labels:  export
porter
Export legacy forums into a format Vanilla Forums can import.
Stars: ✭ 39 (-45.83%)
Mutual labels:  export
export-command
Exports WordPress content to a WXR file.
Stars: ✭ 12 (-83.33%)
Mutual labels:  export
wechat-export
📃 Export WeChat chat histories to HTML files.
Stars: ✭ 585 (+712.5%)
Mutual labels:  export
elastic-query-export
🚚 Export Data from ElasticSearch to CSV/JSON using a Lucene Query (e.g. from Kibana) or a raw JSON Query string
Stars: ✭ 56 (-22.22%)
Mutual labels:  export
excel mysql
Module for import Excel files to MySQL table and export MySQL table to Excel file using PHPExcel
Stars: ✭ 30 (-58.33%)
Mutual labels:  export

Version Language Forks Stargazers Issues GPL License

DiscordChatExporterPy

Export Discord chats with your discord.py (or fork) bots!
Join Discord · Report Bug · Request Feature


Installation

To install the library to your virtual environment, for bot usage, run the command:

pip install chat-exporter

To clone the repository locally, run the command:

git clone https://github.com/mahtoid/DiscordChatExporterPy

(back to top)


Usage

There are currently 3 methods (functions) to chat-exporter which you can use to export your chat.
Expand the blocks below to learn the functions, arguments and usages.

Basic Usage

.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):
channel: discord.TextChannel object, whether ctx.channel or any channel you gather.

Optional Argument(s):
bot: commands.Bot object to gather members who are no longer in your guild.

Return Argument:
discord.Message: The message quick_export will send, containing the embed and exported chat file.

Example:

import discord
import chat_exporter
from discord.ext import commands

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

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

...

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

...
Customisable Usage

.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):
channel: discord.TextChannel object, whether ctx.channel or any channel you gather.

Optional Argument(s):
limit: Integer value to set the limit (amount of messages) the chat exporter gathers when grabbing the history (default=unlimited).
tz_info: String value of a TZ Database name to set a custom timezone for the exported messages (default=UTC)
military_time: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format)
bot: commands.Bot object to gather members who are no longer in your guild.

Return Argument:
transcript: The HTML build-up for you to construct the HTML File with Discord.

Example:

import io

...

@bot.command()
async def save(ctx: commands.Context, limit: int, tz_info: str, military_time: bool):
    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)
Raw Usage

.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):
channel: discord.TextChannel object, whether ctx.channel or any channel you gather (this is just for padding the header).
messages: A list of Message objects which you wish to export to an HTML file.

Optional Argument(s):
tz_info: String value of a TZ Database name to set a custom timezone for the exported messages (default=UTC)
military_time: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format)
bot: commands.Bot object to gather members who are no longer in your guild.

Return Argument:
transcript: The HTML build-up for you to construct the HTML File with Discord.

Example:

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)

(back to top)


Screenshots

General
    Discord
    Chat-Exporter

(back to top)


Additional Functions

Link Function 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.

    quick_link 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):
    channel: discord.TextChannel object, whether ctx.channel or any channel you gather.
    message: The Discord message containing the transcript file

    Return Argument:
    discord.Message: The message quick_link will send, containing the embed.

    Example:

    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)
    link A simple function to return the link you will need to view the transcript online.

    Required Argument(s):
    message: The Discord message containing the transcript file

    Return Argument:
    link: The link to view the transcript file online

    Example:

    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(transcript_file)
        link = await chat_exporter.link(message)
    
        await ctx.send("Click this link to view the transcript online: " + link)

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


Attributions

This project borrows CSS and HTML code from Tyrrrz's C# DiscordChatExporter repository.

(back to top)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].