Captain Ezio commited on
Commit
f872943
·
1 Parent(s): cc7b19b

Update flood.py

Browse files

will resolve the error `RuntimeError`

Files changed (1) hide show
  1. Powers/plugins/flood.py +10 -8
Powers/plugins/flood.py CHANGED
@@ -350,15 +350,17 @@ async def flood_watcher(c: Gojo, m: Message):
350
  if not len(dic):
351
  z = {c_id : {u_id : [[],[]]}}
352
  dic.update(z)
353
- for i in dic.keys():
354
- if c_id != i:
355
- z = {c_id : {u_id : [[],[]]}}
356
- dic.update(z)
 
357
 
358
- for i in dic[c_id].keys():
359
- if u_id != i:
360
- z = {u_id : [[],[]]}
361
- dic[c_id].update(z) # make the dic something like {c_id : {u_id : [[for time],[for msg]]}}
 
362
  sec = round(time.time())
363
  try:
364
  dic[c_id][u_id][0].append(sec)
 
350
  if not len(dic):
351
  z = {c_id : {u_id : [[],[]]}}
352
  dic.update(z)
353
+ try:
354
+ dic[c_id] # access and check weather the c_id present or not
355
+ except KeyError:
356
+ z = {c_id : {u_id : [[],[]]}}
357
+ dic.update(z)
358
 
359
+ try:
360
+ dic[c_id][u_id]
361
+ except KeyError:
362
+ z = {u_id : [[],[]]}
363
+ dic[c_id].update(z) # make the dic something like {c_id : {u_id : [[for time],[for msg]]}}
364
  sec = round(time.time())
365
  try:
366
  dic[c_id][u_id][0].append(sec)