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
-
#get_chat_message(chat_id:, message_id:) ⇒ Object
-
#list_chat_messages(chat_id:, top: 50) ⇒ Object
-
#list_message_replies(chat_id:, message_id:, top: 50) ⇒ Object
-
#reply_to_chat_message(chat_id:, message_id:, content:, content_type: 'text') ⇒ Object
-
#send_chat_message(chat_id:, content:, content_type: 'text', attachments: []) ⇒ Object
#bot_connection, #graph_connection, #oauth_connection, #user_path
Class Method Details
.trigger_words ⇒ Object
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
46
47
48
49
50
|
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 46
def get_chat_message(chat_id:, message_id:, **)
log.debug "get_chat_message(chat_id: #{chat_id}, message_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
33
|
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 28
def list_chat_messages(chat_id:, top: 50, **)
log.debug "list_chat_messages(chat_id: #{chat_id}, top: #{top})"
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
102
103
104
105
106
107
|
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 102
def list_message_replies(chat_id:, message_id:, top: 50, **)
log.debug "list_message_replies(chat_id: #{chat_id}, message_id: #{message_id}, top: #{top})"
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
84
85
86
87
88
89
|
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 84
def reply_to_chat_message(chat_id:, message_id:, content:, content_type: 'text', **)
log.debug "reply_to_chat_message(chat_id: #{chat_id}, message_id: #{message_id}, content: #{content}, content_type: #{content_type})"
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
64
65
66
67
68
69
70
|
# File 'lib/legion/extensions/microsoft_teams/runners/messages.rb', line 64
def send_chat_message(chat_id:, content:, content_type: 'text', attachments: [], **)
log.debug "send_chat_message(chat_id: #{chat_id}, content: #{content}, content_type: #{content_type})"
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
|