顯示具有 line notify 標籤的文章。 顯示所有文章
顯示具有 line notify 標籤的文章。 顯示所有文章

2024/10/16

URLEncoded of emojis

telegram line 傳訊時會用到的東東




2024/10/12

還是line notify終止服務的問題
今天試了另一個方式 telegram
記錄一下
註冊完後首先要把 botfather 加入好友
接下來再對話中輸入 /newbot
他會叫你給bot取個名字
這個名字一定要以bot結尾
例如 testbot

送出後的回應裡就會有一組API key
一定要記好

接下來建立群組並把 testbot 加入該群組

使用curl取得testbot相關資訊

curl https://api.telegram.org/botYOUR API KEY/getUpdates

如果bot加入的群組愈多 回應就會愈多

在得到的回應中先找group 這個關鍵字

往前看 title 就是群組名稱 再往前看 id 就是該群組的id 要記下來 傳訊息時要用

範例如下

"id":-123456780,"title":"test","type":"group"

再來就可以使用curl傳訊息了

curl -X POST "https://api.telegram.org/botYOUR API KEY/sendMessage" -d "chat_id=-1234567890&text=bot%0A換行中文傳訊息 測試"

感覺discord很耗電 telegram好很多

2024/10/10

最近最大的消息應該是line notify要終止服務了
官方說明取代的是付費的 messaging API

因此開始尋代替代方案
目前選定了discord
支援二個方式
一個是建立bot 步驟有點多

另一個是使用webhook
強烈建議使用這個方法
方便很多
而且librenms也直接支援


2023/11/22

line 傳訊息同時傳圖片


curl -X POST https://notify-api.line.me/api/notify -H 'Authorization: Bearer (your token)' -F 'message=test' -F 'imageFile=@/tmp/1122.jpg'


以上指令的 message無法換行

使用 test\n\ntest      test\\ntest 都不行

2022/09/10

今天想使用 line 發群組通知

首先申請權杖

 

官方文件範例是使用 curl


$ curl -X POST -H 'Authorization: Bearer <access_token>' -F 'message=foobar' \

https://notify-api.line.me/api/notify

 

但試了半天發現一個問題 就是 message 無法換行 

找了好久才找到 範例如下


第一個方法


curl -X POST      -H 'Authorization: Bearer (your token)'      --data-binary message="%0A中文%0A123%0Aabc%0A456"      https://notify-api.line.me/api/notify


第二個方法

curl -X POST    -H 'Authorization: Bearer (your token)'   -d $'message=123\nabc'  https://notify-api.line.me/api/notify


使用python範例如下

檔名存為 line_notify.py

檔案內容如下


import requests

import sys


f = open(sys.argv[1])

msg = f.read()

f.close


def lineNotify(token, msg):

    url = "https://notify-api.line.me/api/notify"

    headers = {

        "Authorization": "Bearer " + token

    }

    payload = {'message': msg}

    r = requests.post(url, headers=headers, data=payload)

    return r.status_code


token = "your token"

lineNotify(token, msg)


只要指定檔案發送
檔案內是什麼內容
發送就是什麼內容

用法

python line_notify.py /tmp/txt_to_send


https://xenby.com/b/274-%E6%95%99%E5%AD%B8-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8-line-notify-%E5%B0%8D%E7%BE%A4%E7%B5%84%E9%80%B2%E8%A1%8C%E9%80%9A%E7%9F%A5


https://officeguide.cc/python-line-notify-send-messages-images-tutorial-examples/


https://fm-aid.com/bbs2/viewtopic.php?pid=52815


https://notify-bot.line.me/zh_TW/


https://notify-bot.line.me/doc/en/