Beispiel #1
0
 public function __construct($Debug = false)
 {
     $this->Debug = (bool) $Debug;
     Std::Out();
     Std::Out('[Info] [WhatsBot] Loading... Debug = ' . var_export($this->Debug, true));
     Config::Init();
     LoadLibs();
     $Config = Config::Get('WhatsBot');
     if (!empty($Config['WhatsApp']['Username']) && !empty($Config['WhatsApp']['Nickname']) && !empty($Config['WhatsApp']['Password'])) {
         $this->Password = $Config['WhatsApp']['Password'];
         # WhatsApp
         Std::Out();
         Std::Out("[Info] [WhatsBot] I'm {$Config['WhatsApp']['Nickname']} ({$Config['WhatsApp']['Username']})");
         $this->WhatsProt = new WhatsProt($Config['WhatsApp']['Username'], $Config['WhatsApp']['Nickname'], $this->Debug);
         $this->WhatsApp = new WhatsApp($this->WhatsProt);
         # WhatsBot
         $this->ModuleManager = new ModuleManager($this, $this->WhatsApp);
         $this->ThreadManager = new ThreadManager($this, $this->WhatsProt, $this->ModuleManager);
         $this->Parser = new WhatsBotParser($this->WhatsApp, $this->ModuleManager);
         # Load
         $this->ModuleManager->LoadModules();
         $this->ThreadManager->LoadThreads();
         # Binding
         $this->WhatsApp->EventManager()->LoadListeners($this, $this->WhatsApp, $this->Parser, $this->ModuleManager, $this->ThreadManager, array('Connection', 'WhatsBot', 'Storage'));
     } else {
         throw new Exception('You have to setup the config file config/WhatsBot.json');
     }
 }
 public function SetEncryption()
 {
     $this->iv = mcrypt_create_iv(mcrypt_get_iv_size(self::ENCRYPTION_TYPE, self::ENCRYPTION_MODE), MCRYPT_DEV_URANDOM);
     $this->encryptionKey = strrev(Config::Init($this->app)->Get(\Puzzlout\Framework\Enums\AppSettingKeys::EncryptionKey));
     $this->hashSalt = strrev(Config::Init($this->app)->Get(\Puzzlout\Framework\Enums\AppSettingKeys::PasswordSalt));
     return $this;
 }
Beispiel #3
0
 /**
  * Bootstraps UGS...
  * > Instantiates configs class
  * > Automatically includes ALL of the PHP classes in these directories: "classes" and "viewmodels".
  * This is a naive approach, see not about including base classes first.
  *
  * @private
  */
 private function Bootstrap()
 {
     // let's get Config setup
     $appRoot = dirname(__FILE__);
     include_once $appRoot . '/Config.php';
     // some dependencies: make sure base classes are included first...
     include_once $appRoot . '/classes/SiteUser.php';
     include_once $appRoot . '/viewmodels/_base_Vm.php';
     include_once $appRoot . '/builders/_base_Vmb.php';
     Config::Init();
     foreach (array('classes', 'viewmodels', 'builders') as $directory) {
         foreach (glob($appRoot . '/' . $directory . '/*.php') as $filename) {
             include_once $filename;
         }
     }
 }