-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to skip messages when a user joins/leaves a channel #212
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
from slackviewer.constants import SLACKVIEWER_TEMP_PATH | ||
from slackviewer.utils.click import envvar, flag_ennvar | ||
from slackviewer.reader import Reader | ||
from slackviewer.archive import get_export_info | ||
from jinja2 import Environment, PackageLoader | ||
|
||
|
||
|
@@ -37,32 +36,29 @@ def clean(wet): | |
@click.option('--show-dms', is_flag=True, default=False, help="Show direct messages") | ||
@click.option("--since", default=None, type=click.DateTime(formats=["%Y-%m-%d"]), | ||
help="Only show messages since this date.") | ||
@click.option('--skip-channel-member-change', is_flag=True, default=False, envvar='SKIP_CHANNEL_MEMBER_CHANGE', help="Hide channel join/leave messages") | ||
@click.option("--template", default=None, type=click.File('r'), help="Custom single file export template") | ||
@click.argument('archive_dir') | ||
@click.argument('archive') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this rename is to have the same config['archive'] name as |
||
def export(**kwargs): | ||
config = kwargs | ||
|
||
def export(archive_dir, debug, since, template, show_dms): | ||
css = pkgutil.get_data('slackviewer', 'static/viewer.css').decode('utf-8') | ||
|
||
tmpl = Environment(loader=PackageLoader('slackviewer')).get_template("export_single.html") | ||
if template: | ||
tmpl = Environment(loader=PackageLoader('slackviewer')).from_string(template.read()) | ||
export_file_info = get_export_info(archive_dir) | ||
config = { | ||
"debug": debug, | ||
"since": since, | ||
} | ||
r = Reader(export_file_info["readable_path"], config) | ||
if config["template"]: | ||
tmpl = Environment(loader=PackageLoader('slackviewer')).from_string(config["template"].read()) | ||
r = Reader(config) | ||
channel_list = sorted( | ||
[{"channel_name": k, "messages": v} for (k, v) in r.compile_channels().items()], | ||
key=lambda d: d["channel_name"] | ||
) | ||
|
||
dm_list = [] | ||
mpims = [] | ||
if show_dms: | ||
if config["show_dms"]: | ||
# | ||
# Direct DMs | ||
dm_list = r.compile_dm_messages() | ||
dm_list = r.compile_dm_messages() | ||
dm_users = r.compile_dm_users() | ||
|
||
# make list better lookupable. Also hide own user in 1:1 DMs | ||
|
@@ -89,13 +85,14 @@ def export(archive_dir, debug, since, template, show_dms): | |
html = tmpl.render( | ||
css=css, | ||
generated_on=datetime.now(), | ||
workspace_name=export_file_info["workspace_name"], | ||
source_file=export_file_info["basename"], | ||
workspace_name=r.slack_name(), | ||
source_file=os.path.basename(config["archive"]), | ||
channels=channel_list, | ||
dms=dm_list, | ||
mpims=mpims, | ||
) | ||
with open(export_file_info['stripped_name'] + '.html', 'wb') as outfile: | ||
filename = f"{r.slack_name()}.html" | ||
with open(filename, 'wb') as outfile: | ||
outfile.write(html.encode('utf-8')) | ||
|
||
print("Exported to {}.html".format(export_file_info['stripped_name'])) | ||
print(f"Exported to {filename}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was only used by cli.py. At the same time the workspace name is also computed in Reader()