Skip to content

Commit

Permalink
2.8.0 (#117)
Browse files Browse the repository at this point in the history
* Fix type hinting compatibility with Python < 3.9 (#105)

* Merging master in to 2.8.0 (#110)

* Versioning

* Fix discord import for wrapper namespaces != discord (#104)

* Versioning

---------

Co-authored-by: mahtoid <[email protected]>
Co-authored-by: Lukas Dobler <[email protected]>

* Fix CSS/JS Issues + QOL Improvements (#108)

* Versioning

* Fix discord import for wrapper namespaces != discord (#104)

* Versioning

* Fix quick_export() Missing Argument

* Remove Use of 'proxy_url' due to Discord's CDN Changes

* Fix Embed Colour & Reduce Unnecessary Gaps

* Fix Emoji Mis-Alignment

* Fix Button Label Padding

* Equalise Footer Width

* Fix User Pop-Out

* Add Hover on User Avatars

* Fix Scrolling to Messages

* Open Buttons & Images in New Tabs + Fix Audio Container

* Change BOT Tag to New APP Tag

* Update README

* Add .vscode to Git-Ignore

* Update README.md for my Fork

* Update README.md

* Revert README Installation Changes

* Revert Asset URL Change back to Proxy URL

* Fixed Message Aside Timestamp

* Update chat_exporter/construct/assets/component.py

Co-authored-by: Lukas Dobler <[email protected]>

* Update chat_exporter/construct/assets/component.py

Co-authored-by: Lukas Dobler <[email protected]>

* Update chat_exporter/construct/assets/component.py

Co-authored-by: Lukas Dobler <[email protected]>

* Update chat_exporter/construct/assets/component.py

Co-authored-by: Lukas Dobler <[email protected]>

* Update chat_exporter/construct/assets/component.py

Co-authored-by: Lukas Dobler <[email protected]>

* Update chat_exporter/html/component/component_button.html

Co-authored-by: Lukas Dobler <[email protected]>

* Update chat_exporter/html/base.html

Co-authored-by: Lukas Dobler <[email protected]>

* Update chat_exporter/construct/assets/component.py

Co-authored-by: Lukas Dobler <[email protected]>

* Update chat_exporter/construct/message.py

Co-authored-by: Lukas Dobler <[email protected]>

* Refactoring

* Fixed Military Times

---------

Co-authored-by: mahtoid <[email protected]>
Co-authored-by: Lukas Dobler <[email protected]>

* Update discord link

* Fix a bug within LocalAttachmentHandler and regex search returning None causing AttributeError & add html meta tags to transcript (#111)

* Ensure unique filenames

Signed-off-by: doluk <[email protected]>

* Add html meta tags

Signed-off-by: doluk <[email protected]>

* Fix Local File handler

Signed-off-by: doluk <[email protected]>

* Fix regex search returning no match causing AttributeError

Signed-off-by: doluk <[email protected]>

* Exchange uuid4 with EPOCH timestamp with ms

Signed-off-by: doluk <[email protected]>

---------

Signed-off-by: doluk <[email protected]>

* Interaction Message (metadata)

* Backport Interaction

* interaction name

---------

Signed-off-by: doluk <[email protected]>
Co-authored-by: Argon <[email protected]>
Co-authored-by: mahtoid <[email protected]>
Co-authored-by: Lukas Dobler <[email protected]>
Co-authored-by: syntax <[email protected]>
  • Loading branch information
5 people authored Jul 1, 2024
1 parent 7372cb2 commit 9dd8f04
Show file tree
Hide file tree
Showing 28 changed files with 238 additions and 220 deletions.
109 changes: 35 additions & 74 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
Expand Down Expand Up @@ -50,6 +49,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
Expand All @@ -72,6 +72,7 @@ instance/
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
Expand All @@ -82,7 +83,9 @@ profile_default/
ipython_config.py

# pyenv
.python-version
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand All @@ -91,7 +94,22 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock

# pyflow
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
Expand All @@ -102,7 +120,6 @@ celerybeat.pid
*.sage.py

# Environments
.idea
.env
.venv
env/
Expand All @@ -129,77 +146,21 @@ dmypy.json
# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# VSCode
.vscode/

# Project specific ignores
bot.py
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ from discord import Attachment


class MyAttachmentHandler(AttachmentHandler):
def __init__(self, *args, **kwargs):
# Your initialization code here
# in your case we just create the cloud client
self.cloud_client = CloudClient()

async def process_asset(self, attachment: Attachment):
# Your upload logic here, in our example we just upload the asset to the cloud

Expand All @@ -258,14 +263,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 url attribute of the attachment to the generated url
attachment.url = asset_url
# and set the proxy url attribute of the attachment to the generated url
attachment.proxy_url = asset_url
return attachment

```

Note
1. The `process_asset` method should return the attachment object with the url attribute set to the generated url.
1. The `process_asset` method should return the attachment object with the proxy_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
1 change: 1 addition & 0 deletions chat_exporter/chat_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def quick_export(
after=None,
support_dev=True,
bot=bot,
attachment_handler=None
).export()
).html

Expand Down
6 changes: 3 additions & 3 deletions chat_exporter/construct/assets/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def audio(self):

self.attachments = await fill_out(self.guild, audio_attachment, [
("ATTACH_ICON", file_icon, PARSE_MODE_NONE),
("ATTACH_URL", self.attachments.url, PARSE_MODE_NONE),
("ATTACH_URL", self.attachments.proxy_url, PARSE_MODE_NONE),
("ATTACH_BYTES", str(file_size), PARSE_MODE_NONE),
("ATTACH_AUDIO", self.attachments.proxy_url, PARSE_MODE_NONE),
("ATTACH_FILE", str(self.attachments.filename), PARSE_MODE_NONE)
Expand All @@ -60,7 +60,7 @@ async def file(self):

self.attachments = await fill_out(self.guild, msg_attachment, [
("ATTACH_ICON", file_icon, PARSE_MODE_NONE),
("ATTACH_URL", self.attachments.url, PARSE_MODE_NONE),
("ATTACH_URL", self.attachments.proxy_url, PARSE_MODE_NONE),
("ATTACH_BYTES", str(file_size), PARSE_MODE_NONE),
("ATTACH_FILE", str(self.attachments.filename), PARSE_MODE_NONE)
])
Expand Down Expand Up @@ -88,7 +88,7 @@ async def get_file_icon(self) -> str:
"arj", "pkg", "z"
)

extension = self.attachments.url.rsplit('.', 1)[1]
extension = self.attachments.proxy_url.rsplit('.', 1)[1]
if extension in acrobat_types:
return DiscordUtils.file_attachment_acrobat
elif extension in webcode_types:
Expand Down
22 changes: 15 additions & 7 deletions chat_exporter/construct/assets/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,26 @@ async def build_component(self, c):
Component.menu_div_id += 1

async def build_button(self, c):
url = c.url if c.url else ""
label = c.label if c.label else ""
if c.url:
url = str(c.url)
target = " target='_blank'"
icon = str(DiscordUtils.button_external_link)
else:
url = "javascript:;"
target = ""
icon = ""

label = str(c.label) if c.label else ""
style = self.styles[str(c.style).split(".")[1]]
icon = DiscordUtils.button_external_link if url else ""
emoji = str(c.emoji) if c.emoji else ""

self.buttons += await fill_out(self.guild, component_button, [
("DISABLED", "chatlog__component-disabled" if c.disabled else "", PARSE_MODE_NONE),
("URL", str(url), PARSE_MODE_NONE),
("LABEL", str(label), PARSE_MODE_MARKDOWN),
("EMOJI", str(emoji), PARSE_MODE_EMOJI),
("ICON", str(icon), PARSE_MODE_NONE),
("URL", url, PARSE_MODE_NONE),
("LABEL", label, PARSE_MODE_MARKDOWN),
("EMOJI", emoji, PARSE_MODE_EMOJI),
("ICON", icon, PARSE_MODE_NONE),
("TARGET", target, PARSE_MODE_NONE),
("STYLE", style, PARSE_MODE_NONE)
])

Expand Down
4 changes: 3 additions & 1 deletion chat_exporter/construct/attachment_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import io
import pathlib
from typing import Union
import urllib.parse


import aiohttp
from chat_exporter.ext.discord_import import discord
Expand Down Expand Up @@ -33,7 +35,7 @@ async def process_asset(self, attachment: discord.Attachment) -> discord.Attachm
:param attachment: discord.Attachment
:return: str
"""
file_name = f"{int(datetime.datetime.utcnow().timestamp())}_{attachment.filename}".replace(' ', '%20')
file_name = urllib.parse.quote_plus(f"{datetime.datetime.utcnow().timestamp()}_{attachment.filename}")
asset_path = self.base_path / file_name
await attachment.save(asset_path)
file_url = f"{self.url_base}/{file_name}"
Expand Down
Loading

0 comments on commit 9dd8f04

Please sign in to comment.