File tree Expand file tree Collapse file tree
src/yetibot/core/commands
test/yetibot/core/test/commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change 573573 whole thread lets a follow-up like \" retry\" resolve to the original ask."
574574 [channel-id]
575575 (try
576- (let [topic (try (:name @(discord/get-channel! (rest-conn ) channel-id))
577- (catch Exception _ nil ))
578- lines (->> (all-channel-messages channel-id)
579- (sort-by :timestamp )
580- (map (fn [m] (str (get-in m [:author :username ]) " : " (:content m))))
581- (remove string/blank?))]
582- (string/join " \n " (cond->> lines
583- (not (string/blank? topic)) (cons (str " [thread topic] " topic)))))
576+ (let [channel @(discord/get-channel! (rest-conn ) channel-id)
577+ type (:type channel)]
578+ (if (not (#{10 11 12 } type))
579+ " "
580+ (let [topic (:name channel)
581+ lines (->> (all-channel-messages channel-id)
582+ (sort-by :timestamp )
583+ (map (fn [m] (str (get-in m [:author :username ]) " : " (:content m))))
584+ (remove string/blank?))]
585+ (string/join " \n " (cond->> lines
586+ (not (string/blank? topic)) (cons (str " [thread topic] " topic)))))))
584587 (catch Exception e (debug " thread-context failed:" (.getMessage e)) " " )))
585588
586589; ; ---------------------------------------------------------------------------
Original file line number Diff line number Diff line change 184184 (fact " keeps the original request text"
185185 (agent/resume-request " add a bagif command" ) => (contains " add a bagif command" )))
186186
187+ (facts " about thread-context"
188+ (fact " returns empty string if the channel is not a thread (type is not 10, 11, or 12)"
189+ (#'agent/thread-context " channel-id-123" ) => " "
190+ (provided
191+ (#'agent/rest-conn ) => " mock-conn"
192+ (discljord.messaging/get-channel! " mock-conn" " channel-id-123" ) => (atom {:type 0 :name " general" })))
193+
194+ (fact " returns thread context if the channel is a thread (type 11)"
195+ (#'agent/thread-context " thread-id-456" ) => " [thread topic] cool-thread\n alice: hello\n bob: world"
196+ (provided
197+ (#'agent/rest-conn ) => " mock-conn"
198+ (discljord.messaging/get-channel! " mock-conn" " thread-id-456" ) => (atom {:type 11 :name " cool-thread" })
199+ (#'agent/all-channel-messages " thread-id-456" ) => [{:author {:username " alice" } :content " hello" :timestamp 1 }
200+ {:author {:username " bob" } :content " world" :timestamp 2 }])))
201+
187202(facts " about agent subcommands"
188203 (fact " agent-list-commands-cmd returns available commands in JSON"
189204 (agent/agent-list-commands-cmd {}) => {:result/value " {\" commands\" :[\" cmd1\" ,\" cmd2\" ]}" }
You can’t perform that action at this time.
0 commit comments