Module: Legion::Extensions::MicrosoftTeams::Runners::Messages

Extended by:
Definitions
Includes:
Helpers::Lex, Helpers::Client
Included in:
Client
Defined in:
lib/legion/extensions/microsoft_teams/runners/messages.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Client

#bot_connection, #graph_connection, #oauth_connection, #user_path

Class Method Details

.trigger_wordsObject



13
14
15
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 13

def self.trigger_words
  %w[message messages reply replies thread send]
end

Instance Method Details

#get_chat_message(chat_id:, message_id:) ⇒ Object



45
46
47
48
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 45

def get_chat_message(chat_id:, message_id:, **)
  response = graph_connection(**).get("chats/#{chat_id}/messages/#{message_id}")
  { result: response.body }
end

#list_chat_messages(chat_id:, top: 50) ⇒ Object



28
29
30
31
32
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 28

def list_chat_messages(chat_id:, top: 50, **)
  params = { '$top' => top }
  response = graph_connection(**).get("chats/#{chat_id}/messages", params)
  { result: response.body }
end

#list_message_replies(chat_id:, message_id:, top: 50) ⇒ Object



98
99
100
101
102
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 98

def list_message_replies(chat_id:, message_id:, top: 50, **)
  params = { '$top' => top }
  response = graph_connection(**).get("chats/#{chat_id}/messages/#{message_id}/replies", params)
  { result: response.body }
end

#reply_to_chat_message(chat_id:, message_id:, content:, content_type: 'text') ⇒ Object



81
82
83
84
85
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 81

def reply_to_chat_message(chat_id:, message_id:, content:, content_type: 'text', **)
  payload = { body: { contentType: content_type, content: content } }
  response = graph_connection(**).post("chats/#{chat_id}/messages/#{message_id}/replies", payload)
  { result: response.body }
end

#send_chat_message(chat_id:, content:, content_type: 'text', attachments: []) ⇒ Object



62
63
64
65
66
67
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 62

def send_chat_message(chat_id:, content:, content_type: 'text', attachments: [], **)
  payload = { body: { contentType: content_type, content: content } }
  payload[:attachments] = attachments unless attachments.empty?
  response = graph_connection(**).post("chats/#{chat_id}/messages", payload)
  { result: response.body }
end