Skip to content

Commit d110972

Browse files
committed
feat: Add true reply filter
1 parent dba9ac3 commit d110972

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# A library containing community-based extension for the python-telegram-bot library
2+
# Copyright (C) 2020-2026
3+
# The ptbcontrib developers
4+
#
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU Lesser Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU Lesser Public License for more details.
14+
#
15+
# You should have received a copy of the GNU Lesser Public License
16+
# along with this program. If not, see [http://www.gnu.org/licenses/].
17+
"""
18+
This module contains a filter that filters correctly in a group with topics.
19+
"""
20+
21+
from .true_reply_filter import TRUE_REPLY_FILTER
22+
23+
__all__ = [
24+
"TRUE_REPLY_FILTER",
25+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-telegram-bot>=20.0
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from telegram import Message
2+
from telegram.ext.filters import MessageFilter
3+
4+
5+
class _Reply(MessageFilter):
6+
__slots__ = ()
7+
8+
def filter(self, message: Message) -> bool:
9+
if not message.reply_to_message:
10+
return False
11+
if (
12+
message.is_topic_message
13+
and message.message_thread_id == message.reply_to_message.message_id
14+
):
15+
return False
16+
return True
17+
18+
19+
TRUE_REPLY_FILTER = _Reply(name="true_reply_filter.REPLY")

0 commit comments

Comments
 (0)