Skip to content

Commit

Permalink
Merge pull request #4 from jaavid/Summer
Browse files Browse the repository at this point in the history
Summer
  • Loading branch information
Javid authored Jul 14, 2017
2 parents 7e2965a + 0a1d231 commit 4d8cdf5
Show file tree
Hide file tree
Showing 13 changed files with 484 additions and 256 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
*~
vendor
composer.lock
config.php
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Telegram Bot for jadi.net. This is a single purpose program which lets you interact with [www.Jadi.net](http://jadi.net) using Telegram messenger; although you can modify it to use other weblogs or even sites.

### Usage
If you want to use JadiBot, just head to [http://www.telegram.me/jadibot](http://www.telegram.me/jadibot) and add the bot. As any other bot you have to start with ````/start```` command and use ````/help```` to see the list of commands.
If you want to use JadiBot, just head to [https://t.me/jadibot](https://t.me/jadibot) and add the bot. As any other bot you have to start with ````/start```` command and use ````/help```` to see the list of commands.

These commands are available:

Expand Down
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"require": {
"zelenin/telegram-bot-api": "~0.0",
"joshcam/mysqli-database-class": "dev-master",
"dg/rss-php": "^1.2"
"longman/telegram-bot": "^0.45.0"
}
}
25 changes: 13 additions & 12 deletions config.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php
//Robat Token Give from @botfather
$token = "";
//Group Id To forward Message to group
$agroup = "";
//Database Configuration
$dbconf = array (
'host' => '',
'username' => '',
'password' => '',
'db' => '',
'port' => 3306,
'charset' => 'utf8');
// Add you bot's API key and name
$bot_api_key = '';
$bot_username = '';
$botan = '';
// Define all IDs of admin users in this array (leave as empty array if not used)
$admin_users = [208627,];

// Enter your MySQL database credentials
$mysql_credentials = [
'host' => 'localhost',
'user' => '',
'password' => '',
'database' => '',
];
?>
16 changes: 16 additions & 0 deletions config.php.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
// Add you bot's API key and name
$bot_api_key = '';
$bot_username = '';
$botan = '';
// Define all IDs of admin users in this array (leave as empty array if not used)
$admin_users = [208627,];

// Enter your MySQL database credentials
$mysql_credentials = [
'host' => 'localhost',
'user' => '',
'password' => '',
'database' => '',
];
?>
59 changes: 59 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

// Load composer
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/config.php';

// Define all paths for your custom commands in this array (leave as empty array if not used)
$commands_paths = [
__DIR__ . '/jcommands/',
];

try {
// Create Telegram API object
$telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username);

// Add commands paths containing your custom commands
$telegram->addCommandsPaths($commands_paths);

// Enable admin users
$telegram->enableAdmins($admin_users);

// Enable MySQL
$telegram->enableMySql($mysql_credentials);

// Logging (Error, Debug and Raw Updates)
//Longman\TelegramBot\TelegramLog::initErrorLog(__DIR__ . "/{$bot_username}_error.log");
//Longman\TelegramBot\TelegramLog::initDebugLog(__DIR__ . "/{$bot_username}_debug.log");
//Longman\TelegramBot\TelegramLog::initUpdateLog(__DIR__ . "/{$bot_username}_update.log");

// If you are using a custom Monolog instance for logging, use this instead of the above
//Longman\TelegramBot\TelegramLog::initialize($your_external_monolog_instance);

// Set custom Upload and Download paths
//$telegram->setDownloadPath(__DIR__ . '/Download');
//$telegram->setUploadPath(__DIR__ . '/Upload');

// Here you can set some command specific parameters
// e.g. Google geocode/timezone api key for /date command
//$telegram->setCommandConfig('date', ['google_api_key' => 'your_google_api_key_here']);

// Botan.io integration
$telegram->enableBotan($botan);

// Requests Limiter (tries to prevent reaching Telegram API limits)
$telegram->enableLimiter();

// Handle telegram webhook request
$telegram->handle();

} catch (Longman\TelegramBot\Exception\TelegramException $e) {
// Silence is golden!
//echo $e;
// Log telegram errors
Longman\TelegramBot\TelegramLog::error($e);
} catch (Longman\TelegramBot\Exception\TelegramLogException $e) {
// Silence is golden!
// Uncomment this to catch log initialisation errors
//echo $e;
}
240 changes: 0 additions & 240 deletions index.php

This file was deleted.

Loading

0 comments on commit 4d8cdf5

Please sign in to comment.