Skip to content

Instantly share code, notes, and snippets.

@IcedMango
Last active June 30, 2023 09:58
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save IcedMango/6007aed2d52872a43ef9986475f392df to your computer and use it in GitHub Desktop.
Save IcedMango/6007aed2d52872a43ef9986475f392df to your computer and use it in GitHub Desktop.
How to use tasker forward SMS to telegram
//bot秘钥
var apiKey = "";
//请求链接
var apiUrl = "api.telegram.org";
//会话ID
var chatId = "";
//发件人名称
var senderName = global('SMSRN');
if (senderName.match(/\d*/g)[0].length > 0) {
senderName = "";
}
//消息内容
var Message = encodeURIComponent(`${global('SMSRB')}\n[发件人 ${senderName} ${global('SMSRF')}]\n[接收于 ${global('SMSRD')} ${global('SMSRT').replace('.', ':')}]`);
var url = `https://${apiUrl}/bot${apiKey}/sendMessage?chat_id=${chatId}&text=${Message}`;
var xhttp = new XMLHttpRequest();
xhttp.open("GET", url, false);
xhttp.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment