Linux 软件免费装
Banner图

Telegram Bot & Channel

开发者 Milmor
更新时间 2023年10月20日 07:50
捐献地址: 去捐款
PHP版本: 5.6 及以上
WordPress版本: 6.4
版权: GPLv2 or later
版权网址: 版权信息

标签

newsletter automatic classicpress telegram bot channel group stream

下载

0.10 3.7 1.2.1 3.5 3.6 3.6.1 3.4.10 3.6.2 3.6.3

详情介绍:

This versatile plugin allows you to accomplish a variety of tasks, including teaching, playing, searching, broadcasting, reminding, connecting, and integrating with your services. With this powerful bot builder, you can: 🤖 Bot builder: create interactive autoresponders for users and groups 📣 Broadcast: utilize the broadcast feature to send messages to your channels and bot subscribers https://youtu.be/8fckoWSmAks Bot features Enhance your content distribution strategy with these free advanced features: 📰 Send your content (post, page or custom messages) with templates 📅 Support for scheduled post broadcast ⌨️ Utilize keyboards and inline buttons for enhanced user engagement 💬 Broadcast to various channels including chats, groups, supergroups, and channels ↩️ Create unlimited autoresponders 📊 View insights about users and groups subscribed to your bot 📡 Haversine algorithm to get users' location and provide geo-focused content 🎨 Create custom applicatons with /$command $var1 $var2 format for custom application creation 💡 Zapier integration to ensure seamless connectivity with your other tools Channel features 📰 Send your content (post, page or custom messages) with configurable templates 📅 Support for scheduled post broadcast 💡 Zapier integration Note: your bot must be administrator of your channel for sending messages 🔐 Every connection relies on secure webhooks for maximum security. Telegram requires SSL to manage a Telegram Bot. If you don't have it, just choose the free opt-in service botpress.org in options (the feature will send some data to our server). Zapier and IoT features Zapier makes it easy to automate tasks between web apps. For example: https://www.youtube.com/watch?v=14aEV0_FHFk DEMO

安装:

This section describes how to install the plugin and get it working.
  1. Upload telegram-bot directory to the /wp-content/plugins/ directory
  2. 通过 WordPress 的“插件”菜单激活插件
  3. Go to the Telegram settings page
  4. Go through the steps and hit update!

屏幕截图:

  • Subscribers list
  • Commands list
  • Autoresponders
  • Zapier integration
  • plugin options
  • Dynamic repliles and inline buttons example from [IcBrendola_bot](http://telegram.me/IcBrendola_bot)
  • Keyboard example from [CosenzApp_bot](http://telegram.me/CosenzApp_bot)
  • Post broadcasting (all post types)
  • Native Gutenberg support

常见问题:

How do I create a bot?

More documentation is available on www.botpress.org/docs www.botpress.org/docs/telegram/how-to-create-a-bot

What is Zapier and how do i integrate it?

www.botpress.org/docs/telegram/zapier-integration

How to enable debug mode?

If you are a developer, or just want a more complete "Telegram > Log" enable WP_DEBUG mode. The plugin debug mode also allows to explore Telegram users and groups as standard posts. This let you to check custom fields for each users and modify them in real time. You'll notice a new column (= Telegram id for the user) in Subscribers and Groups page. We don't suggest to keep WP_DEBUG if not for testing purposes.

How to make dynamic replies? (PHP required)

The best way to integrate PHP code is to build a custom integration plugin, but you can also add PHP to /$commands directly in your WordPress admin dashboard using the Insert Php plugin. In case you want to scale and choose the first option, you can create a new file called telegram-bot-custom.php and upload it to wp-content/plugins. The following example, once activated in the plugins list, will reply to /command: `<?php / Plugin Name: Telegram Bot & Channel (Custom) Description: My Custom Telegram Plugin Author: My name Version: 1 / add_action('telegram_parse','telegramcustom_parse', 10, 2); function telegramcustom_parse( $telegram_user_id, $text ) { $plugin_post_id = telegram_getid( $telegram_user_id ); if ( !$plugin_post_id ) { return; } / Here is the dynamic processing and how to reply. You can: - use if, switch and everything that works in php - check if $text is made of multiple words (create an array from $text) - customize and code other actions (ex. create WordPress post is $telegram_user_id is your id) / if ( $text == '/command') { telegram_sendmessage( $telegram_user_id, 'Oh, yes you typed /command'); } return; } ?>`

How to set up dynamic keyboards?

You can send custom keyboards directly in php. Every keyboard can be set only when you send a message, and is kept in the client side until another keyboard is sent (in another message). You can also change this behaviour by setting the $one_time_keyboard true or false. telegram_sendmessage( $telegram_user_id, 'Hello from the other side!'); //Message with no keyboard (or with default one if set in plugin options) telegram_sendmessage( $telegram_user_id, 'Hello from the other side!', telegram_build_reply_markup( '11,12,13;21,22', true )); //Message with custom keyboard Here is the details of telegram_build_reply_markup (an array is returned): telegram_build_reply_markup( '11,12,13;21,22', //The keyboard template (eg. 2 row, 3 columns for the first one and two columns for the second one true, // $one_time_keyboard (optional) (default false = kept until a new keyboard is sent) (true = kept until the user send something to the bot) true // $resize_keyboard (optional) (default true) ); You can also alter keyboards for commands defined in the admin area. Start from the previous custom plugin created, and add the following filter: `add_filter( 'telegram_get_reply_markup_filter', 'telegram_get_reply_markup_filter_custom', 1 ); function telegram_get_reply_markup_filter_custom( $id ) { if ( $id ) { switch ( $id ) { case 7: //Your command ID (found in the url while editing the command) telegram_log('####', $id, 'custom keyboard'); //Useful for debug return array( 'keyboard' => array(array('Top Left', 'Top Right'),array('Bottom')), 'resize_keyboard' => true, //true or false (suggested: true) 'one_time_keyboard' => true //true or false );\ default: return; } } }`

How to get user location?

It's easy, with harvesine algorithm (one-point radius) or standard geolocation (4-points). These snippets only cover the harvesine algorithm, that is simple and supported by the plugin. To use the standard 4-points geolocation it's enough to do some php-calc with basic if-then structures. You can start from the previous custom plugin created, and add the following action: `add_action('telegram_parse_location','telegramcustom_c_parse_location', 10, 3); function telegramcustom_c_parse_location ( $telegram_user_id, $lat, $long ) { if ( telegram_location_haversine_check ( 45.85, 9.70, $lat, $long, 20 ) ) { telegram_sendmessage( $telegram_user_id, 'Inside the radius'); } }` The examples sends a "Inside the radius" message when the user is inside the 20-meters radius centered in 45.85 Lat, 9.70 Long. You have two developer functions to use: `//Check if point is within a distance (max_distance required) $boolean = telegram_location_haversine_check ( $latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, $max_distance, $min_distance = 0, $earthRadius = 6371000); //Calculate the distance $int = telegram_location_haversine_distance ( $latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, $earthRadius = 6371000);` The first function returns a boolean (true/false) depending on given parameters. Please note that $min_distance and $earthRadius are optional. The second one returns a int (in meters) of the distance. $earthRadius optional. Both the functions calculates distances on meters. If you want another type of result, just change the $earthRadius.

How to get user photos?

We've written simple functions to let developers build everything. Photos are saved in /wp-content/uploads/telegram-bot/'.$plugin_post_id.'/'.$file_name where $plugin_post_id is the custom post type id associated with the Telegram subscription (ex. '24') and $file_name is time().$extension `<?php / Plugin Name: Telegram Bot & Channel (Custom) Description: My Custom Telegram Plugin Author: My name Version: 1 / add_action('telegram_parse_photo','telegramcustom_parse_photo', 10, 2); function telegramcustom_parse_photo ( $telegram_user_id, $photo ) { $plugin_post_id = telegram_getid( $telegram_user_id ); if ( !$plugin_post_id ) { return; } /* Here is the dynamic processing and how to reply. You can:

  • use if, switch and everything that works in php
  • check if $text is made of multiple words (create an array from $text)
  • customize and code other actions (ex. create WordPress post is $telegram_user_id is your id) / / $photo[2]['file_id'] is only one of available sizes. You should make sure that this size exist, or check for another size. $photo[1]['file_id'] has lower resolution */ $url = telegram_download_file( $telegram_user_id, $photo[2]['file_id'] ); //Fetch and save photo to your server
if ( $url ) { //$url is the local url because photo is already saved //You can save the entry in your db global $wpdb; $arr = array( 'telegram_id' => $telegram_user_id, 'plugin_post_id' => $plugin_post_id, 'url' => $url ); $wpdb->insert( $wpdb->prefix . 'your_table_name_that_must_already_exist', $arr, array( '%s' ) ); //Or save it as custom field and use it for a Finite State Machine update_post_meta( $plugin_post_id, 'telegram_custom_last_photo_received', $url ); telegram_sendmessage( $telegram_user_id, 'Photo received. Thank you!'); } ?>` Another example, that is a "emergency bot" created for the mid-italy earthquake (24 august 2016) is available on GitHub

更新日志:

3.7 20231020 3.6.3 20230527 3.6.2 20230217 3.6.1 20220927 3.6 20220927 3.5 20220907 3.4.10 20220819 3.4.9 20210804 3.4.7 20210402 3.4.6 20210222 3.4.4 20210222 3.4.3 20210219 3.4.2 20210217 3.4.1 20210205 3.4 20201210 3.3 20201114 3.2.2 20201001 3.2.1 20200909 3.2 20200908 3.1.2 20200515 3.1.1 20200515 3.1 20200430 3.0 28.04.2020 2.3 27.12.2019 2.2.1 15.06.2019 2.2 05.09.2017 2.1.1 4.03.2017 2.0.7 7.02.2017 2.0.6 13.01.2017 2.0.4 29.12.2016 2.0.3 21.12.2016 2.0.1 16.12.2016 2.0 14.12.2016 1.8.3 5.12.2016 1.8.1 16.11.2016 1.8 15.11.2016 1.7.1 16.09.2016 1.7 14.09.2016 1.6.1 27.08.2016 1.6 26.08.2016 1.5.2 25.08.2016 1.5.1 23.08.2016 1.5 23.08.2016 1.4.2 17.08.2016 1.4.1 06.08.2016 1.4 07.07.2016 1.3.18 6.07.2016 1.3.17 21.05.2016 1.3.16 22.04.2016 1.3.15 03.04.2016 1.3.14 26.02.2016 1.3.13 26.02.2016 1.3.12 21.02.2016 1.3.11 15.02.2016 1.3.10 14.02.2016 1.3.9 13.02.2016 1.3.8 05.02.2016 1.3.7 02.02.2016 1.3.6 01.02.2016 1.3.5 28.01.2016 1.3.4 24.01.2016 1.3.3 13.01.2016 1.3.2 13.01.2016 1.3 8.01.2016 1.2 7.01.2016 1.1.1 7.01.2016 1.1 26.12.2015 1.0.2 21.11.2015 1.0 19.11.2015 0.13 11.11.2015 0.12 11.11.2015 0.11 09.11.2015 0.10 24.10.2015 0.9 23.09.2015 0.8 15.09.2015 0.7.3 - 14.09.2015 0.7.2 - 13.09.2015 0.7.1 - 13.09.2015 0.7 - 13.09.2015 0.1 - 07.09.2015