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

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



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

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

Instance Method Details

#get_chat_message(chat_id:, message_id:) ⇒ Object



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

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



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

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



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

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



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

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



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

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