-
Notifications
You must be signed in to change notification settings - Fork 26
Branches - Caroline & Emily #15
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
base: master
Are you sure you want to change the base?
Conversation
…kspace having 66%
…better clarityof purpose
slack.rbWhat We're Looking For
|
| end | ||
|
|
||
| text = get_text | ||
| query_params = { token: ENV["SLACK_KEY"], channel: "CN69B7XMW", text: text, user: msg_recipient.id} |
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.
There are a couple issues with the way this is written.
The api used is meant to send a message to a specific user within a channel, rather than sending a message directly to a user or generally to a channel , which is intended to be the two options. (See api.slack.com/methods/chat.postMessage.) Happy to talk about that is the difference is unclear. Because of that, it looks like the recipient needs to be a user so trying to generally send a message to a channel won't work and the channel that needs to be entered separately is hard-coded here to be CN69B7XMW. This means that when I try to send a message to a user from my own test workspace, I'm unable to because the hard-coded channel doesn't exist.
In addition, the send_message method was meant to be supported in Recipient so that from Workspace you'd just need to call @entity.send_message(text) from Workspace.
I'm sure this will all become more clear as we do more projects but also feel free to ask a TA, tutor, me, or another staff member to dig into this with you deeper.
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.
yeah... we couldn't figure out the correct api to use bc I thought our scope is not covered. Will go check out ohter people's code for this one haha.
|
|
||
| @all_channels.each do |channel| | ||
| if (input == channel.id) || (input == channel.name.upcase) | ||
| return channel |
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 could update the @entity instance variable directly. This would be more true to OO design rather than expecting the variable to be updated by "slack.rb" from the return value. If this were done that way, no explicit return value would be needed because the "state" of the workspace instance would already be updated.
|
|
||
| when "C", "SEND MESSAGE" | ||
| puts "SENDING MESSAGE" | ||
| send_message |
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.
similar to the way there is code to handle ArgumentErrors, it'd be good to have code here to handle the Slack Api Error.
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.
oops, we forgot to wrap some of the methods in a begin/rescue block.
| end | ||
|
|
||
| def self.load_all | ||
| names = self.get_names |
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.
The way these methods are seperated is a little awkward and inefficient because the same api ends up getting called 4 times when all of that information is available in the response from each call.
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.
I understand the tradeoff though because it enables smaller, succinct methods, one for each attribute. You could accomplish both of these things by pulling the call to self.get out of these methods. If self.get were called directing from self.load_all, the results from self.get could be passed to each method like so:
result = self.get
self.get_names(result)
...
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions