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 it gets invited into a channel #4

Open
PhillippOhlandt opened this issue Oct 29, 2016 · 2 comments
Open

Error when it gets invited into a channel #4

PhillippOhlandt opened this issue Oct 29, 2016 · 2 comments

Comments

@PhillippOhlandt
Copy link

When I invite the bot into a channel, I get the following error message in the console and the process stops:

2016/10/29 19:42:35 json: cannot unmarshal object into Go value of type string

I already applied #3.

@PhillippOhlandt PhillippOhlandt changed the title Bot exists when it gets invited into a channel Error when it gets invited into a channel Oct 29, 2016
@PhillippOhlandt
Copy link
Author

PhillippOhlandt commented Oct 29, 2016

Ok, the problem is, that for regular slack events (message, etc.), channel is a string. But when you get the channel_joined event, channel is an object with information about the channel. Therefore GO can't fill the struct and fails.

Here is the raw data of the two events I receive when I invite my bot into a channel:

{"type":"channel_joined","channel":{"id":"C052LFU5N","name":"code","is_channel":true,"created":1432794048,"creator":"U04V7ARLN","is_archived":false,"is_general":false,"is_member":true,"last_read":"1477772629.000007","latest":{"user":"U2VTZ5U64","text":"<@U2VTZ5U64|my_bot> has left the channel","type":"message","subtype":"channel_leave","ts":"1477772629.000007"},"unread_count":0,"unread_count_display":0,"members":["U04V7ARLN","U2VTZ5U64"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"","creator":"","last_set":0}}}
{"user":"U2VTZ5U64","inviter":"U04V7ARLN","user_profile":{"avatar_hash":"3c0d22192158","image_72":"https://avatars.slack-edge.com/2016-10-29/97900532003_3c0d22192158ab559938_72.png","first_name":null,"real_name":"","name":"my_bot"},"type":"message","subtype":"channel_join","team":"T04V7ARLC","text":"<@U2VTZ5U64|my_bot> has joined the channel","channel":"C052LFU5N","ts":"1477774072.000008"}

@PhillippOhlandt
Copy link
Author

Same problem with team_join and user_change events because they have objects in the user key and not strings.

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

No branches or pull requests

1 participant