app.extern.wechat module

wechat.py

集合了本应用需要发送到微信的函数

调用提示

函数可以假设是异步IO,参数符合条件时不抛出异常 由于异步假设,函数只返回尝试状态,即是否设置了定时任务,不保证成功发送

app.extern.wechat.WechatApp

Apps 的别名

app.extern.wechat.WechatMessageLevel

Levels 的别名

app.extern.wechat.publish_notification(notification_or_id, show_source=True, app=None, level=None)[源代码]

根据单个通知或id(实际是主键)向通知的receiver发送 别创建了好多通知然后循环调用这个,批量发送用publish_notifications - show_source: bool, 显示消息来源 默认显示 - app: str | WechatApp宏, 确定发送的应用 请推广类消息务必注意 - level: int | WechatMessageLevel宏, 用于筛选用户 推广类消息可以不填

app.extern.wechat.publish_notifications(notifications_or_ids=None, filter_kws=None, exclude_kws=None, show_source=True, app=None, level=None, *, check=True) bool[源代码]

批量发送通知,选取筛选后范围内所有与最新通知发送者等相同、且内容结尾一致的通知 如果能保证这些通知全都一致,可以要求不检查

Argument

  • notifications_or_ids: QuerySet | List or Tuple[notification with id] |

    Iter[id] | None, 通知基本范围, 别问参数类型为什么这么奇怪,问就是django不统一

  • filter_kws: dict | None, 这些参数将被直接传递给filter函数

  • exclude_kws: dict | None, 这些参数将被直接传递给exclude函数

  • 以上参数不能都为空

  • show_source: bool, 显示消息来源 默认显示

  • app: str | WechatApp宏, 确定发送的应用 请推广类消息务必注意

  • level: int | WechatMessageLevel宏, 用于筛选用户 推广类消息可以不填

Keyword-Only

  • check: bool, default=True, 是否检查最终筛选结果的相关性

returns:

- success

rtype:

bool, 是否尝试了发送,出错时返回False