本文整理汇总了Python中telegram.ext.Filters.chat方法的典型用法代码示例。如果您正苦于以下问题:Python Filters.chat方法的具体用法?Python Filters.chat怎么用?Python Filters.chat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类telegram.ext.Filters
的用法示例。
在下文中一共展示了Filters.chat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filters_chat_username
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import chat [as 别名]
def test_filters_chat_username(self, message):
assert not Filters.chat(username='chat')(message)
message.chat.username = 'chat'
assert Filters.chat(username='@chat')(message)
assert Filters.chat(username='chat')(message)
assert Filters.chat(username=['chat1', 'chat', 'chat2'])(message)
assert not Filters.chat(username=['@chat1', 'chat_2'])(message)
示例2: test_filters_chat_id
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import chat [as 别名]
def test_filters_chat_id(self, message):
assert not Filters.chat(chat_id=-1)(message)
message.chat.id = -1
assert Filters.chat(chat_id=-1)(message)
message.chat.id = -2
assert Filters.chat(chat_id=[-1, -2])(message)
assert not Filters.chat(chat_id=[-3, -4])(message)
示例3: test_filters_chat_username
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import chat [as 别名]
def test_filters_chat_username(self):
self.assertFalse(Filters.chat(username='chat')(self.message))
self.message.chat.username = 'chat'
self.assertTrue(Filters.chat(username='@chat')(self.message))
self.assertTrue(Filters.chat(username='chat')(self.message))
self.assertTrue(Filters.chat(username=['chat1', 'chat', 'chat2'])(self.message))
self.assertFalse(Filters.chat(username=['@chat1', 'chat_2'])(self.message))
示例4: test_filters_chat_id
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import chat [as 别名]
def test_filters_chat_id(self):
self.assertFalse(Filters.chat(chat_id=-1)(self.message))
self.message.chat.id = -1
self.assertTrue(Filters.chat(chat_id=-1)(self.message))
self.message.chat.id = -2
self.assertTrue(Filters.chat(chat_id=[-1, -2])(self.message))
self.assertFalse(Filters.chat(chat_id=-1)(self.message))
示例5: test_filters_chat
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import chat [as 别名]
def test_filters_chat(self):
with pytest.raises(ValueError, match='chat_id or username'):
Filters.chat(chat_id=-1, username='chat')
with pytest.raises(ValueError, match='chat_id or username'):
Filters.chat()
示例6: test_filters_chat
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import chat [as 别名]
def test_filters_chat(self):
with self.assertRaisesRegexp(ValueError, 'chat_id or username'):
Filters.chat(chat_id=-1, username='chat')
with self.assertRaisesRegexp(ValueError, 'chat_id or username'):
Filters.chat()