Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php -q
- <?php
- $canal = "CANAL O CHATID";
- $token = "EL TOKEN DEL BOT";
- @$cmd = $argv[1];
- @$arg = $argv[2];
- if($cmd == 'start') $msg = "inicio de fail2ban";
- elseif($cmd == 'stop') $msg = "fin de fail2ban";
- elseif($cmd == 'ban') $msg = "nuevo ip <strong>bloqueado</strong> ".$arg;
- elseif($cmd == 'unban') $msg = "nuevo ip desbloqueado ".$arg;
- if(!empty($msg)) chat($msg);
- /* chat(para, mensaje) {{{ */
- function chat($m) {
- global $token, $canal;
- $datos = [ "text" => $m, "chat_id" => $canal, 'parse_mode'=>'html'];
- if(empty($m)) { echo "intenta enviar un mensaje vacio\n"; return; }
- $metodo = "POST"; //cambiar a "POST" en caso de que sea post
- $url = "https://api.telegram.org/bot".$token."/sendMessage";
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($datos));
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- $tmp = curl_exec($ch);
- $k = json_decode($tmp);
- curl_close($ch);
- }
- /* }}} */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement