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

Revert "Add compatibility for Coffeescript 2 (and hubot 3)" #594

Merged
merged 1 commit into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,12 @@ node_js:
- "4"
- "4.2"
env:
- HUBOT_VERSION=">=2.0 <3" COFFEESCRIPT_VERSION=">=1.6.3 <2.0"
- HUBOT_VERSION="^3.0" COFFEESCRIPT_VERSION=">=1.6.3 <2.0"
- HUBOT_VERSION="^3.0" COFFEESCRIPT_VERSION="^2.0"
# Excluding tests with Coffeescript 2 on nodejs version <= 5
# because the syntax incompatible issue. Coffeescript 2 use
# destructuring assignment syntax at https://git.io/fjcq2 but
# nodejs <= 5 doesn't support.
matrix:
exclude:
- node_js: "4.2"
env: HUBOT_VERSION="^3.0" COFFEESCRIPT_VERSION="^2.0"
- node_js: "4"
env: HUBOT_VERSION="^3.0" COFFEESCRIPT_VERSION="^2.0"
- node_js: "5"
env: HUBOT_VERSION="^3.0" COFFEESCRIPT_VERSION="^2.0"
- HUBOT_VERSION=">=2.0 <3"
- HUBOT_VERSION="^3.0"
after_success:
- npm run codecov
# The second step here installs the specific hubot version determined
# by the `env` specified in the matrix. That lets us test against
# multiple Hubot versions. This is a bit messy, but works around
# package.json only being able to specify one version.
script: npm install && npm install hubot@"$HUBOT_VERSION" coffeescript@"$COFFEESCRIPT_VERSION" && npm test
script: npm install && npm install hubot@"$HUBOT_VERSION" && npm test
9 changes: 4 additions & 5 deletions src/bot.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ class SlackBot extends Adapter
# @param {Object} options.rtm - RTM configuration options for SlackClient
# @param {Object} options.rtmStart - options for `rtm.start` Web API method
###
constructor: (robot, @options) ->
super robot
@robot = robot
constructor: (@robot, @options) ->
super
@robot.logger.info "hubot-slack adapter v#{pkg.version}"
@client = new SlackClient @options, @robot

Expand Down Expand Up @@ -306,9 +305,9 @@ class SlackBot extends Adapter

@robot.logger.debug "Received presence update message for users: #{u.id for u in users} with status: #{event.presence}"
@receive new PresenceMessage(users, event.presence)

else if event.type is "file_shared"

# Once again Hubot expects all user objects to have a room property that is used in the envelope for the message
# after it is received. If the reaction is to a message, then the `event.item.channel` contain a conversation ID.
# Otherwise reactions can be on files and file comments, which are "global" and aren't contained in a
Expand Down
23 changes: 9 additions & 14 deletions src/message.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ class ReactionMessage extends Message
# custom integration (not part of a Slack app with a bot user), then this value will be undefined.
# @param {string} event_ts - A String of the reaction event timestamp.
###
constructor: (@type, user, @reaction, @item_user, @item, @event_ts) ->
super user
@user = user
constructor: (@type, @user, @reaction, @item_user, @item, @event_ts) ->
super @user
@type = @type.replace("reaction_", "")

class FileSharedMessage extends Message

###*
Expand All @@ -32,9 +31,8 @@ class FileSharedMessage extends Message
# @param {string} file_id - A String identifying the file_id of the file that was shared.
# @param {string} event_ts - A String of the file_shared event timestamp.
###
constructor: (user, @file_id, @event_ts) ->
super user
@user = user
constructor: (@user, @file_id, @event_ts) ->
super @user

class PresenceMessage extends Message

Expand Down Expand Up @@ -81,12 +79,7 @@ class SlackTextMessage extends TextMessage
# @param {string} robot_name - The Slack username for this robot
# @param {string} robot_alias - The alias for this robot
###
constructor: (user, text, rawText, rawMessage, channel_id, robot_name, robot_alias) ->
super user, text, rawMessage.ts

@user = user
@text = text
@rawMessage = rawMessage
constructor: (@user, @text, rawText, @rawMessage, channel_id, robot_name, robot_alias) ->
# private instance properties
@_channel_id = channel_id
@_robot_name = robot_name
Expand All @@ -97,6 +90,8 @@ class SlackTextMessage extends TextMessage
@thread_ts = @rawMessage.thread_ts if @rawMessage.thread_ts?
@mentions = []

super @user, @text, @rawMessage.ts

###*
# Build the text property, a flat string representation of the contents of this message.
#
Expand Down Expand Up @@ -267,4 +262,4 @@ class SlackTextMessage extends TextMessage
exports.SlackTextMessage = SlackTextMessage
exports.ReactionMessage = ReactionMessage
exports.PresenceMessage = PresenceMessage
exports.FileSharedMessage = FileSharedMessage
exports.FileSharedMessage = FileSharedMessage