module SingaiContext
Constants
- MAX_FANDOM_PROFILES
- MAX_LINE_CHARS
Public Instance Methods
Source
# File lib/singai_context.rb, line 18 def build_channel_lines(network:, channel:, store: RabbotDb) AiChannelLog.entries(network: network, channel: channel, store: store).map do |entry| format_channel_line(entry) end end
Source
# File lib/singai_context.rb, line 38 def build_fandom_lines(profiles:) Array(profiles).first(MAX_FANDOM_PROFILES).filter_map do |profile| next unless profile name = profile.name.to_s.strip summary = profile.summary.to_s.strip next if name.empty? line = name.dup line << " — #{summary}" unless summary.empty? line end end
Source
# File lib/singai_context.rb, line 52 def discover_profiles(channel_users:, bot_nicks:, bots_dir:, root:) FandomTriviaSources.discover_profiles( channel_users: channel_users, bot_nicks: bot_nicks, bots_dir: bots_dir, root: root ) end
Source
# File lib/singai_context.rb, line 24 def format_channel_line(entry) nick = (entry[:nick] || entry["nick"]).to_s text = AiChannelLog.plain_log_text((entry[:text] || entry["text"]).to_s) text = truncate_line(text) "#{nick}: #{text}" end
Source
# File lib/singai_context.rb, line 31 def truncate_line(text) line = text.to_s.strip return line if line.length <= MAX_LINE_CHARS "#{line[0, MAX_LINE_CHARS - 3]}..." end