package TriviaHints;
use strict;

# a ZNC module to parse hints given by trivia bots and add useful info
# (swallowing the original message and replacing it)

sub new {
    my ( $classname ) = @_;
    my $self = {};
    bless( $self, $classname );
    return( $self );
}



sub OnChanMsg {
    my ( $self, $nick, $chan, $msg ) = @_;
    
    if ($msg =~ /Hint: ((?:[@*]\s)+)/) {
        my @letters;
    
        my @words = split / /, $1;
        for my $word (@words) {
            push @letters, length($word);
        }
    
        my $msg = "Hint is: $1 (Letters: " . join(',', @letters) . ')';
        # now send a raw line to the client to replace the hint...
        ZNC::PutUser(":$nick PRIVMSG $chan :$msg");
        # and indicate that the line should be swallowed (otherwise the client
        # would get our "faked" message *and* the real message):
        return ( ZNC::HALTCORE );

    } else {
        # indicate that we don't want to swallow the message (I think)
        return( ZNC::CONTINUE );
    }
}


1;
