昨天,今天,明天,每天的每天,你是否都多懂得一点点...

星期日, 二月 09, 2020

[Youtube]峰哥教你玩正则表达式 - 第五课 - 分组与优先级

Tags: regex, regular expression, regex101, 正则, 正则表达式, 分组, group

本节课为正则表达式入门教程, 看完本视频你将掌握:

正则表达式中如何定义匹配的优先级
如何抓取分组里的内容
如何使用抓取的内容替换


-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-




星期二, 一月 21, 2020

A strange but works connection using HG259B as a wifi repeater

The connection is a little bit wield. The other router doesn't need any config. 

HG259B is router B
The original router is router A

Router B is from previous internet company. Router A is from the new  internet company. 

The original layout is simple, router A is connected to the fibre box with the WAN port. All other devices can connect to internet through router A's WIFI.

Telephone is connected to router A and working. 

Both routers have 2 telephone ports. But only router A has correct VOIP settings. Router A's company doesn't provide password to login to router A. So there is no way to copy the VOIP settings. 

The problem is that router A's WIFI signal cannot reach as Far as router B. Router B has the same config as router A for internet connection, so use router B for internet connection is OK. but as router B doesn't have VOIP settings,  telephone is not working with router B.

As we cannot enter router A's management portal, we can only do something from router B. The bad news is that Router B doesn't support WDS, so cannot use as a standard WIFI repeater.

The solution I made here is still using router B as a wifi repeater. 


The connection is as such:

Router B's WAN port connects to Fibre box
Router A's WAN port connects to Router B's LAN 1
Router A's LAN 2 connects to Router B's LAN 2


The hardware connection is simple, but wield. As Router A and Router B is already connected using  WAN port and LAN 1, it shouldn't need LAN2 to LAN2 connection. 


The software part is more complex:

1. Router B needs to be config as bridge mode, as below



2. Router B's IP is config to match Router A's domain, in my case, Router A's IP is 192.168.20.1, so I set router B's IP to 192.168.20.254. Also DHCP should be turned off. (So that Router'A DHCP will work).




3. Telephone is still connect to Router A


With this settings, Connect to both Router A's WIFI and Router B's WIFI will work. 

Different from WDS, their WIFI name and password are different. But actually they are the same network. Devices connect to both WIFI and talk to each other.



Questions: If we don't use bridge mode, can we still make it work? I failed once with these settings. But I am not sure If I made some other mistakes. It suppose to work with the following connection:

Router A's WAN port connect to Fibre box
Router B's LAN 1 connect to Router A's LAN 1
Router B change IP to match router A
Router B disable DHCP




--
Feng

星期五, 一月 17, 2020

Re: How to use a different nodejs version on atlassian bamboo build agent

If docker is available on the build server, use docker contained nodejs to build is a good idea too.

feng <fengnz@gmail.com> 于2020年1月17日周五 上午10:40写道:
When you build a nodejs app, you may need to use a specific version of node for building.  Either you want to match the running env or your node packages require a certain nodejs version. 

On Azure DevOps, you can easily choose the node version by adding a nodejs installer step. With bamboo, there is no nodejs install, but this can be achieved easily if you have admin access to the build agent. 

In the build steps, add a script step, and add the following inline script. This script will switch the node version for you. For first time running, you need to uncomment all the lines to install nvm first. 

[bash]

node -v
#curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
#nvm install 13.6.0
nvm use 13.6.0
nvm list
node -v
[/bash]

Then you can add a npm install step, it will use the new node version. Or you can simply add node install command to the script.

--
Feng


--
Feng

How to use a different nodejs version on atlassian bamboo build agent

When you build a nodejs app, you may need to use a specific version of node for building.  Either you want to match the running env or your node packages require a certain nodejs version. 

On Azure DevOps, you can easily choose the node version by adding a nodejs installer step. With bamboo, there is no nodejs install, but this can be achieved easily if you have admin access to the build agent. 

In the build steps, add a script step, and add the following inline script. This script will switch the node version for you. For first time running, you need to uncomment all the lines to install nvm first. 

[bash]

node -v
#curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
#nvm install 13.6.0
nvm use 13.6.0
nvm list
node -v
[/bash]

Then you can add a npm install step, it will use the new node version. Or you can simply add node install command to the script.

--
Feng

星期四, 一月 09, 2020

[Youtube]峰哥教你玩正则表达式 - 第四课 - 或的关系和与(且)的关系及其原理(肯定前瞻)


Tags: regex, regular expression, regex101, 正则, 正则表达式, 前瞻, look ahead

本节课为正则表达式入门教程, 看完本视频你将掌握:

如何写"或"关系的正则
如何写"与"关系的正则
"与"关系是什么原理


视频中2分40多秒的时候, 有个口误 , 或关系的字符是竖线字符, 视频中讲成下划线字符.



 
-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-



星期一, 十二月 30, 2019

[Youtube]峰哥教你玩正则表达式 - 第三课 - 重复符号 *, ?, + , 贪婪模式, 懒惰模式, 侵占模式



Tags: regex, regular expression, regex101, 正则, 正则表达式, 贪婪模式, 懒惰模式, 侵占模式


本节课为正则表达式入门教程, 看完本视频你将掌握:


使用特殊重复字符 *, ?, +, {}
使用贪婪模式
使用懒惰模式
使用侵占模式



 
-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-




星期一, 十二月 23, 2019

[Youtube]峰哥教你玩正则表达式 - 第二课 - 特殊匹配符号



Tags: regex, regular expression, regex101, 正则, 正则表达式


本节课为正则表达式入门教程, 看完本视频你将掌握:


使用特殊元字符 \d \D \b \B \w \W \s \S ^ $, 
用 [] 组建匹配字符集
用^ 制作字符的反集
匹配完整单词
匹配数字
匹配非数字
匹配英文字符
匹配非英文字符




 
-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-



星期四, 十二月 19, 2019

[网络技术]How to list all remote docker images in the repo?

tags: docker

If you have a private docker repo (such as azure docker registry), and would like to list all the remote images, what would you do?

If you have the portal access such as azure portal, you can see all your images easily. But if you only have the credentials for the repo, then what can you do?

It's actual very easy to do.

Docker registry provides a easy to use restful API to access images info. You can use any HTTP client to access it. In the following example, I use curl 

[code]

curl https://username:password@repo_domain/v2/_catalog  

{"repositories": ["image1", "image2", "image3" ...]}

[/code]


星期日, 十二月 08, 2019

[Youtube]如何验证, 调试正则表达式, 在线工具使用教程, 无需下载

Tags: regex, regular expression, regex101, 正则, 正则表达式

超级好用的在线正则表达式工具

本视频是此工具的使用教程

 
-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-


[Youtube]Windows (多种版本适用) 定时关机小技巧, 无需下载



Tags: windows, 定时, 关机, 重启

本方法支持 从 windows xp 到 windows 10 的所有windows 系统.

 
-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-

星期日, 十一月 24, 2019

[Youtube][跟峰哥学Node.js编程系列教程] Javascript Promise 异步编程全解析 [第十二期]

Tags: Javascript, nodejs, 峰哥, yufeng deng, expressjs, jade, pug, handlebars, bootstrap, Telegram Bot, Promise

本集对javascript 中的 promise 作一个详细的解析. Promise 是在javascript 中的一个异步操作, 也就是可以同时进行多个任务, 而不需要等待.  看完本集你将学会.

如何使用Promise函数
如何处理Promise函数返回的结果
如何使用 Promise 中的 catch 和 Promise.reject
如何链接多个 Promise.then
如何把前一个then的处理结果传给下一个then
如何嵌套多个 Promise 函数(实现同步操作)
如何等待多个Promise 的结果返回, 使用 Promise.all


之前的教程可以在这个播放列表找到

视频里用到的代码请到

 
-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-



星期日, 十一月 17, 2019

[Youtube]太牛了! Kubesail, 可以一键布署的免费服务器! 居然是免费的!

Tags: Javascript, nodejs, 峰哥, yufeng deng, expressjs, jade, pug, handlebars, bootstrap, Telegram Bot, kubesail, 免费, 服务器, 容器, kubernetes


Nodejs 网站+Telegram 机器人后台程序布署示例.


本集介绍如何使用Kubesail 将你的服务程序一键部署到远程服务器上.

本集将介绍如下内容 

注册github
注册docker hub
注册kubesail
安装docker 
安装npx 
一键部署nodejs 程序到kubesail
绑定程序端口到公开域名上


Nodejs编程系列的教程可以在这个播放列表找到
https://www.youtube.com/playlist?list=PL3dZh-p-vVofgTEnJ_SL1LM9jxmQp19E2

 
-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-


星期日, 十一月 10, 2019

[Youtube][跟峰哥学Node.js编程系列教程] 制作Telegram聊天聊软 回声机器人 [第十一期]

Tags: Javascript, nodejs, 峰哥, yufeng deng, expressjs, jade, pug, handlebars, bootstrap, Telegram Bot


本集介绍如何使用之前学的内容做一个简单的telegram 回声机器人. 在这个机器人的基本上, 小伙伴们可以开发出属于自己的强大聊天机器人. 看完本集你将学会.

如何绑定Telegram机器人到你的代码上
如何接收聊天群里发来的请求
如何读取聊天群的ID和发来的消息
如何把重复的代码变成一个函数
如何使用你的代码发送机器人消息
如何读取发送机器人消息后, TG返回的数据


之前的教程可以在这个播放列表找到
https://www.youtube.com/playlist?list=PL3dZh-p-vVofgTEnJ_SL1LM9jxmQp19E2


视频里用到的代码请到

 
-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-




星期日, 十一月 03, 2019

[Youtube][跟峰哥学Node.js编程系列教程] 调用第三方API - Telegram 机器人示例 [第十期]

Tags: Javascript, nodejs, 峰哥, yufeng deng, expressjs, jade, pug, handlebars, bootstrap, Telegram Bot


本集介绍如何使用 node fetch 调用第三方 Restful API. 本集使用 Telegram 机器人的API作为示例.  在本集视频的视频中, 将介绍如何调用Telegram 机器人的API, 把用户在网页上输入的内容转发到TG的群组当中. 


之前的教程可以在这个播放列表找到
https://www.youtube.com/playlist?list=PL3dZh-p-vVofgTEnJ_SL1LM9jxmQp19E2


视频里用到的代码请到

 
-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-



星期日, 十月 20, 2019

[Youtube][跟峰哥学Node.js编程系列教程] 制作简单的URL转码在线工具 [第九期]

Tags: Javascript, nodejs, 峰哥, yufeng deng, expressjs, jade, pug, handlebars, bootstrap, Url Encoder


本集是节实验课, 演示一下使用之前学习的内容, 如何做出一个在线URL转码的小工具! 



之前的教程可以在这个播放列表找到
https://www.youtube.com/playlist?list=PL3dZh-p-vVofgTEnJ_SL1LM9jxmQp19E2


视频里用到的代码请到

 
-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-


星期日, 十月 13, 2019

[Youtube][跟峰哥学Node.js编程系列教程]使用Bootstrap 美化表单和表单的客户端验证 [第七期]

Tags: Javascript, nodejs, 峰哥, yufeng deng, expressjs, jade, pug, handlebars, bootstrap


本集主要讲如何使用 Bootstrap 来美化和验证表单,  并用 bootstrap 在客户端显示错误提示信息.

看完本集你将学会:

如何使用bootstrap 样式美化网页
如何使用浏览器内建的表单验证
如何使用bootstrap 显示漂亮的表单和错误提示



之前的教程可以在这个播放列表找到
https://www.youtube.com/playlist?list=PL3dZh-p-vVofgTEnJ_SL1LM9jxmQp19E2


视频里用到的代码请到

 
-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-




--
Feng

星期三, 十月 09, 2019

[网络技术]Pandoc Undefined control sequence error

When I used pandoc to one of my files, it produced the following error.

Error producing PDF.
! Undefined control sequence.
l.256 \tightlist



I don't know which part of the markdown cause this. Search on google and find this solution:


Simply adding a empty tightlist to the template file fixed the issue.


--
Feng

How to increase docker toolbox disk size

Today, when I tried to pull a pandoc docker image, I got the following error. Simply, I ran out of the disk.

image.png

But my harddrive still have more than 100G space left. So what's the problem.

The reason is that docker toolbox is actually running in a linux VM hosted by virtual box. The default disk size of the VM is 20G.

Increase Virtualbox vdisk

So things become clear, I need to increase the VM disk size. So that I stopped my VM and run the following command to get a bigger VM disk.

cd C:\Users\dengy\.docker\machine\machines\default\  set path=C:\Program Files\Oracle\VirtualBox;%path%  vboxmanage clonehd "disk.vmdk" "virtualdisk.vdi" --format vdi  vboxmanage modifyhd "virtualdisk.vdi" --resize 65536  

Then replace the old disk with the new one.

image.png

image.png

image.png

Re-partition the disk in linux

So far so good, but it didn't work. I restarted the machine, still lack of space.

Now, the "physical" disk has been increased, but the partition in linux system is still the old size. Follow this blog to re-partition the disk.

https://www.dengnz.com/2019/03/25/increase-azure-linux-vm-disk-size/ 

You will get permission denied, that's ok, restart the vm and run sudo resize2fs /dev/sda1

then you will get your disk size correct.

image.png

You are done!

星期一, 十月 07, 2019

[Youtube]Telegram Bot 使用Cloudflare CF worker 制作回声机器人 [第二集番外]

Tags: Telegram, 机器人, 聊天机器人,机器人编程,机器人代码, Telegram代码,Telegram Bot, Telegram编程

https://youtu.be/-_fcxPsCVYs



第二集的视频在这里
https://youtu.be/SxwsGWlMfP4

整个系列的视频请点视频右上角的感叹号.


哈喽, 大家好, 欢迎来到峰哥分享, 我是峰哥.

最近咳嗽的老毛病又犯了, 基本没办法讲话.

所以今天这个视频就打字好了.

今天我来介绍一下怎么样在Cloudflare 上用worker 来创建一个Telegram bot 的聊天机器人.

当然是最简单的机器人, 只能简单的回复文字, 而且还是同样的汤姆猫机器人, 就是你说什么, 它就说什么.

之前出的教程是在谷歌的 app script 上面的, 其实代码都是JS, 所以把我的GAS (google app script)
的教程拿在 cf worker 上面, 也是差不了多少.

所以, 今天就来教大家做一个最基础的机器人, 剩下的, 小伙伴们再看我的telegram bot的教程, 应该就能看明白了.

好吧, 开始教程!

首先, 我们需要创建一个机器人, 这个就直接看我的TG教程系列的第一集就可以了.

机器人申请好了, 我们来加一下 cf worker 的代码

还没有cloudflare 帐号的小伙伴自己注册一下, 这个很简单,我就不多介绍了.

自己到以下网址注册

https://dash.cloudflare.com/sign-up

然后登录

新建一个 worker 脚本

新建完脚本以后, 是一个简单的hello world 网页, 直接就是工作的.

通过 save and deploy 发布这个网站

到以下这个网址去抄网方的示例POST代码
https://developers.cloudflare.com/workers/templates/snippets/post_data/

抄来的代码最后那段HTML不要, 然后 save and deploy 就可以开作了

只是简单的显示了 The request was a GET

现在我来加入机器人的代码, 只有简单的几行, 非常容易!

粘贴完这段代码

let bodyString = await readRequestBody(request)

try {

let body = JSON.parse(bodyString);

const init = {
headers: { 'content-type': 'application/json' },
}

if (body.message) {
let payload = {
"method": "sendMessage",
"chat_id": body.message.chat.id,
"text": "Only echo back text",
"parse_mode": "markdown",
"disable_web_page_preview": true,
};
if (body.message.text) {
payload.text = body.message.text;

const myInit = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
};

let myRequest = new
Request("https://api.telegram.org/bot682267360:AAHmjSil8oylavD2pENLLpcMU1svaD7mVeA/",
myInit)

//let myRequest = new Request("https://eaa874bb.ngrok.io", myInit)
fetch(myRequest).then(x=> {
console.log(x);

});


return new Response("OK")
} else {
return new Response("OK")
}

} else {
return new Response(JSON.stringify(body), init)
}

}catch(e){
return new Response(e)
}

注册刚才高亮的那段代码, 其中的网址是以下这段, 这里面从bot 开始, 就是机器人的token
https://api.telegram.org/bot682267360:AAHmjSil8oylavD2pENLLpcMU1svaD7mVeA/

注意后面那个 / 非常重要, 不能省略

好了, 现在发布改过的代码

发布完成后, 我们需要绑定机器人, 机器人的网址在这里

https://raspy-sun-ed74.fennng.workers.dev/

为了预防成一, 我们把这个网址做一下 urlencode

网上随便找一个在线的 url encoder , encoder 完是以下的样子

https%3A%2F%2Fraspy-sun-ed74.fennng.workers.dev%2F

现在找到绑定机器人的链接,以下这段是设置机器人的链接, 前面 https://api.telegram.org/bot 这段是固定的,

中间这段 682267360:AAHmjSil8oylavD2pENLLpcMU1svaD7mVeA 是机器人的 token

后面这段是设置机器人链接的方法 /setWebhook?url=

所以我们要把机器人后台链接放在这个链接的最后面

https://api.telegram.org/bot682267360:AAHmjSil8oylavD2pENLLpcMU1svaD7mVeA/setWebhook?url=https%3A%2F%2Fraspy-sun-ed74.fennng.workers.dev%2F

粘贴完后是上面这个样子

现在把这个链接放在浏览器的地址栏打开, 看到以下这个就是绑定成功

{"ok":true,"result":true,"description":"Webhook was set"}

现在我们去试下机器人

工作, 发布成功.

现在来随便改点东西, 简单的加了个签名, 现在再去看看

成功的改了....

很简单吧, 机器人的创建看第一集. 然后, 其它机器人的功能看我关于 谷歌app script 的教程就行了, 差不了多少.

注意的是, cf worker 的 fetch 是 promise, 这点和gas 有很大不同...做简单的机器人可以先不理会. 跟着我的代码写就行了.

好了, 今天的教程就到这里, 喜欢这个视频的话, 不要忘了点赞,订阅还有转发!

谢谢大家. 我们下载再见!


-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程,
如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz
🔷 Twitter: https://twitter.com/fennng

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-

其它博客地址

此博客的同步博客地址: http://fengnz.wordpress.com
这里进入我的MSN SPACE.