@@ -13,62 +13,45 @@ function mdEscape($text) {
13
13
return str_replace (array_keys ($ rep ), array_values ($ rep ), $ text );
14
14
};
15
15
16
+ function get_vardump ($ var ) {
17
+ ob_start ();
18
+ var_dump ($ var );
19
+ return ob_get_clean ();
20
+ };
21
+
16
22
$ updates = file_get_contents ("php://input " );
17
23
$ updates = json_decode ($ updates , TRUE );
18
24
19
25
$ msg = $ updates ["message " ];
20
-
21
- $ teclado = array (
22
- "inline_keyboard " => array (
23
- array (
24
- array (
25
- "text " => "Canal moderatorz " ,
26
- "url " => "https://telegram.me/Moderatorz "
27
- ),
28
- array (
29
- "text " => "Trucos Telegram " ,
30
- "url " => "https://telegram.me/trucostelegram "
31
- )
32
- ),
33
- array (
34
- array (
35
- "text " => "Google " ,
36
- "url " => "https://google.com "
37
- )
38
- )
39
- )
40
- );
26
+ $ msg ["cb " ] = $ updates ["callback_query " ];
41
27
42
28
if ($ config ["var_dump " ]) {
43
- ob_start ();
44
- var_dump ($ msg );
45
- $ result = ob_get_clean ();
29
+ $ result = get_vardump ($ msg );
46
30
if ($ result ) {
47
- $ bot ->sendMessage ($ config ["owners " ][0 ], $ result, false , false , false );
31
+ $ bot ->sendMessage ($ config ["owners " ][0 ], $ result );
48
32
return ;
49
33
}
50
34
};
51
35
52
- if (isset ($ msg ["forward_from_chat " ])) {
53
- $ username = $ msg ["forward_from_chat " ]["username " ]?"@ " .mdEscape ($ msg ["forward_from_chat " ]["username " ]):"" ;
54
- $ type = $ msg ["forward_from_chat " ]["type " ]?"\n*Type*: " .$ msg ["forward_from_chat " ]["type " ]:"" ;
55
- $ bot ->sendReply ($ msg , $ username ."\n*Id*: " .$ msg ["forward_from_chat " ]["id " ]."\n*Title*: " .mdEscape ($ msg ["forward_from_chat " ]["title " ]).$ type , "markdown " , false );
56
- return ;
57
- };
58
-
59
- if (isset ($ msg ["forward_from " ])) {
60
- $ msg ["from " ] = $ msg ["forward_from " ];
61
- };
62
-
63
- if (isset ($ msg ["text " ]) && isset ($ msg ["from " ])) {
64
- $ last_name = $ msg ["from " ]["last_name " ]?"\n*Last*: " .$ msg ["from " ]["last_name " ]:"" ;
65
- $ username = $ msg ["from " ]["username " ]?"@ " .mdEscape ($ msg ["from " ]["username " ]):"" ;
66
- $ language_code = $ msg ["from " ]["language_code " ]?"\n*Lang*: " .$ msg ["from " ]["language_code " ]:"" ;
67
- $ bot ->sendReply ($ msg , $ username ."\n*Id*: " .$ msg ["from " ]["id " ]."\n*First*: " .mdEscape ($ msg ["from " ]["first_name " ]).$ last_name .$ language_code , "markdown " , false );
36
+ for ($ i =0 ; $ i <sizeof ($ config ["plugins " ]); $ i ++) {
37
+ $ actual_plugin = include "plugins/ " .$ config ["plugins " ][$ i ];
38
+ if (isset ($ actual_plugin ["pre_process " ])) {
39
+ call_user_func ($ actual_plugin ["pre_process " ], $ bot , $ msg , $ matches );
40
+ };
41
+ if (isset ($ actual_plugin ["exe " ])) {
42
+ for ($ m =0 ; $ m <sizeof ($ actual_plugin ["patterns " ]); $ m ++) {
43
+ preg_match ($ actual_plugin ["patterns " ][$ m ], $ msg ["text " ], $ matches , PREG_OFFSET_CAPTURE );
44
+ if ($ matches ) {
45
+ call_user_func ($ actual_plugin ["exe " ], $ bot , $ msg , $ matches );
46
+ break ;
47
+ }
48
+ }
49
+ };
68
50
};
69
51
70
52
ini_set ('display_errors ' , 1 );
71
53
ini_set ('display_startup_errors ' , 1 );
72
54
error_reporting (E_ALL );
73
55
56
+
74
57
?>
0 commit comments