lunarflu HF staff commited on
Commit
a12522f
1 Parent(s): 6ff2a08

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -36,16 +36,26 @@ async def on_message(message):
36
  try:
37
  global number_of_messages
38
  if message.author != bot.user:
39
- user = bot.get_user(811235357663297546) #811235357663297546
 
 
40
  number_of_messages = number_of_messages + 1
41
  message_link = f"[#{message.channel.name}]({message.jump_url})"
42
- dm_message = await user.send(f"{number_of_messages}| {message_link} |{message.author}: {message.content}")
43
-
44
-
45
-
46
-
47
-
48
- ### antispam experiment
 
 
 
 
 
 
 
 
49
  cooldown_duration = 3 # messages per n seconds, was 1, now 3, could try 5
50
  if message.author.id not in user_cooldowns:
51
  user_cooldowns[message.author.id] = {'count': 1, 'timestamp': message.created_at}
@@ -89,11 +99,6 @@ async def on_message(message):
89
  """
90
  user_cooldowns[message.author.id]['timestamp'] = message.created_at
91
 
92
-
93
-
94
-
95
-
96
- # Allow other event handlers to process the message
97
  await bot.process_commands(message)
98
 
99
  except Exception as e:
 
36
  try:
37
  global number_of_messages
38
  if message.author != bot.user:
39
+ lunarflu = bot.get_user(811235357663297546) #811235357663297546
40
+
41
+ """Backup"""
42
  number_of_messages = number_of_messages + 1
43
  message_link = f"[#{message.channel.name}]({message.jump_url})"
44
+ dm_message = await lunarflu.send(f"{number_of_messages}| {message_link} |{message.author}: {message.content}")
45
+
46
+ """Antispam"""
47
+ #Detecting certain unwanted strings
48
+ try:
49
+ forbidden_strings = ["@everyone", "@here", "discord.gg", "discord.com/invite", "discord.com", "discord-premium"]
50
+ if any(string.lower() in message.content.lower() for string in forbidden_strings):
51
+ ignored_role_ids = [897381378172264449, 897376942817419265] #admins, huggingfolks
52
+ if any(role.id in ignored_role_ids for role in message.author.roles):
53
+ return
54
+ dm_unwanted = await lunarflu.send(f"FORBIDDEN STRING: {message_link} |{message.author}: {message.content}")
55
+ except Exception as e:
56
+ print(f"Antispam->Detecting certain unwanted strings Error: {e}")
57
+
58
+ #Posting too fast
59
  cooldown_duration = 3 # messages per n seconds, was 1, now 3, could try 5
60
  if message.author.id not in user_cooldowns:
61
  user_cooldowns[message.author.id] = {'count': 1, 'timestamp': message.created_at}
 
99
  """
100
  user_cooldowns[message.author.id]['timestamp'] = message.created_at
101
 
 
 
 
 
 
102
  await bot.process_commands(message)
103
 
104
  except Exception as e: