Ejemplo n.º 1
0
 * Telegram Simple PHP Bot - A different and simple approach to use Telegram Bot Plataform (No SSL or setWebhook needed)
 * 
* @package telegram-simple_phpbot
* @author intrd - http://dann.com.br/
* @copyright 2016 intrd
* @license Creative Commons Attribution-ShareAlike 4.0 - http://creativecommons.org/licenses/by-sa/4.0/
* @link http://github.com/intrd/telegram-simple_phpbot/
* Version & Dependencies: See composer.json
*/
require __DIR__ . '/vendor/autoload.php';
use php\intrdCommons as i;
use telegram\simplePhpBot as b;
$conf = parse_ini_file("config.ini", false);
date_default_timezone_set($conf["timezone"]);
$conf["root"] = dirname(__FILE__) . "/";
i::check_dir(array($conf["root"] . "DATA/", $conf["root"] . "TMP/", $conf["root"] . "LOGS/"));
$conf["tmp_path"] = $conf["root"] . "TMP/";
$conf["data_path"] = $conf["root"] . "DATA/";
$conf["cookie_jar_file"] = $conf["tmp_path"] . $conf["cookie"];
$conf["replieds"] = $conf["data_path"] . $conf["replieds"];
/* Sample of a function that reply based on current week day when trigger_custom1 is mentioned, see trigger_custom1 at config.ini and custom1() at src/classes.php */
$weekday = date('D');
$trigger_custom1 = b::custom1($weekday);
$custom[$conf["trigger_custom1"]] = $trigger_custom1;
$offset = fopen($conf["replieds"], 'a') or die("Can't create file");
fclose($offset);
$offset = file($conf["replieds"]);
$offset = trim(array_pop($offset));
$updates = b::telegrambot_getUpdates($offset);
//get all chats opened w/ bot (channel mentions and pvts)
$last = json_decode($updates["content"], true);