global
statement detected PYL-W0603 49 if event.fwd_from:
50 return
51 global USER_AFK
52 global afk_time 53 global last_afk_message
54 global reason
55 USER_AFK = {}
90 if event.fwd_from:
91 return
92 global USER_AFK
93 global afk_time 94 global last_afk_message
95 afk_since = "yakın bir zaman"
96 current_message_text = event.message.message.lower()
50 return
51 global USER_AFK
52 global afk_time
53 global last_afk_message 54 global reason
55 USER_AFK = {}
56 afk_time = datetime.datetime.now()
19
20@bot.on(events.NewMessage(outgoing=True))
21async def set_not_afk(event):
22 global USER_AFK 23 global afk_time
24 global last_afk_message
25 me = await bot.get_me()
20@bot.on(events.NewMessage(outgoing=True))
21async def set_not_afk(event):
22 global USER_AFK
23 global afk_time 24 global last_afk_message
25 me = await bot.get_me()
26 if me.id != event.sender_id:
It is recommended not to use global
statement unless it is really necessary. Global variables are dangerous because they can be simultaneously accessed from multiple sections of a program. This frequently results in bugs. This also make code difficult to read, because they force you to search through multiple functions or even modules just to understand all the different locations where the global variable is used and modified. Read more about why it should be avoided here.