Skip to content

feat: handle livechat message #211

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

Merged
merged 2 commits into from
Jul 6, 2017
Merged
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
10 changes: 8 additions & 2 deletions src/rocketchat.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RocketChatUser = process.env.ROCKETCHAT_USER or "hubot"
RocketChatPassword = process.env.ROCKETCHAT_PASSWORD or "password"
ListenOnAllPublicRooms = (process.env.LISTEN_ON_ALL_PUBLIC or "false").toLowerCase() is 'true'
RespondToDirectMessage = (process.env.RESPOND_TO_DM or "false").toLowerCase() is 'true'
RespondToLivechatMessage = (process.env.RESPOND_TO_LIVECHAT or "false").toLowerCase() is "true"
RespondToEditedMessage = (process.env.RESPOND_TO_EDITED or "false").toLowerCase() is 'true'
SSLEnabled = "false"

Expand Down Expand Up @@ -141,7 +142,12 @@ class RocketChatBotAdapter extends Adapter
if isDM and not RespondToDirectMessage
return

if not isDM and not messageOptions.roomParticipant and not ListenOnAllPublicRooms
isLC = messageOptions.roomType is 'l'

if isLC and not RespondToLivechatMessage
return

if not isDM and not messageOptions.roomParticipant and not ListenOnAllPublicRooms and not RespondToLivechatMessage
return

curts = new Date(newmsg.ts.$date)
Expand Down Expand Up @@ -180,7 +186,7 @@ class RocketChatBotAdapter extends Adapter

startOfText = if message.text.indexOf('@') == 0 then 1 else 0
robotIsNamed = message.text.indexOf(@robot.name) == startOfText || message.text.indexOf(@robot.alias) == startOfText
if isDM and not robotIsNamed
if (isDM or isLC) and not robotIsNamed
message.text = "#{ @robot.name } #{ message.text }"
@robot.receive message
@robot.logger.info "Message sent to hubot brain."
Expand Down