Skip to content

Commit

Permalink
primer commit para llevarlo a linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Orlando Sanhchez committed Nov 14, 2021
0 parents commit 38449b9
Show file tree
Hide file tree
Showing 107 changed files with 78,792 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vagrant
/.discovery
Homestead.json
Homestead.yaml
npm-debug.log
.env
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<p align="center"><img height="188" width="198" src="https://botman.io/img/botman.png"></p>
<h1 align="center">BotMan Studio</h1>

## About BotMan Studio

While BotMan itself is framework agnostic, BotMan is also available as a bundle with the great [Laravel](https://laravel.com) PHP framework. This bundled version is called BotMan Studio and makes your chatbot development experience even better. By providing testing tools, an out of the box web driver implementation and additional tools like an enhanced CLI with driver installation, class generation and configuration support, it speeds up the development significantly.

## Documentation

You can find the BotMan and BotMan Studio documentation at [http://botman.io](http://botman.io).

## Support the development
**Do you like this project? Support it by donating**

- PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=m%2epociot%40googlemail%2ecom&lc=CY&item_name=BotMan&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest)
- Patreon: [Donate](https://www.patreon.com/botman)

## Security Vulnerabilities

If you discover a security vulnerability within BotMan or BotMan Studio, please send an e-mail to Marcel Pociot at [email protected]. All security vulnerabilities will be promptly addressed.

## License

BotMan is free software distributed under the terms of the MIT license.

42 changes: 42 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
45 changes: 45 additions & 0 deletions app/Conversations/ExampleConversation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace App\Conversations;

use Illuminate\Foundation\Inspiring;
use BotMan\BotMan\Messages\Incoming\Answer;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
use BotMan\BotMan\Messages\Conversations\Conversation;

class ExampleConversation extends Conversation
{
/**
* First question
*/
public function askReason()
{
$question = Question::create("Huh - you woke me up. What do you need?")
->fallback('Unable to ask question')
->callbackId('ask_reason')
->addButtons([
Button::create('Tell a joke')->value('joke'),
Button::create('Give me a fancy quote')->value('quote'),
]);

return $this->ask($question, function (Answer $answer) {
if ($answer->isInteractiveMessageReply()) {
if ($answer->getValue() === 'joke') {
$joke = json_decode(file_get_contents('http://api.icndb.com/jokes/random'));
$this->say($joke->value->joke);
} else {
$this->say(Inspiring::quote());
}
}
});
}

/**
* Start the conversation
*/
public function run()
{
$this->askReason();
}
}
55 changes: 55 additions & 0 deletions app/Conversations/beginConversation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace App\Conversations;

use App\articulo;
use App\empresa;
use Illuminate\Support\Facades\DB;
use Illuminate\Foundation\Inspiring;
use BotMan\BotMan\Messages\Incoming\Answer;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
use BotMan\BotMan\Messages\Conversations\Conversation;


class beginConversation extends Conversation
{
/**
* Start the conversation.
*
* @return mixed
*/
protected $params;

public function __construct($params) {
$this->params = $params;
}


public function run()
{

//$empresas = empresa::where('producto', 'ADMI')->get();

// $question = Question::create("Selecciona la empresa a consultar:");

//foreach($empresas as $empresa){

// $question->addButtons([
// Button::create("desc_empresa")->value("AXN000183")
//]);

//}

$this->params['cod_empresa'] = "AXN000183";

$this->bot->startConversation(new inventarioConversation($this->params));

// $this->ask($question, function($answer){
// $this->params['cod_empresa'] = "AXN000183";

// $this->bot->startConversation(new inventarioConversation($this->params));

// });
}
}
168 changes: 168 additions & 0 deletions app/Conversations/inventarioConversation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?php

namespace App\Conversations;


use App\articulo;
use App\empresa;
use Illuminate\Support\Facades\DB;
use Illuminate\Foundation\Inspiring;
use BotMan\BotMan\Messages\Incoming\Answer;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
use BotMan\BotMan\Messages\Conversations\Conversation;



class inventarioConversation extends Conversation
{

/**
* Start the conversation
*/
protected $params;
protected $count = 0;

public function __construct($params) {
$this->params = $params;
}


public function run()
{
config()->set('database.connections.sqlsrv.database', $this->params['cod_empresa']);
switch($this->params['solicitud']) {
case 'articulos':
$this->params['articulos'] = articulo::where('tipo', '!=', 'S')->get();
$this->mostrarStock();
break;
case 'inventario':
$this->mostrarInventario();
break;
}


}


public function mostrarStock(){

// $articulos = articulo::where('tipo', '!=', 'S')->get();
$question = Question::create("Selecciona el articulo a consultar");

foreach($this->params['articulos'] as $articulo){

$question->addButtons([
Button::create($articulo['art_des'])->value($articulo['co_art'])
]);

}

$this->ask($question, function($answer) {

config()->set('database.connections.sqlsrv.database', $this->params['cod_empresa']);
// $this->say(DB::connection()->getDatabaseName());
$cantidad = DB::table('dbo.v_saStockActual')->where([
['co_art', $answer->getText()],
['tipo', 'act']
])
->get();
if(count($cantidad) > 0){
$this->say(strval($cantidad[0]->stock));
}else{
$this->say('no tiene');
}
$question = Question::create("Quieres consultar otro articulo?")
->fallback('No es posible en estos momentos')
->addButtons([
Button::create('Si')->value('si'),
Button::create('No')->value('no'),
]);

$this->ask($question, function($answer){
if($answer->isInteractiveMessageReply()){
//$this->count = 0;
if($answer->getValue() == 'si'){
$this->mostrarStock();
}else{
return $this->say('Ok, estaré acá si me necesitas.');
}
}else{
$this->count++;
if($this->count >=4){
$this->say('Bueno cabron que parte de que uses los botones no entiendes ');
}elseif($this->count > 2 && $this->count < 4){
$this->say('Me estas haciendo molestar! Por favor usa los botones! acaso no los ves? 👇');
}else{
$this->say('Debes contestar usando los botones. 👇');
}
$this->repeat();
}
});
});

}

protected function mostrarInventario(){
config()->set('database.connections.sqlsrv.database', $this->params['cod_empresa']);
//$this->say('estamos probando');
try{
$inventario = DB::select('SET NOCOUNT ON; exec [dbo].[RepStockArticulos]');
}catch (Throwable $e){
$inventario = $e;
}
//$this->say('estamos probando');


$this->say($this->generarInventario($inventario), ['parse_mode' => 'Markdown']);

$this->say('Estaré acá si necesitas algo.');


}


public function generarInventario($inventario){
$resultado = "*Inventario al: " . date("j F, Y, g:i a") ."*\n\n";
foreach($inventario as $key => $item){
if($item->StockActual == 0 ){
continue;
}
if($key > 50){
break;
}
$resultado .= sprintf("%.35s", ucfirst(strtolower($item->art_des))) . "\nCant: " .
"*".sprintf("%01.2f", $item->StockActual) . " " . $item->des_uni . "*\n\n";
}

//$resultado += $inventario[0]->art_des;

return $resultado;

}

public function seleccionarArticulo(){


$keyboard = [
['300 €', '400 €', '450 €'],
['500 €', '600 €', '700 €'],
['800 €', '900 €', '1000 €'],
['1200 €', '1400 €', '2000 €'],
['2500 €', '3000 €', 'any'],
];

$this->ask('How much?',
function (Answer $answer) {
//$this->askAdress();
}, ['reply_markup' => json_encode([
'keyboard' => $keyboard,
'one_time_keyboard' => true,
'resize_keyboard' => true
])]
);

}


}
38 changes: 38 additions & 0 deletions app/Conversations/menu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Conversations;

use BotMan\BotMan\Messages\Conversations\Conversation;
use BotMan\BotMan\Messages\Attachments\Contact;

use BotMan\Drivers\Telegram\Extensions\Keyboard;
use BotMan\Drivers\Telegram\Extensions\KeyboardButton;

class menu extends Conversation
{
protected $phone;

public function teclado()
{
$this->ask('Selecciona un modulo 👇', function ($Answer) {
$this->say('Haz elegido ' . $Answer);
},
Keyboard::create()
->type(Keyboard::TYPE_KEYBOARD)
->oneTimeKeyboard(true)
->resizeKeyboard()
->addRow(KeyboardButton::create('Ventas')->callbackData('dijiste ventas'))
->toArray()
);
}

public function run()
{
// This will be called immediately
// $this->askPhone();
$this->teclado();
}



}
Loading

0 comments on commit 38449b9

Please sign in to comment.