Skip to content

scripts/relay: make format configurable by user #68

Description

@sariyamelody

The current output is hard-coded into scripts/relay.rb, which I find sub-optimal or multiple use-cases where I want a non-standard output format. I would like to suggest a configurable output.

The current code to generate output is as follows:

  def generate_raw type, dest, network, channel, nick, text = '', misc = ''                                                                                                                                                      
    prefix = message_prefix network, channel                                                                                                                                                                                     
    case type                                                                                                                                                                                                                    
    when :message                                                                                                                                                                                                                
      "PRIVMSG #{dest} :#{prefix} <\02#{nick}\02> #{text}"                                                                                                                                                                       
    when :action                                                                                                                                                                                                                 
      "PRIVMSG #{dest} :#{prefix} * \02#{nick}\02 #{text}"                                                                                                                                                                       
    when :join                                                                                                                                                                                                                   
      "PRIVMSG #{dest} :#{prefix} --> \02#{nick}\02 has joined \02#{channel}\02"                                                                                                                                                 
    when :part                                                                                                                                                                                                                   
      "PRIVMSG #{dest} :#{prefix} <-- \02#{nick}\02 has left \02#{channel}\02"                                                                                                                                                   
    when :kick                                                                                                                                                                                                                   
      "PRIVMSG #{dest} :#{prefix} <-- \02#{misc}\02 has has been kicked from \02#{channel}\02 by \02#{nick}\02 (#{text})"                                                                                                        
    when :quit                                                                                                                                                                                                                   
      "PRIVMSG #{dest} :#{prefix} <-- \02#{nick}\02 has quit (#{text})"                                                                                                                                                          
    end                                                                                                                                                                                                                          
  end  

A simple format specifier to replace this would be a wonderful addition. Of course, the current formats would be kept as defaults.

An example config block for relay.rb post-change is as follows. Compatibility with the current show_prefix option MUST be maintained at the current time.

relay = {                                                                                                                                                                                                                        
prefix_format  = "[&network&:&channel&]"                                                                                                                                                                                         
message_format = "&prefix& \x02<&nick&>\x02 &message&"                                                                                                                                                                           
action_format  =  "&prefix& * \x02&nick&\x02 &message&"                                                                                                                                                                          
join_format    =  "&prefix& --> \x02&nick&\x02 has joined \x02&channel&\x02"                                                                                                                                                     
part_format    =   "&prefix& <-- \x02&nick&\x02 has parted \x02&channel&\x02"                                                                                                                                                    
kick_format    =   "&prefix& <-- \x02&kicked&\x02 has been kicked from \x02&channel&\x02 by \x02&kicker&\x02"                                                                                                                    
quit_format    = "&prefix& <-- \x02&nick&\x02 has quit (&quit_text&)"                                                                                                                                                            
}            

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions