add escape
authorAlan <alan@roojs.com>
Wed, 28 Jun 2023 09:06:37 +0000 (17:06 +0800)
committerAlan <alan@roojs.com>
Wed, 28 Jun 2023 09:06:37 +0000 (17:06 +0800)
Net/Telegram.php
Net/Telegram/SendMessage.php

index dc16fc8..409c4eb 100644 (file)
@@ -27,4 +27,16 @@ class Net_Telegram {
         return self::$tokens[$this->id];
     }
     
+    function escape($text)
+    {
+        return str_replace(array(
+                 '\\', '_', '*', '[', ']', '(', ')', '~', '`',  '>',
+                '<', '&', '#', '+', '-', '=', '|', '{', '}', '.', '!'
+                ), array(
+                    '\\\\', '\\_', '\\*', '\\[', '\\]', '\\(', '\\)', '\\~', '\\`',  '\\>',
+                    '\\<', '\\&', '\\#', '\\+', '\\-', '\\=', '\\|', '\\{', '\\}', '\\.', '\\!'
+                ),
+                $text);
+    }
+            
 }
index 54fffa3..b94d914 100644 (file)
@@ -16,25 +16,7 @@ class Net_Telegram_SendMessage extends Net_Telegram_Call {
         
     );
     
-     function __construct($tg, $o=false)
-    {
-        
-        
-        parent::__construct($tg, $o);
-        if (!empty($this->text)) {
-            $this->text = str_replace(array(
-                 '\\', '_', '*', '[', ']', '(', ')', '~', '`',  '>',
-                '<', '&', '#', '+', '-', '=', '|', '{', '}', '.', '!'
-                ), array(
-                    '\\\\', '\\_', '\\*', '\\[', '\\]', '\\(', '\\)', '\\~', '\\`',  '\\>',
-                    '\\<', '\\&', '\\#', '\\+', '\\-', '\\=', '\\|', '\\{', '\\}', '\\.', '\\!'
-                ),
-                $this->text);
-            
-            
-        }
-        
-    }
+   
     
     function send()
     {