<commit_before>"use strict";

var WhatsAppService = function($rootScope, $q) {
  var self = this;
  var whatsapi = require('whatsapi');

  return {
    createAdapter: function(argument) {
      self.wa = whatsapi.createAdapter(argument);
    },

    login: function(logged) {
      // logged is callback function
      if (logged === undefined) {
        logged = function (err) {
          if (err) {
            console.error(err);
            return;
          }
        }
      }

      self.wa.connect(function(err) {
        if (err) {
          console.error(err);
          return;
        }

        self.wa.login(logged);
      })
    },

    requestGroupsList: function() {
      wa.requestGroupsList(function(err, groups) {
        if (err) {
          console.error(err);
          return;
        }
      })
    },

    requestLastSeen: function(to, func) {
      if (func === undefined) {
        func = function(err, lastSeen) {
          if (err && err.code == 405) {
            console.log('The user has denied last seen time');
            return;
          }
          console.log(lastSeen.date);
        }
      }

      self.wa.requestLastSeen(to, func);
    },

    isLoggedIn: function() {
      console.log(self.wa);
      return self.wa;<commit_msg>updated whatsapp-service.js<commit_after>"use strict";

var WhatsAppService = function($rootScope, $q) {
  var whatsapi = require('whatsapi');

  return {
    createAdapter: function(argument) {
      var self = this;
      self.wa = whatsapi.createAdapter(argument);
      console.log("createAdapter: ", self.wa);
    },

    login: function(logged) {
      var self = this;

      // logged is callback function
      if (logged === undefined) {
        logged = function (err) {
          if (err) {
            console.error(err);
            return;
          }
          console.log("Logged in to WA server");
          self.wa.sendIsOnline();
        }
      }

      self.wa.connect(function(err) {
        if (err) {
          console.error(err);
          return;
        }

        self.wa.login(logged);
      });
      console.log("login");
    },

    requestGroupsList: function() {
      var self = this;

      console.log("requestGroupsList");
      self.wa.requestGroupsList(function(err, groups) {
        console.log(groups);
        if (err) {
          console.error(err);
          return;
        }

      })
    },

    requestLastSeen: function(to, func) {
      var self = this;

      if (func === undefined) {
        func = function(err, lastSeen) {
          if (err && err.code == 405) {
            console.log('The user has denied last seen time');
            return;
          }
          console.log(lastSeen.date);
        }
      }

      self.wa.requestLastSeen(to, func);
      console.log("requestLastSeen");
    },

    isLoggedIn: function() {
      var self = this;

      console.log(self.wa);
      return self.wa;
{'fraction_non_alphanumeric': 0.13138189244383935, 'fraction_numerical': 0.0020422055820285907, 'mean_word_length': 1.7162661737523106, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5700925', 'n_tokens_mistral': 902, 'n_tokens_neox': 867, 'n_words': 176}