创建你的第一个bot
- 留言@botfather https://telegram.me/botfather,内容如下:/newbot 如果您不知道如何通过用户名发送消息,请单击您的电报应用程序上的搜索字段,然后键入@botfather,您应该能够发起对话。请注意不要将其发送给错误的联系人,因为有些用户的用户名与其相似botfather。
- @botfather回复 Alright, a new bot. How are we going to call it? Please choose a name for your bot.
- 为你的机器人输入任何你想要的名字。
- @botfather回复 Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot.
- 为您的机器人输入您想要的任何用户名,最少5个字符,并且必须以bot。例如:telesample_bot
- @botfather回复:
Done! Congratulations on your new bot. You will find it at
telegram.me/telesample_bot. You can now add a description, about
section and profile picture for your bot, see /help for a list of
commands.
Use this token to access the HTTP API:
123456789:AAG90e14-0f8-40183D-18491dDE
For a description of the Bot API, see this page:
https://core.telegram.org/bots/api
- 翻墙,登录国外服务器,创建数据库并执行根目录下的structure.sql文件创建数据表
- 修改根目录下的getUpdatesCLI.php文件配置信息
例:$bot_api_key = ‘123456789:AAG90e14-0f8-40183D-18491dDE’;
$bot_api_key = 'your:bot_api_key';
$bot_username = 'username_bot';
$mysql_credentials = [
'host' => 'localhost',
'user' => 'dbuser',
'password' => 'dbpass',
'database' => 'dbname',
];
- 将创建的机器人拉进电报群,并给服务器添加定时任务执行getUpdatesCLI.php文件,每次执行都会将群内消息保存到数据库中,message表中的text字段为用户发出的消息。(注:只能获取24小时内消息,超过24小时的消息将获取不到,获取过的数据不会重复获取)
1.翻墙,并用国外服务器
2.获取域名及https证书
3.创建项目修改set.php,hook.php中的botName,botAPI
4.修改set.php 中hook地址
5.hook.php 增加
6.删除unset.php文件
7.执行https://api.telegram.org/bot*:AAHX******p5saZoE/setWebhook?url=https://*.com
8.邀请机器人进群加管理
9.获取管理员ID,手动将ID加入项目