Skip to content

Commit 240a0c9

Browse files
committed
New way of posting to slack via bot app.
1 parent 291ed6f commit 240a0c9

File tree

3 files changed

+1
-18
lines changed

3 files changed

+1
-18
lines changed

app/controllers/games_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ def show
2525
def say
2626
text = params[:text]
2727
game_id = params[:game_id]
28-
gandhi_url = "https://vignette.wikia.nocookie.net/civilization/images/3/36/Gandhi_%28Civ5%29.png/revision/latest?cb=20121104232443"
2928
game = ReadModel::GameReadModel.find_by(id: game_id)
3029
client = Slack::Web::Client.new(token: game.slack_token)
3130
begin
32-
client.chat_postMessage(channel: game.slack_channel, text: text, as_user: false, icon_url: gandhi_url)
31+
client.chat_postMessage(channel: game.slack_channel, text: text)
3332
rescue => e
3433
puts(e.inspect)
3534
end

notifications/lib/notifications/slack_notifier.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ def new_turn_notification(event)
2727
client.chat_postMessage(
2828
channel: game.slack_channel,
2929
text: game.build_slack_new_turn_message(event.data),
30-
as_user: false,
31-
icon_url: gandhi_url
3230
)
3331
end
3432

@@ -44,17 +42,11 @@ def maybe_notify_remaining_players(event)
4442
client.chat_postMessage(
4543
channel: game.slack_channel,
4644
text: "Turn " + remaining_players_mentions,
47-
as_user: false,
48-
icon_url: gandhi_url
4945
)
5046
logger.warn("Slack response: #{response.pretty_inspect}") if logger
5147
end
5248
end
5349

54-
def gandhi_url
55-
"https://vignette.wikia.nocookie.net/civilization/images/3/36/Gandhi_%28Civ5%29.png/revision/latest?cb=20121104232443"
56-
end
57-
5850
attr_reader :logger, :event_store
5951
end
6052
end

notifications/spec/notifications/slack_notifier_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ def given(*domain_events)
4747
stub = stub_request(:post, "https://slack.com/api/chat.postMessage")
4848
.with(
4949
body: {
50-
"as_user" => "false",
5150
"channel" => "#arkency58",
52-
"icon_url" => "https://vignette.wikia.nocookie.net/civilization/images/3/36/Gandhi_%28Civ5%29.png/revision/latest?cb=20121104232443",
5351
"text" => "Game Turn 1 <!channel>\nsteam://run/8930/q/%2Bconnect%2010.4.0.28"
5452
},
5553
headers: {
@@ -71,9 +69,7 @@ def given(*domain_events)
7169
stub = stub_request(:post, "https://slack.com/api/chat.postMessage")
7270
.with(
7371
body: {
74-
"as_user" => "false",
7572
"channel" => "#arkency58",
76-
"icon_url" => "https://vignette.wikia.nocookie.net/civilization/images/3/36/Gandhi_%28Civ5%29.png/revision/latest?cb=20121104232443",
7773
"text" => "Turn <@slack_user>"
7874
},
7975
headers: {
@@ -116,9 +112,7 @@ def given(*domain_events)
116112
stub0 = stub_request(:post, "https://slack.com/api/chat.postMessage")
117113
.with(
118114
body: {
119-
"as_user" => "false",
120115
"channel" => "#arkency58",
121-
"icon_url" => "https://vignette.wikia.nocookie.net/civilization/images/3/36/Gandhi_%28Civ5%29.png/revision/latest?cb=20121104232443",
122116
"text" => "Turn <@slack_user> <@some_hidden_identifier>"
123117
},
124118
headers: {
@@ -133,9 +127,7 @@ def given(*domain_events)
133127
stub1 = stub_request(:post, "https://slack.com/api/chat.postMessage")
134128
.with(
135129
body: {
136-
"as_user" => "false",
137130
"channel" => "#arkency58",
138-
"icon_url" => "https://vignette.wikia.nocookie.net/civilization/images/3/36/Gandhi_%28Civ5%29.png/revision/latest?cb=20121104232443",
139131
"text" => "Turn <@slack_user>"
140132
},
141133
headers: {

0 commit comments

Comments
 (0)