Send notifications by multiple channels
Project description
安装
pip install anotify
导入
实例
企业微信
from ANotify import Nwecom
# 企业ID
CORPID = ''
# 应用Secret
CORPSECRET = ''
# 应用ID
AgentId = ''
wn = Nwecom.WxNotify(corpid=CORPID, corpsecret=CORPSECRET, agentid=AgentId)
wn.send_msg("test message")
wn.send_msg_markdown("**Hello**\n- test1\n- [ANotify](https://github.com/TommyMerlin/ANotify)")
wn.send_text_card("test title", "test content", "https://www.example.com")
wn.send_file("./test.txt")
wn.send_img("./test.png")
# Webhook
WEB_HOOK = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxx"
wn_webhook = Nwecom.WxWebhookNotify(WEB_HOOK)
wn_webhook.send_msg("Hello")
wn_webhook.send_msg_markdown("**Hello**\n- test1\n- [ANotify](https://github.com/TommyMerlin/ANotify)")
wn_webhook.send_img("E:/Desktop/gpt/Cursor_Demo/test.png")
wn_webhook.send_file("test.png")
飞书
官网
创建应用
API调试台
获取消息发送对象 openid
Webhook请求发送消息
from ANotify import Nfeishu
APPID = ''
APPSECRET = ''
OPEN_ID = ''
UNION_ID = ''
USER_ID = ''
CHAT_ID = ''
feishu = Nfeishu.FeishuNotify(appid=APPID, appsecret=APPSECRET)
feishu.send_msg(Nfeishu.ReceiverType.OPEN_ID, OPEN_ID, "Hello World!")
feishu.send_msg(Nfeishu.ReceiverType.UINION_ID, UNION_ID, "Hello World!")
feishu.send_msg(Nfeishu.ReceiverType.USER_ID, USER_ID, "Hello World!")
feishu.send_msg(Nfeishu.ReceiverType.CHAT_ID, CHAT_ID, "Hello World!")
# 发送图片
feishu.send_img(Nfeishu.ReceiverType.OPEN_ID, OPEN_ID, "test.png")
# 发送文件
feishu.send_file(Nfeishu.ReceiverType.OPEN_ID, OPEN_ID, "test.txt")
# Webhook
feishu_webhook = Nfeishu.FeishuWebhookNotify("https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxx")
feishu_webhook.send_msg("Hello World!")
钉钉
from ANotify import Ndingtalk
WEB_HOOK = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxx"
dingtalk_webhook = Ndingtalk.DingtalkWebhookNotify(WEB_HOOK)
dingtalk_webhook.send_msg("Hello World!")
Gotify
from ANotify import Ngotify
TOKEN = ""
SERVER_URL = ""
gotify = Ngotify.GotifyNotify(SERVER_URL, TOKEN)
gotify.send_msg("title", "content")
gotify.send_msg("title", "**content**\n- No.1\n- No.2", Ngotify.MessageType.markdown)
Ntfy
from ANotify import Nntfy
TOPIC = ""
URL = ""
ntfy = Nntfy.NtfyNotify(TOPIC, URL)
ntfy.send_msg("title", "content")
AnPush
from ANotify import Nanpush
TOKEN = ""
anpush = Nanpush.AnpushNotify(TOKEN)
anpush.send_msg("title", "content", "channel_id")
息知
from ANotify import Nxizhi
TOKEN = ""
xizhi = Nxizhi.XizhiNotify(TOKEN)
xizhi.send_msg("title", "content")
传息
from ANotify import Nchuanxi
TOKEN = ""
chuanxi = Nchuanxi.ChuanxiNotify(TOKEN)
chuanxi.send_msg("title", "content")
WPush
from ANotify import Nwpush
TOKEN = ""
wpush = Nwpush.WpushNotify(TOKEN)
wpush.send_msg("title", "content")
IYUU
from ANotify import Niyuu
TOKEN = ""
iyuu = Niyuu.IyuuNotify(TOKEN)
iyuu.send_msg("title", "content")
PushPlus
from ANotify import NPushPlus
TOKEN = ''
pushplus = Npushplus.PushPlusNotify(TOKEN)
pushplus = Npushplus.PushPlusNotify(TOKEN)
pushplus.send_msg("测试标题", "测试正文", Npushplus.TemplateType.txt)
msg_json = {
"status": 200,
"msg": "success"
}
pushplus.send_msg("测试标题", msg_json, Npushplus.TemplateType.json)
pushplus.send_msg("测试标题", "**测试内容**\n- test1\n- [ANotify](https://github.com/TommyMerlin/ANotify)", Npushplus.TemplateType.markdown)
pushplus.send_msg("测试标题", "测试内容<a href='https://github.com/TommyMerlin/ANotify'>ANotify</a>", Npushplus.TemplateType.html)
# 异步调用发送消息
async def main():
result = await pushplus.send_msg_async("测试标题异步", "测试正文异步", TemplateType.txt)
asyncio.run(main())
Server酱
from ANotify import Nserverchan
TOKEN = ''
serverchan = Nserverchan.ServerChanNotify(TOKEN)
serverchan.send_msg("测试标题", "测试正文")
Reminder
from ANotify import Nreminder
PUSH_KEY = ""
reminder = Nreminder.ReminderNotify(PUSH_KEY)
reminder.send_msg("title", "content")
巴法云
from ANotify import Nbemfa
TOKEN = ""
bemfa = Nbemfa.BemfaNotify(TOKEN)
bemfa.send_msg("title", "content")
Telegram Bot
from ANotify import Ntelegram
TOKEN = ''
CHAT_ID = ''
# 可选项
proxy = {
"http": "http://127.0.0.1:1234",
"https": "http://127.0.0.1:1234"
}
telegram = Ntelegram.TelegramNotify(TOKEN, CHAT_ID)
# https://core.telegram.org/bots/api#formatting-options
telegram.send_msg("test message", Ntelegram.ParseMode.TEXT) # 无代理
telegram.send_msg("test message", Ntelegram.ParseMode.TEXT, proxy=proxy) # 有代理
telegram.send_msg("[link](https://www.example.com)", Ntelegram.ParseMode.Markdown)
telegram.send_msg("<a href='https://www.example.com'>link</a>", Ntelegram.ParseMode.HTML)
telegram.send_photo("test.png","test")
telegram.send_file("test.txt", "test")
from ANotify import Nemail
# 邮箱服务器地址
MAIL_HOST = ''
# 用户名
MAIL_USER = ''
# 密码(部分邮箱为授权码)
MAIL_PASS = ''
# 邮件发送方邮箱地址
SENDER = ''
email_notify = Nemail.EmailNotify(MAIL_HOST, MAIL_USER, MAIL_PASS, SENDER)
email_notify.send_email("测试标题", "测试正文", attachment_filename=None, receiver='123@example.com')
Resend
from ANotify import Nresend
# 发件地址
FROM_ADDR = 'from@example.com'
# 收件地址
TO_ADDR = 'to@example.com'
# API Key
API_KEY = ''
# 主题
SUBJECT = 'TEST EMAIL'
# 邮件正文(html格式)
HTML = '<h1>This is a test email</h1>'
resend = Nresend.ResendNotify(API_KEY)
resend.send_email(FROM_ADDR, TO_ADDR, SUBJECT, HTML)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
anotify-0.2.2.tar.gz
(12.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
anotify-0.2.2-py3-none-any.whl
(18.5 kB
view details)
File details
Details for the file anotify-0.2.2.tar.gz.
File metadata
- Download URL: anotify-0.2.2.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd3121526a68d5078f9577f280640b6562d8a50de7daae6be4d73103ea76335f
|
|
| MD5 |
ce1a4bc71183990627daf6699a695b35
|
|
| BLAKE2b-256 |
b4ae3003897986ef95708c90563ad47df6c40134635aa8c797f03464a3f8f81b
|
File details
Details for the file anotify-0.2.2-py3-none-any.whl.
File metadata
- Download URL: anotify-0.2.2-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eedbb9bbae46bbd0d9099b166f1713fd4e3e284c6c517ce32403e7c5ad1e59d0
|
|
| MD5 |
37d4a66b907c63f6c6eb8d8276292cad
|
|
| BLAKE2b-256 |
744d615115597707dca332e38b7389415a246c5267a77ae6f3d5ab553bde16a5
|