Skip to content

Instantly share code, notes, and snippets.

@chuv1
chuv1 / tgEntitiesToHTML.php
Last active November 18, 2023 09:37
Test function to convert telegram message entities into HTML markup.
public function getHTML($without_cmd = false){
if(empty($this->getEntities())){
return $this->getText($without_cmd);
}
$text = $this->getText();
$html = '';
$entities_count = \count($this->getEntities())-1;
@chuv1
chuv1 / tg-bots-watchdog.php
Created May 2, 2017 07:01
Watchdog. Will notify you if your bot is down.
<?php
$message = '';
$botoneHook = file_get_contents('https://api.telegram.org/bot___FIRST_BOT_API_KEY___/getWebhookInfo');
$bottwoHook = file_get_contents('https://api.telegram.org/bot___SECOND_BOT_API_KEY___/getWebhookInfo');
$botOne = !empty($botoneHook) && !empty(json_decode($botoneHook, true)) && !empty(json_decode($botoneHook, true)['result']['pending_update_count']) && json_decode($botoneHook, true)['result']['pending_update_count'] > 5?
json_decode($botoneHook, true)['result']:'ok';
$botTwo = !empty($bottwoHook) && !empty(json_decode($bottwoHook, true)) && !empty(json_decode($bottwoHook, true)['result']['pending_update_count']) && json_decode($bottwoHook, true)['result']['pending_update_count'] > 5?
json_decode($bottwoHook, true)['result']:'ok';
@chuv1
chuv1 / PoC.md
Last active May 1, 2017 22:26
Authorise you website users with Telegram bot.

Using https://github.com/php-telegram-bot

First.

Create some script that will issue tokens for users and will check if user logged in when asked.

auth.php

<?php

date_default_timezone_set('Asia/Bangkok');