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