python - python电报机器人发件人过滤器
问题描述
我想创建一个处理程序,当具体用户(@exampleuser)发布包含单词列表中单词的消息时触发。
这就是我所做的:
dispatcher.add_handler(MessageHandler(Filters.regex(re.compile(r'*example word from the wordlist*', re.IGNORECASE)) and Filters.sender_chat(390077500)) , wordBan)
但它不起作用,但如果我只使用:dispatcher.add_handler(MessageHandler(Filters.sender_chat(*example user id*)) , wordBan)
它起作用,但不是在具体用户发送消息时触发,而是在任何用户发送消息时触发。
如何添加具体的用户过滤器
解决方案
利用
dispatcher.add_handler(MessageHandler(Filters.regex(re.compile(r'*example word from the wordlist*', re.IGNORECASE)) & Filters.sender_chat(390077500)) , wordBan)
您想使用&
和|
组成 PTB 过滤器。
推荐阅读
- ios - Siri INSearchForAccountsIntent 可以自定义帐户详细信息屏幕或阻止用户进入帐户详细信息屏幕吗?
- android - Android Studio arctic 在 Windows7 中无法运行 - AAPT2 错误
- r - Error in MEEM(object, conLin, control$niterEM) : Singularity in backsolve at level 0, block 1... Linear mixed model, nlme, R
- logging - 与其他用户连接时,是否可以在远程服务器上以 root 身份运行 RSYNC?
- javascript - 在 ORB-SLAM 中,找到输出随机值的平移向量
- docker - Nginx Docker 容器可以看到其他容器,但不能通过暴露的端口
- python - 如何在熊猫中将列与虚拟变量组合(一个输出)?
- excel - 从 VB.Net 应用程序复制 Excel 范围并粘贴到 word 使用多个时会导致 0x800A03EC 错误
- java - 如何调用从另一个类创建数组的方法?
- flutter - Flutter NestedScrollView header 用 TabBar 和 TabbarView 弹跳