<commit_before>import Behavior from '../behavior.js';
import Karma from './models/karma.js';

const USER_KARMA_REGEX = /^<@(\w+)>(\+\+|\-\-)(?:\s?#\s?((?:[\s\S])+))?/gi,
  USER_REGEX = /<@(\w+)>/gi;

class KarmaBehavior extends Behavior {
  constructor(settings) {
    settings.name = 'Karma';
    settings.description = 'Karma is fun, `++` or `--` people, places, or things!';
    super(settings);

    this.commands.push({
      tag: 'explain',
      description: 'Displays the karma for the provided users (e.g. `!karma @beatz-bot`)'
    });

    this.commands.push({
      tag: 'list',
      description: 'Displays the top or bottom 10 karma users (e.g. `!list top` or `!list bottom`'
    });
  }

  initialize(bot) {
    bot.on('message', messageData => {
      this.bot.users = undefined;
      if (messageData.text && messageData.text.match(USER_KARMA_REGEX)) {
        const [, userId, type, reason] = USER_KARMA_REGEX.exec(messageData.text),
          channel = messageData.channel;<commit_msg>Prevent karma manipulation in private<commit_after>import Behavior from '../behavior.js';
import Karma from './models/karma.js';

const USER_KARMA_REGEX = /^<@(\w+)>(\+\+|\-\-)(?:\s?#\s?((?:[\s\S])+))?/gi,
  USER_REGEX = /<@(\w+)>/gi;
const BEATZ_ID = 'D2HRBHJ7R';

class KarmaBehavior extends Behavior {
  constructor(settings) {
    settings.name = 'Karma';
    settings.description = 'Karma is fun, `++` or `--` people, places, or things!';
    super(settings);

    this.commands.push({
      tag: 'explain',
      description: 'Displays the karma for the provided users (e.g. `!karma @beatz-bot`)'
    });

    this.commands.push({
      tag: 'list',
      description: 'Displays the top or bottom 10 karma users (e.g. `!list top` or `!list bottom`'
    });
  }

  initialize(bot) {
    bot.on('message', messageData => {
      if (messageData.text && messageData.text.match(USER_KARMA_REGEX)) {
        const [, userId, type, reason] = USER_KARMA_REGEX.exec(messageData.text),
          channel = messageData.channel;

        if (channel === BEATZ_ID) {
          this.bot.postMessage(channel, `Tut tut, <@${messageData.user}>, if you're going to give or take karma, do it in public.`, {
            icon_emoji: ':patpat:'
          });
          return;
        }
{'fraction_non_alphanumeric': 0.1802990325417766, 'fraction_numerical': 0.002638522427440633, 'mean_word_length': 2.991228070175439, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, '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': '1527179', 'n_tokens_mistral': 820, 'n_tokens_neox': 785, 'n_words': 180}