Class: Botiasloop::Commands::Conversations
- Defined in:
- lib/botiasloop/commands/conversations.rb
Overview
Conversations command - lists all conversations
Instance Method Summary collapse
-
#execute(context, args = nil) ⇒ String
Execute the conversations command Lists non-archived conversations by default, or archived conversations when specified Sorted by last updated (most recent first).
Methods inherited from Base
command, description, inherited
Instance Method Details
#execute(context, args = nil) ⇒ String
Execute the conversations command Lists non-archived conversations by default, or archived conversations when specified Sorted by last updated (most recent first)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/botiasloop/commands/conversations.rb', line 17 def execute(context, args = nil) show_archived = args.to_s.strip.downcase == "archived" current_conversation = context.conversation if show_archived conversations = context.chat.archived_conversations lines = ["**Archived Conversations**"] else conversations = context.chat.active_conversations lines = ["**Conversations**"] end if conversations.empty? lines << (show_archived ? "No archived conversations found." : "No conversations found.") return lines.join("\n") end conversations.each do |conv| prefix = (conv.id == current_conversation.id) ? "[current] " : "" label = conv.label suffix = label ? " (#{label})" : "" lines << "#{prefix}#{conv.id}#{suffix}" end lines.join("\n") end |