class FlipTime
Help: store or show upside-down clock flip meanings — !time <HH:MM> [abbrev meaning…] — responders: all_loaded
Public Class Methods
Source
# File plugins/flip_time.rb, line 18 def self.command_pattern /time(?:\s+(.+))?$/i end
Source
# File plugins/flip_time.rb, line 55 def self.format_add(entry:, time_label:) ClockReport.format_flip_entry( time_label: time_label, flip_word: entry["flip_word"], lines: entry["lines"], source: "manual", title_suffix: "saved" ) end
Source
# File plugins/flip_time.rb, line 32 def self.format_show(entry:, time_label:, flip_word:, candidates: nil) footer = ["!time #{time_label} #{flip_word} …"] options = Array(candidates).map(&:to_s).reject(&:empty?).uniq footer << "valid: #{options.join(', ')}" if options.length > 1 if entry ClockReport.format_flip_entry( time_label: time_label, flip_word: entry["flip_word"], lines: entry["lines"], source: entry["source"] ) else IrcReply.card( tag: "TIME", title: "#{time_label} · flip #{flip_word}", body_lines: ["No meaning stored yet."], footer_parts: footer, heading_style: ClockReport::STYLE_TITLE ) end end
Source
# File plugins/flip_time.rb, line 28 def self.parse_command(args) ClockFlipCommand.parse_command(args) end
Source
# File plugins/flip_time.rb, line 24 def self.usage_message ClockFlipCommand.usage_message end
Public Instance Methods
Source
# File plugins/flip_time.rb, line 65 def execute(m, args = nil) return unless m.channel parsed = self.class.parse_command(args) if parsed[:action] == :error themed_flood_safe_reply(m, parsed[:error]) return end case parsed[:action] when :show entry = ClockFlipStore.load_entry(hour: parsed[:hour], minute: parsed[:minute]) candidates = ClockFlipStore.valid_flip_words(parsed[:hour], parsed[:minute]) flip_word = entry ? entry["flip_word"] : ClockFlipStore.expected_flip_word(parsed[:hour], parsed[:minute]) themed_flood_safe_reply( m, self.class.format_show( entry: entry, time_label: parsed[:time_label], flip_word: flip_word, candidates: candidates ) ) when :add result = ClockFlipStore.save_manual( hour: parsed[:hour], minute: parsed[:minute], abbrev: parsed[:abbrev], meaning: parsed[:meaning] ) if result[:error] themed_flood_safe_reply(m, result[:error]) return end themed_flood_safe_reply(m, self.class.format_add(entry: result[:entry], time_label: result[:time_label])) end end