6
6
ParseMode ,
7
7
Bot ,
8
8
Update ,
9
- BotCommandScopeAllPrivateChats ,
10
- BotCommandScopeChat ,
11
- BotCommandScopeAllGroupChats ,
12
- BotCommandScopeChatAdministrators ,
13
9
)
14
10
from telegram .error import BadRequest ,Unauthorized
15
11
from telegram .ext import (
16
- CommandHandler ,
17
12
Updater ,
18
13
MessageHandler ,
19
14
Filters ,
20
15
Defaults ,
21
- ChatMemberHandler ,
22
16
InlineQueryHandler ,
23
- CallbackQueryHandler ,
24
17
)
25
18
26
19
from components import inlinequeries
27
20
from components .callbacks import (
28
- start ,
29
- rules ,
30
- docs ,
31
- wiki ,
32
- help_callback ,
33
- off_on_topic ,
34
- sandwich ,
35
21
reply_search ,
36
- delete_new_chat_members_message ,
37
- greet_new_chat_members ,
38
- tag_hint ,
39
- say_potato_command ,
40
- say_potato_button ,
41
- ban_sender_channels ,
42
22
)
43
- from components .errorhandler import error_handler
44
23
from components .const import (
45
24
OFFTOPIC_RULES ,
46
- OFFTOPIC_USERNAME ,
47
25
ONTOPIC_RULES ,
48
- ONTOPIC_USERNAME ,
49
26
ONTOPIC_RULES_MESSAGE_ID ,
50
27
OFFTOPIC_RULES_MESSAGE_ID ,
51
28
ONTOPIC_CHAT_ID ,
52
29
OFFTOPIC_CHAT_ID ,
53
30
)
54
- from components .taghints import TagHintFilter
55
- from components .util import (
56
- rate_limit_tracker ,
57
- build_command_list ,
58
- )
31
+ from components .errorhandler import error_handler
59
32
from components .github import github_issues
60
33
61
34
if os .environ .get ("ROOLSBOT_DEBUG" ):
@@ -102,63 +75,63 @@ def main() -> None:
102
75
103
76
# Note: Order matters!
104
77
105
- dispatcher .add_handler (MessageHandler (~ Filters .command ,rate_limit_tracker ),group = - 1 )
106
- dispatcher .add_handler (
107
- MessageHandler (
108
- Filters .sender_chat .channel & ~ Filters .is_automatic_forward ,ban_sender_channels
109
- )
110
- )
111
-
112
- # Simple commands
113
- # The first one also handles deep linking /start commands
114
- dispatcher .add_handler (CommandHandler ("start" ,start ))
115
- dispatcher .add_handler (CommandHandler ("rules" ,rules ))
116
- dispatcher .add_handler (CommandHandler ("docs" ,docs ))
117
- dispatcher .add_handler (CommandHandler ("wiki" ,wiki ))
118
- dispatcher .add_handler (CommandHandler ("help" ,help_callback ))
119
-
120
- # Stuff that runs on every message with regex
121
- dispatcher .add_handler (
122
- MessageHandler (
123
- Filters .regex (r"(?i)[\s\S]*?((sudo )?make me a sandwich)[\s\S]*?" ),sandwich
124
- )
125
- )
126
- dispatcher .add_handler (MessageHandler (Filters .regex ("/(on|off)_topic" ),off_on_topic ))
127
-
128
- # Tag hints - works with regex
129
- dispatcher .add_handler (MessageHandler (TagHintFilter (),tag_hint ))
78
+ # dispatcher.add_handler(MessageHandler(~Filters.command, rate_limit_tracker), group=-1)
79
+ # dispatcher.add_handler(
80
+ # MessageHandler(
81
+ # Filters.sender_chat.channel & ~Filters.is_automatic_forward, ban_sender_channels
82
+ # )
83
+ # )
84
+
85
+ ## Simple commands
86
+ ## The first one also handles deep linking /start commands
87
+ # dispatcher.add_handler(CommandHandler("start", start))
88
+ # dispatcher.add_handler(CommandHandler("rules", rules))
89
+ # dispatcher.add_handler(CommandHandler("docs", docs))
90
+ # dispatcher.add_handler(CommandHandler("wiki", wiki))
91
+ # dispatcher.add_handler(CommandHandler("help", help_callback))
92
+
93
+ ## Stuff that runs on every message with regex
94
+ # dispatcher.add_handler(
95
+ # MessageHandler(
96
+ # Filters.regex(r"(?i)[\s\S]*?((sudo )?make me a sandwich)[\s\S]*?"), sandwich
97
+ # )
98
+ # )
99
+ # dispatcher.add_handler(MessageHandler(Filters.regex("/(on|off)_topic"), off_on_topic))
100
+
101
+ ## Tag hints - works with regex
102
+ # dispatcher.add_handler(MessageHandler(TagHintFilter(), tag_hint))
130
103
131
104
# We need several matches so Filters.regex is basically useless
132
105
# therefore we catch everything and do regex ourselves
133
106
dispatcher .add_handler (
134
107
MessageHandler (Filters .text & Filters .update .messages & ~ Filters .command ,reply_search )
135
108
)
136
109
137
- # Status updates
138
- dispatcher .add_handler (
139
- ChatMemberHandler (greet_new_chat_members ,chat_member_types = ChatMemberHandler .CHAT_MEMBER )
140
- )
141
- dispatcher .add_handler (
142
- MessageHandler (
143
- Filters .chat (username = [ONTOPIC_USERNAME ,OFFTOPIC_USERNAME ])
144
- & Filters .status_update .new_chat_members ,
145
- delete_new_chat_members_message ,
146
- ),
147
- group = 1 ,
148
- )
110
+ ## Status updates
111
+ # dispatcher.add_handler(
112
+ # ChatMemberHandler(greet_new_chat_members, chat_member_types=ChatMemberHandler.CHAT_MEMBER)
113
+ # )
114
+ # dispatcher.add_handler(
115
+ # MessageHandler(
116
+ # Filters.chat(username=[ONTOPIC_USERNAME, OFFTOPIC_USERNAME])
117
+ # & Filters.status_update.new_chat_members,
118
+ # delete_new_chat_members_message,
119
+ # ),
120
+ # group=1,
121
+ # )
149
122
150
123
# Inline Queries
151
124
dispatcher .add_handler (InlineQueryHandler (inlinequeries .inline_query ))
152
125
153
- # Captcha for userbots
154
- dispatcher .add_handler (
155
- CommandHandler (
156
- "say_potato" ,
157
- say_potato_command ,
158
- filters = Filters .chat (username = [ONTOPIC_USERNAME ,OFFTOPIC_USERNAME ]),
159
- )
160
- )
161
- dispatcher .add_handler (CallbackQueryHandler (say_potato_button ,pattern = "^POTATO" ))
126
+ ## Captcha for userbots
127
+ # dispatcher.add_handler(
128
+ # CommandHandler(
129
+ # "say_potato",
130
+ # say_potato_command,
131
+ # filters=Filters.chat(username=[ONTOPIC_USERNAME, OFFTOPIC_USERNAME]),
132
+ # )
133
+ # )
134
+ # dispatcher.add_handler(CallbackQueryHandler(say_potato_button, pattern="^POTATO"))
162
135
163
136
# Error Handler
164
137
dispatcher .add_error_handler (error_handler )
@@ -176,25 +149,25 @@ def main() -> None:
176
149
github_issues .init_ptb_contribs (dispatcher .job_queue )# type: ignore[arg-type]
177
150
github_issues .init_issues (dispatcher .job_queue )# type: ignore[arg-type]
178
151
179
- # set commands
180
- updater .bot .set_my_commands (
181
- build_command_list (private = True ),
182
- scope = BotCommandScopeAllPrivateChats (),
183
- )
184
- updater .bot .set_my_commands (
185
- build_command_list (private = False ),
186
- scope = BotCommandScopeAllGroupChats (),
187
- )
188
-
189
- for group_name in [ONTOPIC_CHAT_ID ,OFFTOPIC_CHAT_ID ]:
190
- updater .bot .set_my_commands (
191
- build_command_list (private = False ,group_name = group_name ),
192
- scope = BotCommandScopeChat (group_name ),
193
- )
194
- updater .bot .set_my_commands (
195
- build_command_list (private = False ,group_name = group_name ,admins = True ),
196
- scope = BotCommandScopeChatAdministrators (group_name ),
197
- )
152
+ ## set commands
153
+ # updater.bot.set_my_commands(
154
+ # build_command_list(private=True),
155
+ # scope=BotCommandScopeAllPrivateChats(),
156
+ # )
157
+ # updater.bot.set_my_commands(
158
+ # build_command_list(private=False),
159
+ # scope=BotCommandScopeAllGroupChats(),
160
+ # )
161
+ #
162
+ # for group_name in [ONTOPIC_CHAT_ID, OFFTOPIC_CHAT_ID]:
163
+ # updater.bot.set_my_commands(
164
+ # build_command_list(private=False, group_name=group_name),
165
+ # scope=BotCommandScopeChat(group_name),
166
+ # )
167
+ # updater.bot.set_my_commands(
168
+ # build_command_list(private=False, group_name=group_name, admins=True),
169
+ # scope=BotCommandScopeChatAdministrators(group_name),
170
+ # )
198
171
199
172
updater .idle ()
200
173