Skip to content
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

Error when a channel is empty #105

Closed
bblising opened this issue Jul 30, 2019 · 4 comments · Fixed by #118
Closed

Error when a channel is empty #105

bblising opened this issue Jul 30, 2019 · 4 comments · Fixed by #118

Comments

@bblising
Copy link
Contributor

We are on on a free subscription and we've long forgotten whether we used the default Random and General channels. They are empty after using https://github.com/zach-snell/slack-export and this causes an exception to the lines

    if "general" in channels:
        return channel_name("general")
    else:
        return channel_name(channels[0])

in app.py. The workaround I did is to wrap this in an exception and return the first DM instead.

@hfaran
Copy link
Owner

hfaran commented Sep 19, 2019

What's the exception that is thrown?

@asmaier
Copy link

asmaier commented Dec 13, 2019

I ran into the same issue. It happens if you are using https://github.com/zach-snell/slack-export , but don't export the public channels. The exception is

File "...slack-export/env_slack-export/lib/python3.6/site-packages/slackviewer/app.py", line 89, in index
     return channel_name(channels[0])
 IndexError: list index out of range

@chopley
Copy link
Contributor

chopley commented Jan 7, 2020

This is a problem when no public channels are requested in the export. This can be handled by adding other messages types possible from https://github.com/zach-snell/slack-export e.g. private groups, DMS etc.. A suggested start for bug correction is below ..packages/slackviewer/app.py

@app.route("/")
def index():
    channels = list(flask._app_ctx_stack.channels.keys())
    groups = list(flask._app_ctx_stack.groups.keys())
    dm_users = list(flask._app_ctx_stack.dm_users)
    mpim_users = list(flask._app_ctx_stack.mpim_users)
    if(len(channels) > 0):
        if "general" in channels:
            return channel_name("general")
        else:
            return channel_name(channels[0])
    elif(len(groups) >0):
        return(group_name(groups[0]))
    elif(len(dm_users) >0):
        return(dm_id(dm_users[0]))
    else:
        print("Not sure where to start- Try adding a Private group, Public group or DM to the slack-export ")

@hfaran
Copy link
Owner

hfaran commented Jan 16, 2020

Release 1.0.1 published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants