Code Monkey home page Code Monkey logo

tgmessage's Introduction

TG Bot

TG 消息推送机器人,基于 vercel 函数搭建的TG消息推送机器人,无需服务器。

搭建教程

Deploy to Vercel

Deploy to Vercel

建立 TG 机器人

1.首先关注 BotFather

  1. 创建机器人,关注 BotFather 之后,发送 /newboot 开始创建 Bot 第一次输入机器人名称,第二次输入机器人 username 需要以 bot 结尾 oEENc.png

3.获取机器人 token

创建成功之后会发送一条消息给你,里面就包含了 token

oEGEr.png

设置机器人 Command 设置获取 token 命令 首先给 BotFather 发送 /mybots,然后点击你刚才创建的机器人,再点击 Edit Bot, 继续点击 Edit Commands。 然后输入

token - 获取token

这样就设置好了一个 commands

oEQIM.png oE0FG.png oEcR1.png oEd9I.png

部署到 Vercel

点击首页的 Deploy 跳到 vercel oSgul.png

输入项目名,然后确认

oSpFg.png

确认之后会直接部署到 vercel

设置环境变量

vercel 部署好了之后,然后设置环境变量

在控制台点击你创建好的项目,然后点击设置,添加环境变量

设置vercel 环境变量

需要设置4个环境变量,1个是必填的

token: bot 机器人的token
sign_key: 加密 chat_id 需要用到,不设置默认为 abc
url: webhook 回调地址, 不设置的话请求 setWebhook 时需要手动加参数, webhook url 地址为:https://你的域名/webhook
key: 设置 webhook 的请求参数

oSJRB.png

上面的环境变量设置好了之后,可能不会立马生效,你可以重新构建一下函数

oSP9s.png

设置回调

设置 webhook ,可以直接通过浏览器请求来设置

webhook地址为:https://你的域名/webhook

浏览器窗口打开:https://你的域名/setwebhook?key=环境变量设置的KEY&url=你的webhook地址

code 返回 200 就是设置成功了~

tgmessage's People

Contributors

anhao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tgmessage's Issues

求助!

你好,请问最后一步设置 WebHook能不能写的详细一点?请问在哪里执行执行 `curl以及php 执行 set webhook 脚本?谢谢!

您好,我按您的步骤装好了。是不是升级的原因,还是有点问题,应该是我不会的原因。请您帮我看看。多谢了!

1,我结果是 {"code":200,"message":"\u8bbe\u7f6e\u6210\u529f"}
2,

字段名称 | 字段说明 | 类型 | 必填 | 备注

token   | string | Y | token
message   | string | Y | 要发送的消息内容

这个token 在环境变量已经填过了,不用再填了吧?那message 在哪填呢?

3,还有webhook地址 比如你的 https://tg-message.vercel.app/webhook ?,还有设置GIT选项里还有一个
Deploy Hooks
Deploy hooks are unique URLs that allow you to trigger a deployment of a given branch.

push on main
https://api.vercel.com/v1/integrations/deploy/prj_yjTS6lry4Ww1lxSUL9

到底是哪个呢? 打扰了。期待回复。新年好!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.