Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class BroadcastService(private val repository: Repository) {
private lateinit var manager: WireApplicationManager

companion object {
private const val COMMAND_PREFIX = "/broadcast"
const val COMMAND_PREFIX = "/broadcast"
private val NOT_AUTHORIZED = """
⛔ You’re not authorized to send broadcasts.
Only approved broadcasters can use the `$COMMAND_PREFIX` command.
Expand Down
23 changes: 23 additions & 0 deletions src/main/kotlin/com/wire/broadcastapp/EventsHandler.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.wire.broadcastapp

import com.wire.broadcastapp.BroadcastService.Companion.COMMAND_PREFIX
import com.wire.broadcastapp.dao.Repository
import com.wire.sdk.WireEventsHandlerSuspending
import com.wire.sdk.model.ConversationData
import com.wire.sdk.model.ConversationMember
import com.wire.sdk.model.WireMessage

class EventsHandler : WireEventsHandlerSuspending() {
Expand All @@ -12,4 +15,24 @@ class EventsHandler : WireEventsHandlerSuspending() {
override suspend fun onTextMessageReceived(wireMessage: WireMessage.Text) {
broadcast.handleMessage(wireMessage)
}

override suspend fun onAppAddedToConversation(
conversation: ConversationData,
members: List<ConversationMember>
) {
val welcomeMessage = WireMessage.Text.create(
conversationId = conversation.id,
text = WELCOME_TEXT
)

manager.sendMessage(welcomeMessage)
}

private companion object {
const val WELCOME_TEXT =
"👋 Hi, I'm the Broadcast App. Thanks for adding me to the conversation.\n" +
"You can use me to message multiple conversations simultaneously.\n" +
"I'm here to help make everyday work a little easier.\n" +
"Use the `$COMMAND_PREFIX <your message here>` command to get started."
}
}