<commit_before>/*

  Flooder
  Simple flood protection module

  CONFIG:

  flood: {
    interval: 1, // in seconds
    message: 'Flood message.' // message
  }
  
  NOTE: Received Telegram message time accuracy is one second!

*/

// Store users
var userList = {};

// Export bot module
module.exports = function(bot) {
  // Load config data
  var cfg = bot.cfg.flood || {};
  var interval = Number(cfg.interval) || 1;
  var text = cfg.message || 'Too many messages from you. Please, try later...';
  // Create message modifier
  bot.mod('message', function(msg) {
    var id = msg.from.id, user = userList[id];
    console.log(msg.date);
    var now = new Date(msg.date);
    if (user) {
      var diff = now - user.lastTime;
      user.lastTime = now;
      console.log(diff);
      if (diff <= interval) {
        if (!user.flood) {
          if (text) bot.sendMessage(id, text);
          user.flood = true;
        }
        msg = {};
      } else {
        user.flood = false;
      }
    } else {
      userList[id] = { lastTime: now };
    }<commit_msg>Remove console log<commit_after>/*

  Flooder
  Simple flood protection module

  CONFIG:

  flood: {
    interval: 1, // in seconds
    message: 'Flood message.' // message
  }
  
  NOTE: Received Telegram message time accuracy is one second!

*/

// Store users
var userList = {};

// Export bot module
module.exports = function(bot) {
  // Load config data
  var cfg = bot.cfg.flood || {};
  var interval = Number(cfg.interval) || 1;
  var text = cfg.message || 'Too many messages from you. Please, try later...';
  // Create message modifier
  bot.mod('message', function(msg) {
    var id = msg.from.id, user = userList[id];
    var now = new Date(msg.date);
    if (user) {
      var diff = now - user.lastTime;
      user.lastTime = now;
      if (diff <= interval) {
        if (!user.flood) {
          if (text) bot.sendMessage(id, text);
          user.flood = true;
        }
        msg = {};
      } else {
        user.flood = false;
      }
    } else {
      userList[id] = { lastTime: now };
    }
{'fraction_non_alphanumeric': 0.13818006740491093, 'fraction_numerical': 0.0019258545979778526, 'mean_word_length': 2.12012012012012, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '7615352', 'n_tokens_mistral': 685, 'n_tokens_neox': 663, 'n_words': 196}