Skip to main content

Work wechat log notify.

Project description

Work wechat log notify.

WorkWechatLog(webhook_urls: str | List[str], mode: bool) 企业微信日志类

  • webhook_urls {str|List[str]} webhook链接地址,可传字符串或者字符串列表
  • mode {bool} 是否测试模式,测试模式使用print输出 True: 测试模式 False: 生产模式

example:

log = WorkWechatLog("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", False)
# 或
log = WorkWechatLog(
  [
    "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  ],
  False
)

text(msg: str, mentioned_list: List[str], mentioned_mobile_list: List[str]) 发送文本消息

  • msg {str} 文本内容,最长不超过2048个字节,必须是utf8编码
  • mentioned_list {List[str]} userid的列表,提醒群中的指定成员(@某个成员),@all表示提醒所有人,如果开发者获取不到userid,可以使用mentioned_mobile_list
  • mentioned_mobile_list {List[str]} 手机号列表,提醒手机号对应的群成员(@某个成员),@all表示提醒所有人
  • returns {None}

example:

from work_wechat_log.log import WorkWechatLog

log = WorkWechatLog(webhook_urls, False)
log.text("haha", ["@all"])

markdown(msg: str) 发送markdown消息

  • msg {str} 文本内容,最长不超过2048个字节,必须是utf8编码
  • mentioned_list {List[str]} userid的列表,提醒群中的指定成员(@某个成员),@all表示提醒所有人,如果开发者获取不到userid,可以使用mentioned_mobile_list
  • mentioned_mobile_list {List[str]} 手机号列表,提醒手机号对应的群成员(@某个成员),@all表示提醒所有人
  • returns {None}

example:

from work_wechat_log.log import WorkWechatLog

log = WorkWechatLog(webhook_urls, False)
log.markdown("###实时新增用户反馈<font color=\"warning\">132例</font>")

image(image_path: str) 发送图片消息

  • image_path {str} 图片地址,图片最大不能超过2M
  • returns {None}

example:

from work_wechat_log.log import WorkWechatLog

log = WorkWechatLog(webhook_urls, False)
log.image("./tmp/test.png")

table(table: TableType, headers: TableHeadersType = (), tablefmt: TableFmtType = "simple") 发送表格消息

测试模式使用tabulate输出表格,生产模式会转化为image发送

example:

from work_wechat_log.log import WorkWechatLog

log = WorkWechatLog(webhook_urls, False)
table = [["spam",42],["eggs",451],["bacon",0]]
headers = ["item", "qty"]
log.table(table, headers, "simple_grid")

file(file_path: str) 发送文件消息

  • file_path {str} 文件地址,要求文件大小在5B~20M之间
  • returns {None}

example:

from work_wechat_log.log import WorkWechatLog

log = WorkWechatLog(webhook_urls, False)
log.file("./tmp/test.pdf")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

work_wechat_log_notify-0.2.2.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

work_wechat_log_notify-0.2.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file work_wechat_log_notify-0.2.2.tar.gz.

File metadata

  • Download URL: work_wechat_log_notify-0.2.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for work_wechat_log_notify-0.2.2.tar.gz
Algorithm Hash digest
SHA256 0f2bc19ce6863cbd28ef979120c7e5650fa768a58126c21587941aab8129cb3e
MD5 7c17e9e0be35f4fbba5336fa5b20421b
BLAKE2b-256 7d94eae3458217bf0804e839f3ca0df519002d5e21319b3833459c022a566ee4

See more details on using hashes here.

File details

Details for the file work_wechat_log_notify-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for work_wechat_log_notify-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c1e58363d57e1cb075b4a2fee1ff9f9903c1a185275574accafaec96d19c603a
MD5 811f6fcb2ab9c04e8b698dd8010a4069
BLAKE2b-256 2f61cd7afd217dae36c4363ea8f062bdee0d1e5c6afed043369a13c06ec43549

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page