79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/huginn_discord_agent/discord_agent.rb', line 79
def validate_options
errors.add(:base, "type has invalid value: should be 'send_message'") if interpolated['type'].present? && !%w(send_message).include?(interpolated['type'])
unless options['channel_id'].present? || !['send_message'].include?(options['type'])
errors.add(:base, "channel_id is a required field")
end
if options.has_key?('emit_events') && boolify(options['emit_events']).nil?
errors.add(:base, "if provided, emit_events must be true or false")
end
unless options['content'].present? || !['send_message'].include?(options['type'])
errors.add(:base, "content is a required field")
end
unless options['bot_token'].present? || !['send_message'].include?(options['type'])
errors.add(:base, "bot_token is a required field")
end
if options.has_key?('debug') && boolify(options['debug']).nil?
errors.add(:base, "if provided, debug must be true or false")
end
unless options['expected_receive_period_in_days'].present? && options['expected_receive_period_in_days'].to_i > 0
errors.add(:base, "Please provide 'expected_receive_period_in_days' to indicate how many days can pass before this Agent is considered to be not working")
end
end
|