Exemplo n.º 1
0
<?php

require_once 'Telegram.php';
$Token = "112487:AAHt7GekYvSR_dEMKAfyjxAOjgX7u87lACo";
$WebHook = "https://www.****.com/test/WebHook.php";
$Web = new TelegramBot($Token);
if (php_sapi_name() == 'cli') {
    $Web->Request('setWebhook', array('url' => isset($argv[1]) && $argv[1] == 'delete' ? '' : $WebHook));
    exit;
}
$Data = file_get_contents("php://input");
$Web->Run($Data);
Exemplo n.º 2
0
}
function isSecure()
{
    return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443;
}
$setHook = true;
$deleteWebhook = isset($_GET['delete']);
if (!isSecure()) {
    _log("You need to use a secure conection to set a webhook \n\n");
    $setHook = false;
} else {
    _log("This connection is secure \n\n");
}
if (file_exists($ssl_cert_location)) {
    _log("Certificate found \n\n");
} else {
    _log("Certificate NOT found \n\n");
    $setHook = false;
}
if ($setHook || $deleteWebhook) {
    $telegram = new TelegramBot(BOT_AUTH_TOKEN);
    if (!$deleteWebhook) {
        $url = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        $url = substr($url, 0, strrpos($url, "/") + 1) . "bot.php";
    } else {
        $url = '';
        $ssl_cert_location = null;
    }
    _log("Setting webhook address to: " . $url);
    _log($telegram->setWebhook($url, $ssl_cert_location));
}
Exemplo n.º 3
0
 public function __construct($token, ConnectionModel $db_connect)
 {
     parent::__construct($token);
     $this->moneyTracker = new MoneyTracker($db_connect);
 }
 public function init()
 {
     parent::init();
 }
Exemplo n.º 5
0
 public function init()
 {
     parent::init();
     $this->dbInit();
 }
Exemplo n.º 6
0
<?

$start=time();

// Connect to database
require('TelegramDBConnect.php');
$db=connectDB();


// Create new Bot Object
require('TelegramBotClass.php');
require('TelegramBotConfig.php');
$bot = new TelegramBot($tokenAPI);


// Message & chatId from web-site
$wsMessage=$_POST['wsMessage'];


if($_COOKIE['wsChatHash']!=null){
		$wsChatHash=$_COOKIE['wsChatHash'];
		$sth=$db->prepare("SELECT wsChatId FROM wsChat WHERE wsChatHash=:wsChatHash");
		$sth->execute(array(":wsChatHash"=>$wsChatHash));
		$a=$sth->fetch();
		$wsChatId=$a['wsChatId'];
}else{
		$sth=$db->prepare("SELECT MAX(wsChatId) as max FROM wsChat");
		$sth->execute();
		$a=$sth->fetch();
		$wsChatId=intval($a['max'])+1;
		$wsChatHash=uniqid();
Exemplo n.º 7
0
<?
set_time_limit(0);
error_reporting(E_ALL); //Выводим все ошибки и предупреждения
set_time_limit(0);	//Время выполнения скрипта не ограничено
ob_implicit_flush();	//Включаем вывод без буферизации 
ignore_user_abort(true); // Игнорируем закрытие окна браузера с сервером


// Connect to database
require('TelegramDBConnect.php');
$db=connectDB();

// Create new Bot Object
require('TelegramBotClass.php');
require('TelegramBotConfig.php');
$bot = new TelegramBot($tokenAPI);

$f=fopen("running",'w');
$fl=flock($f, LOCK_EX | LOCK_NB);

if($fl){
//	print("I`m the only running process...<hr>");
	
	

		while(true){
		// Get lastUpdate ID

		$sth=$db->prepare("SELECT lastUpdate FROM lastUpdate");
		$sth->execute();
		$a=$sth->fetch();