lunarflu HF staff commited on
Commit
139364e
·
verified ·
1 Parent(s): d522acf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -2
app.py CHANGED
@@ -87,5 +87,40 @@ async def give_verified_roles():
87
  guild = bot.get_guild(879548962464493619)
88
  role = guild.get_role(900063512829755413)
89
 
90
- # Define the invite message
91
- org_link = "https://huggingface.co/organizations/discord-community/share/wPKRAHYbAlaEaCxUxcq
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  guild = bot.get_guild(879548962464493619)
88
  role = guild.get_role(900063512829755413)
89
 
90
+ org_link = "https://huggingface.co/organizations/discord-community/share/wPKRAHYbAlaEaCxUxcqVyaaaeZcYagDvqc"
91
+ invite_message = "Click to join our community org on the HF Hub!"
92
+
93
+ await guild.chunk()
94
+
95
+ for index, row in global_df.iterrows():
96
+ hf_user_name = row['hf_user_name']
97
+ if pd.notna(hf_user_name) and hf_user_name.lower() != 'n/a':
98
+ discord_id = row['discord_user_id'].strip('L')
99
+ member = guild.get_member(int(discord_id))
100
+ if not member:
101
+ continue
102
+ if role not in member.roles:
103
+ await member.add_roles(role)
104
+ await asyncio.sleep(5)
105
+ print(f"Role added to member: {member}")
106
+ lunar = bot.get_user(811235357663297546)
107
+ if lunar:
108
+ await lunar.send(f"Verified role given to {member}!")
109
+ await member.send(
110
+ f"Verification successful! [{member} <---> {row['discord_user_name']}] \n🤗 {org_link} {invite_message}"
111
+ )
112
+ await asyncio.sleep(5)
113
+
114
+ except Exception as e:
115
+ print(f"Error encountered: {e}")
116
+ await asyncio.sleep(30)
117
+
118
+ def run_bot():
119
+ bot.run(DISCORD_TOKEN)
120
+
121
+ threading.Thread(target=run_bot).start()
122
+
123
+ def greet(name):
124
+ return "Hello " + name + "!"
125
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
126
+ demo.launch()