<commit_before>#include "messagebuilder.hpp"
#include "colorscheme.hpp"
#include "emotemanager.hpp"
#include "resources.hpp"

namespace chatterino {
namespace messages {

MessageBuilder::MessageBuilder()
    : _words()
{
    _parseTime = std::chrono::system_clock::now();
    regex.setPattern("\\bhttps?:\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[A-Z0-9+&@#\/%=~_|]");
    regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
}

SharedMessage MessageBuilder::build()
{
    return SharedMessage(new Message(this->originalMessage, _words));
}

void MessageBuilder::appendWord(const Word &word)
{
    _words.push_back(word);
}

void MessageBuilder::appendTimestamp()
{
    time_t t;
    time(&t);
    appendTimestamp(t);
}

void MessageBuilder::appendTimestamp(time_t time)
{
    char timeStampBuffer[69];

    // TODO(pajlada): Fix this
    QColor systemMessageColor(140, 127, 127);
    // QColor &systemMessageColor = ColorScheme::getInstance().SystemMessageColor;

    // Add word for timestamp with no seconds
    strftime(timeStampBuffer, 69, "%H:%M", localtime(&time));
    QString timestampNoSeconds(timeStampBuffer);
    appendWord(Word(timestampNoSeconds, Word::TimestampNoSeconds, systemMessageColor, QString(),
                    QString()));

    // Add word for timestamp with seconds
    strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&time));
    QString timestampWithSeconds(timeStampBuffer);
    appendWord(Word(timestampWithSeconds, Word::TimestampWithSeconds, systemMessageColor, QString(),
                    QString()));
}

QString MessageBuilder::matchLink(const QString &string)
{
    QRegularExpressionMatch match = regex.match(string);
    return match.captured();
}

}  // namespace messages<commit_msg>Added support for non http/https links. (#82)<commit_after>#include "messagebuilder.hpp"
#include "colorscheme.hpp"
#include "emotemanager.hpp"
#include "resources.hpp"

namespace chatterino {
namespace messages {

MessageBuilder::MessageBuilder()
    : _words()
{
    _parseTime = std::chrono::system_clock::now();
    regex.setPattern("(\\bhttps?:\/\/)?[-A-Z0-9+&@#\/%?=~_|!:,.;]*[A-Z0-9+&@#\/%=~_|]");
    regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
}

SharedMessage MessageBuilder::build()
{
    return SharedMessage(new Message(this->originalMessage, _words));
}

void MessageBuilder::appendWord(const Word &word)
{
    _words.push_back(word);
}

void MessageBuilder::appendTimestamp()
{
    time_t t;
    time(&t);
    appendTimestamp(t);
}

void MessageBuilder::appendTimestamp(time_t time)
{
    char timeStampBuffer[69];

    // TODO(pajlada): Fix this
    QColor systemMessageColor(140, 127, 127);
    // QColor &systemMessageColor = ColorScheme::getInstance().SystemMessageColor;

    // Add word for timestamp with no seconds
    strftime(timeStampBuffer, 69, "%H:%M", localtime(&time));
    QString timestampNoSeconds(timeStampBuffer);
    appendWord(Word(timestampNoSeconds, Word::TimestampNoSeconds, systemMessageColor, QString(),
                    QString()));

    // Add word for timestamp with seconds
    strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&time));
    QString timestampWithSeconds(timeStampBuffer);
    appendWord(Word(timestampWithSeconds, Word::TimestampWithSeconds, systemMessageColor, QString(),
                    QString()));
}

QString MessageBuilder::matchLink(const QString &string)
{
    QString match = regex.match(string,0,QRegularExpression::PartialPreferCompleteMatch,QRegularExpression::NoMatchOption).captured();
    if(!match.contains(QRegularExpression("\\bhttps?:\/\/"))){
        match.insert(0,"https://");
    }
    return match;
}

}  // namespace messages
{'fraction_non_alphanumeric': 0.14968758489540884, 'fraction_numerical': 0.011409942950285249, 'mean_word_length': 4.77115987460815, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7035702', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1109, 'n_words': 199}