Added MSG to function

This commit is contained in:
Frank Bischof 2023-04-12 16:40:50 +02:00
parent 3ae9610d25
commit cdc65698af
1 changed files with 8 additions and 8 deletions

View File

@ -2,7 +2,7 @@
/* /*
Author: info@meer-web.nl Author: info@meer-web.nl
Web: https://meer-web.nl Web: https://meer-web.nl
Version: 2.0.0 Version: 2.1.0
#URL to get the webhook info #URL to get the webhook info
https://api.telegram.org/bot<BOT_ID>/getWebhookInfo https://api.telegram.org/bot<BOT_ID>/getWebhookInfo
@ -23,8 +23,8 @@ $TELEGRAM_BOT='123456789:ABCDEFXXXXXXXXXXXXXXXXXXXXX';
/********************** Start script **********************/ /********************** Start script **********************/
// Telegram function which you can call // Telegram function which you can call
function telegram($METHOD) { function telegram($METHOD, $MSG) {
global $TELEGRAM_BOT, $TELEGRAM_CHATID, $MSG, $CAPTION; global $TELEGRAM_BOT, $TELEGRAM_CHATID, $CAPTION;
if ($METHOD == 'TXT') { if ($METHOD == 'TXT') {
$url='https://api.telegram.org/bot'.$TELEGRAM_BOT.'/sendMessage';$data=array('chat_id'=>$TELEGRAM_CHATID,'text'=>$MSG); $url='https://api.telegram.org/bot'.$TELEGRAM_BOT.'/sendMessage';$data=array('chat_id'=>$TELEGRAM_CHATID,'text'=>$MSG);
} }
@ -81,29 +81,29 @@ switch ($MESSAGE[0]) {
case '/ping': case '/ping':
// Friendly reply // Friendly reply
$MSG = "Hi $FIRSTNAME!"; $MSG = "Hi $FIRSTNAME!";
telegram('TXT'); telegram('TXT', "$MSG");
break; break;
case '/time': case '/time':
// Send current time // Send current time
$MSG = "The current time is " . date('d-m-Y H:i:s'); $MSG = "The current time is " . date('d-m-Y H:i:s');
telegram('TXT'); telegram('TXT', "$MSG");
break; break;
case '/chatid': case '/chatid':
// Show chatid // Show chatid
$MSG = "$TELEGRAM_CHATID"; $MSG = "$TELEGRAM_CHATID";
telegram('TXT'); telegram('TXT', "$MSG");
break; break;
case '/picture': case '/picture':
// Show an image with caption (or leave caption empty) // Show an image with caption (or leave caption empty)
$MSG = "https://www.creativefabrica.com/wp-content/uploads/2022/04/11/Turtle-Graphics-3812807.jpg"; $MSG = "https://www.creativefabrica.com/wp-content/uploads/2022/04/11/Turtle-Graphics-3812807.jpg";
$CAPTION = 'Here you have a little turtle'; $CAPTION = 'Here you have a little turtle';
telegram('IMG'); telegram('IMG', "$MSG");
break; break;
case '/gif': case '/gif':
// Show a gif with caption (or leave caption empty) // Show a gif with caption (or leave caption empty)
$MSG = "https://media2.giphy.com/media/LMVkZXubrWzcaZNq10/giphy.gif"; $MSG = "https://media2.giphy.com/media/LMVkZXubrWzcaZNq10/giphy.gif";
$CAPTION = 'Here you have a swimming turtle'; $CAPTION = 'Here you have a swimming turtle';
telegram('GIF'); telegram('GIF', "$MSG");
break; break;
} }
?> ?>