telegram_parse “upgrade”
-
Hi! ?? I love your plugin since unleash a lot of potential! ?? I have just a suggestion: send to “telegram_parse” action the entire data object so a developer can handle every kind of interactions (ex. “new_member”).
here is my quick mod of “parse.php”:
do_action( ‘telegram_parse’, $USERID, $COMMAND ); //EXPERIMENTAL
do_action( ‘telegram_parse’, $USERID, $data ); //EXPERIMENTALin this way you can have more fun! ??
IMPORTANT: advise people to make the bot “admin” otherwise it will work in “privacy mode” and will just get “/commands”.Here it is your PHP code snippet modified with an example to make a “welcome message”:
add_action('telegram_parse','telegramcustom_parse', 10, 2); function telegramcustom_parse( $telegram_user_id, $data ) { $plugin_post_id = telegram_getid( $telegram_user_id ); if ( !$plugin_post_id ) { return; } $text = $data['message']['text']; // to get just text if ( $text == '/command') { telegram_sendmessage( $telegram_user_id, 'Oh, yes you typed '.$result); } if( isset($data['message']['new_chat_member']) ) { telegram_sendmessage( $telegram_user_id, 'Welcome '.$data['message']['new_chat_member']['first_name']); } return; }
- The topic ‘telegram_parse “upgrade”’ is closed to new replies.