module LolcatReport
LolcatReport — IRC replies for !lolcat command. Public: help, status, toggle_reply, options_reply, preview Depends: IrcFormat, IrcReply, LolcatRunner, AnsiToIrc Tests: test/plugins/lolcat_test.rb
Constants
- TAG
Public Instance Methods
Source
# File lib/lolcat_report.rb, line 87 def denial IrcReply.error(tag: TAG, message: "Admin required for !lolcat on|off|options.", heading_style: IrcFormat.named_style(:title)) end
Source
# File lib/lolcat_report.rb, line 18 def help IrcReply.card( tag: TAG, title: "lolcat rainbow", body_lines: [ "!lolcat on|off — channel rainbow toggle (admin)", "!lolcat options -p 8 -a — set lolcat flags (admin)", "!lolcat status — enabled + current flags", "!lolcat preview [text] — demo line", "Flags: -p spread -F freq -S seed -a animate -d duration -s speed -i invert -t truecolor" ], footer_parts: [LolcatRunner.available? ? "lolcat installed" : "lolcat missing", "pipe replies when on"], heading_style: IrcFormat.named_style(:title) ) end
Source
# File lib/lolcat_report.rb, line 57 def options_reply(argv:) IrcReply.card( tag: TAG, title: "options saved", body_lines: [argv.empty? ? "default (-f)" : argv.join(" ")], footer_parts: ["!lolcat preview"], heading_style: IrcFormat.named_style(:title) ) end
Source
# File lib/lolcat_report.rb, line 67 def preview(text:, argv:, runner: LolcatRunner, converter: AnsiToIrc) sample = text.to_s.strip.empty? ? "hello rainbow" : text.to_s.strip built = runner.build_argv(argv) lolcat_argv = built[:error] ? runner.default_argv : built[:argv] result = runner.run(sample, argv: lolcat_argv) body = if result[:error] "lolcat unavailable — #{result[:error]}" else converter.convert(result[:output].to_s.rstrip) end IrcReply.card( tag: TAG, title: "preview", body_lines: [body], footer_parts: [lolcat_argv.join(" ")], heading_style: IrcFormat.named_style(:title) ) end
Source
# File lib/lolcat_report.rb, line 34 def status(state:) enabled = state[:enabled] ? "on" : "off" argv = Array(state[:argv]) flag_line = argv.empty? ? "default" : argv.join(" ") IrcReply.card( tag: TAG, title: "status", body_lines: ["enabled: #{enabled}", "options: #{flag_line}"], footer_parts: ["!lolcat preview"], heading_style: IrcFormat.named_style(:title) ) end
Source
# File lib/lolcat_report.rb, line 47 def toggle_reply(enabled:) word = enabled ? "on" : "off" IrcReply.card( tag: TAG, title: "lolcat #{word}", body_lines: ["Channel replies will#{enabled ? "" : " not"} pass through lolcat."], heading_style: IrcFormat.named_style(:title) ) end