Sam a028309cbd
FEATURE: add ai_bot_enabled_chat commands and tune search (#94)
* FEATURE: add ai_bot_enabled_chat commands and tune search

This allows admins to disable/enable GPT command integrations.

Also hones search results which were looping cause the result did not denote
the failure properly (it lost context)

* include more context for google command
include more context for time command

* type
2023-06-21 17:10:30 +10:00

52 lines
953 B
Ruby

#frozen_string_literal: true
module DiscourseAi::AiBot::Commands
class TimeCommand < Command
class << self
def name
"time"
end
def desc
"Will generate the time in a timezone"
end
def parameters
[
Parameter.new(
name: "timezone",
description: "ALWAYS supply a Ruby compatible timezone",
type: "string",
required: true,
),
]
end
end
def result_name
"time"
end
def description_args
{ timezone: @last_timezone, time: @last_time }
end
def process(args)
timezone = JSON.parse(args)["timezone"]
time =
begin
Time.now.in_time_zone(timezone)
rescue StandardError
nil
end
time = Time.now if !time
@last_timezone = timezone
@last_time = time.to_s
{ args: args, time: time.to_s }
end
end
end