module BotOptions
Constants
- FALSE_VALUES
- PLUGIN
- TRUE_VALUES
Public Instance Methods
Source
# File lib/bot_options.rb, line 31 def boolean(network:, channel:, key:, default: false) value = get(network: network, channel: channel, key: key) return default if value.nil? || value.to_s.strip.empty? normalized = value.to_s.strip.downcase return true if TRUE_VALUES.include?(normalized) return false if FALSE_VALUES.include?(normalized) default end
Source
# File lib/bot_options.rb, line 17 def get(network:, channel:, key:, default: nil) value = RabbotDb.get_plugin_value(plugin: PLUGIN, key: key, network: network, channel: channel) value.nil? ? default : value end
Source
# File lib/bot_options.rb, line 42 def integer(network:, channel:, key:, default:) value = get(network: network, channel: channel, key: key) return default if value.nil? || value.to_s.strip.empty? Integer(value) rescue ArgumentError, TypeError default end
Source
# File lib/bot_options.rb, line 22 def set(network:, channel:, key:, value:) RabbotDb.set_plugin_value(plugin: PLUGIN, key: key, value: value, network: network, channel: channel) value end
Source
# File lib/bot_options.rb, line 27 def unset(network:, channel:, key:) RabbotDb.set_plugin_value(plugin: PLUGIN, key: key, value: "", network: network, channel: channel) end