Skip to content
Open

3.1.0 #155

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ body:
validations:
required: true

- type: textarea
attributes:
label: Reproduction
description: How to reproduce the bug.
placeholder: Either provide a minimal reproducible example or a set of steps to reproduce the bug.
validations:
required: true

- type: textarea
attributes:
label: Bug Traceback
Expand Down
66 changes: 0 additions & 66 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: integration-test

on:
push:
branches: [ "**" ]

jobs:
integration-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Run Discord Integration Test
env:
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
run: python tests/integration_test_discord.py

- name: Upload integration artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: integration-transcript
path: tests/artifacts/integration_transcript.html
if-no-files-found: error
15 changes: 15 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: lint

on:
push:
branches: [ "**" ]

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v1
with:
args: "check --select S,E,F,I"

33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: test

on:
push:
branches: [ "**" ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Run AST unit tests
run: python -m unittest discover -s tests -p "test_*.py" -v

- name: Upload export artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: export-artifacts
path: tests/artifacts/
if-no-files-found: ignore
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ chat_exporter/config.py
*.fs*
*.sqlite

.idea/*
.idea\*
# Tests
tests/artifacts

# Bloat
.ruff_cache/

# macOS
.DS_Store
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ how to use the `AttachmentHandler`. One using the example of storing files on a
an example of storing them on Discord *(the latter merely just being an example, this will still obviously run in to
the expiration issue)*.

If you do not specify an attachment handler, chat-exporter will continue to use the (proxy) URLs for the assets.
If you do not specify an attachment handler, chat-exporter will continue to use the URLs for the assets.

<details><summary><b>Concept</b></summary>

Expand Down Expand Up @@ -266,14 +266,14 @@ class MyAttachmentHandler(AttachmentHandler):
# now we can generate the asset url from the identifier
asset_url = await self.cloud_client.get_share_url(asset_id, shared_with="everyone")

# and set the proxy url attribute of the attachment to the generated url
attachment.proxy_url = asset_url
# and set the url attribute of the attachment to the generated url
attachment.url = asset_url
return attachment

```

Note
1. The `process_asset` method should return the attachment object with the proxy_url attribute set to the generated url.
1. The `process_asset` method should return the attachment object with the url attribute set to the generated url.
2. The `process_asset` method should be an async method, as it is likely that you have to do some async operations
like fetching the content of the attachment or uploading it to the cloud.
3. You are free to add other methods in your class, and call them from `process_asset` if you need to do some
Expand Down
11 changes: 6 additions & 5 deletions chat_exporter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from chat_exporter.chat_exporter import (
export,
raw_export,
quick_export,
AttachmentHandler,
AttachmentToDiscordChannelHandler,
AttachmentToLocalFileHostHandler,
AttachmentToWebhookHandler,
AttachmentToDiscordChannelHandler)
export,
quick_export,
raw_export,
)

__version__ = "3.0.1"
__version__ = "3.1.0"

__all__ = (
export,
Expand Down
36 changes: 25 additions & 11 deletions chat_exporter/chat_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,31 @@
import io
from typing import List, Optional

from chat_exporter.construct.attachment_handler import (
AttachmentHandler,
AttachmentToDiscordChannelHandler,
AttachmentToLocalFileHostHandler,
AttachmentToWebhookHandler,
)
from chat_exporter.construct.transcript import Transcript
from chat_exporter.ext.discord_import import discord
from chat_exporter.construct.attachment_handler import AttachmentHandler, AttachmentToLocalFileHostHandler, AttachmentToDiscordChannelHandler, AttachmentToWebhookHandler

__all__ = [
"quick_export",
"export",
"raw_export",
"AttachmentHandler",
"AttachmentToLocalFileHostHandler",
"AttachmentToDiscordChannelHandler",
"AttachmentToWebhookHandler",
]


async def quick_export(
channel: discord.TextChannel,
guild: Optional[discord.Guild] = None,
bot: Optional[discord.Client] = None,
raise_exceptions: bool = False
raise_exceptions: bool = False,
):
"""
Create a quick export of your Discord channel.
Expand Down Expand Up @@ -39,16 +54,15 @@ async def quick_export(
support_dev=True,
bot=bot,
attachment_handler=None,
raise_exceptions=raise_exceptions
).export()
).html
raise_exceptions=raise_exceptions,
).export()
).html

if not transcript:
return

transcript_embed = discord.Embed(
description=f"**Transcript Name:** transcript-{channel.name}\n\n",
colour=discord.Colour.blurple()
description=f"**Transcript Name:** transcript-{channel.name}\n\n", colour=discord.Colour.blurple()
)

transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"transcript-{channel.name}.html")
Expand All @@ -67,7 +81,7 @@ async def export(
after: Optional[datetime.datetime] = None,
support_dev: Optional[bool] = True,
attachment_handler: Optional[AttachmentHandler] = None,
raise_exceptions: bool = False
raise_exceptions: bool = False,
):
"""
Create a customised transcript of your Discord channel.
Expand Down Expand Up @@ -101,7 +115,7 @@ async def export(
support_dev=support_dev,
bot=bot,
attachment_handler=attachment_handler,
raise_exceptions=raise_exceptions
raise_exceptions=raise_exceptions,
).export()
).html

Expand All @@ -116,7 +130,7 @@ async def raw_export(
fancy_times: Optional[bool] = True,
support_dev: Optional[bool] = True,
attachment_handler: Optional[AttachmentHandler] = None,
raise_exceptions: bool = False
raise_exceptions: bool = False,
):
"""
Create a customised transcript with your own captured Discord messages
Expand Down Expand Up @@ -148,6 +162,6 @@ async def raw_export(
support_dev=support_dev,
bot=bot,
attachment_handler=attachment_handler,
raise_exceptions=raise_exceptions
raise_exceptions=raise_exceptions,
).export()
).html
5 changes: 3 additions & 2 deletions chat_exporter/construct/assets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from .attachment import Attachment, AttachmentGrid
from .component import Component
from .embed import Embed
from .reaction import Reaction
from .attachment import Attachment
from .component import Component

__all__ = (
Embed,
Reaction,
Attachment,
AttachmentGrid,
Component,
)
Loading
Loading