File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed
ptbcontrib/true_reply_filter Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 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+ ]
Original file line number Diff line number Diff line change 1+ python-telegram-bot >= 20.0
Original file line number Diff line number Diff line change 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" )
You can’t perform that action at this time.
0 commit comments