Captain Ezio commited on
Commit
474e825
·
1 Parent(s): 54fcb8e

Update flood.py

Browse files
Files changed (1) hide show
  1. Powers/plugins/flood.py +17 -15
Powers/plugins/flood.py CHANGED
@@ -42,15 +42,15 @@ action_kb = InlineKeyboardMarkup(
42
  [
43
  InlineKeyboardButton(
44
  "Mute 🔇",
45
- callback_data="mute"
46
  ),
47
  InlineKeyboardButton(
48
  "Ban 🚷",
49
- callback_data="ban"
50
  ),
51
  InlineKeyboardButton(
52
  "Kick",
53
- callback_data="kick"
54
  )
55
  ]
56
  ]
@@ -61,15 +61,15 @@ within_kb = InlineKeyboardMarkup(
61
  [
62
  InlineKeyboardButton(
63
  "5",
64
- callback_data="5"
65
  ),
66
  InlineKeyboardButton(
67
  "10",
68
- callback_data="10"
69
  ),
70
  InlineKeyboardButton(
71
  "15",
72
- callback_data="15"
73
  )
74
  ]
75
  ]
@@ -80,15 +80,15 @@ limit_kb = InlineKeyboardMarkup(
80
  [
81
  InlineKeyboardButton(
82
  "5",
83
- callback_data="l_5"
84
  ),
85
  InlineKeyboardButton(
86
  "10",
87
- callback_data="l_10"
88
  ),
89
  InlineKeyboardButton(
90
  "15",
91
- callback_data="l_15"
92
  )
93
  ]
94
  ]
@@ -164,7 +164,7 @@ async def flood_set(c: Gojo, m: Message):
164
  await m.reply_text("**Usage:**\n `/setflood on/off`")
165
  return
166
 
167
- @Gojo.on_callback_query()
168
  async def callbacks(c: Gojo, q: CallbackQuery):
169
  data = q.data
170
  if data == "close":
@@ -180,15 +180,16 @@ async def callbacks(c: Gojo, q: CallbackQuery):
180
  user = q.from_user.id
181
  user_status = (await q.message.chat.get_member(q.from_user.id)).status
182
  if user in SUPPORT_STAFF or user_status in [CMS.OWNER, CMS.ADMINISTRATOR]:
183
- if data in ["mute", "ban", "kick"]:
184
- Flood.save_flood(c_id, slimit, swithin, data)
 
185
  await q.answer("Updated action", show_alert=True)
186
  await q.edit_message_caption(
187
  f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
188
  reply_markup=limit_kb
189
  )
190
  return
191
- if data in ["l_5", "l_10", "l_15"]:
192
  change = int(data.split("_")[1])
193
  Flood.save_flood(c_id, change, swithin, saction)
194
  await q.answer("Updated limit", show_alert=True)
@@ -197,7 +198,8 @@ async def callbacks(c: Gojo, q: CallbackQuery):
197
  reply_markup=within_kb
198
  )
199
  return
200
- if data in ["5", "10", "15"]:
 
201
  change = int(data)
202
  Flood.save_flood(c_id, slimit, change, saction)
203
  await q.answer("Updated", show_alert=True)
@@ -415,7 +417,7 @@ async def flood_watcher(c: Gojo, m: Message):
415
  return
416
 
417
 
418
- __PLUGIN__ = "anti-flood"
419
  __alt_name__ = [
420
  "anit-flood",
421
  "flood",
 
42
  [
43
  InlineKeyboardButton(
44
  "Mute 🔇",
45
+ callback_data="f_mute"
46
  ),
47
  InlineKeyboardButton(
48
  "Ban 🚷",
49
+ callback_data="f_ban"
50
  ),
51
  InlineKeyboardButton(
52
  "Kick",
53
+ callback_data="f_kick"
54
  )
55
  ]
56
  ]
 
61
  [
62
  InlineKeyboardButton(
63
  "5",
64
+ callback_data="f_f_5"
65
  ),
66
  InlineKeyboardButton(
67
  "10",
68
+ callback_data="f_f_10"
69
  ),
70
  InlineKeyboardButton(
71
  "15",
72
+ callback_data="f_f_15"
73
  )
74
  ]
75
  ]
 
80
  [
81
  InlineKeyboardButton(
82
  "5",
83
+ callback_data="f_5"
84
  ),
85
  InlineKeyboardButton(
86
  "10",
87
+ callback_data="f_10"
88
  ),
89
  InlineKeyboardButton(
90
  "15",
91
+ callback_data="f_15"
92
  )
93
  ]
94
  ]
 
164
  await m.reply_text("**Usage:**\n `/setflood on/off`")
165
  return
166
 
167
+ @Gojo.on_callback_query(filters.regex("^f_"))
168
  async def callbacks(c: Gojo, q: CallbackQuery):
169
  data = q.data
170
  if data == "close":
 
180
  user = q.from_user.id
181
  user_status = (await q.message.chat.get_member(q.from_user.id)).status
182
  if user in SUPPORT_STAFF or user_status in [CMS.OWNER, CMS.ADMINISTRATOR]:
183
+ if data in ["f_mute", "f_ban", "f_kick"]:
184
+ change = int(data.split("_")[1])
185
+ Flood.save_flood(c_id, slimit, swithin, change)
186
  await q.answer("Updated action", show_alert=True)
187
  await q.edit_message_caption(
188
  f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
189
  reply_markup=limit_kb
190
  )
191
  return
192
+ if data in ["f_5", "f_10", "f_15"]:
193
  change = int(data.split("_")[1])
194
  Flood.save_flood(c_id, change, swithin, saction)
195
  await q.answer("Updated limit", show_alert=True)
 
198
  reply_markup=within_kb
199
  )
200
  return
201
+ if data in ["f_f_5", "f_f_10", "f_f_15"]:
202
+ data = data.split("_")[-1]
203
  change = int(data)
204
  Flood.save_flood(c_id, slimit, change, saction)
205
  await q.answer("Updated", show_alert=True)
 
417
  return
418
 
419
 
420
+ __PLUGIN__ = "flood"
421
  __alt_name__ = [
422
  "anit-flood",
423
  "flood",