Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
removing role assignment bits from verification process; can add separately on a timer
Browse files
app.py
CHANGED
@@ -94,16 +94,7 @@ async def send_button(ctx):
|
|
94 |
def generate_unique_string(length=6):
|
95 |
return secrets.token_hex(length // 2)
|
96 |
|
97 |
-
|
98 |
-
async def fetch_all_members(guild):
|
99 |
-
members = []
|
100 |
-
async for member in guild.fetch_members(limit=None):
|
101 |
-
members.append(member)
|
102 |
-
print(f"Fetched {len(members)} members.")
|
103 |
-
return members
|
104 |
-
|
105 |
|
106 |
-
|
107 |
@bot.event
|
108 |
async def on_ready():
|
109 |
try:
|
@@ -112,9 +103,6 @@ async def on_ready():
|
|
112 |
print(f'Logged in as {bot.user.name}')
|
113 |
print(f"XP_PER_MESSAGE: {XP_PER_MESSAGE}")
|
114 |
|
115 |
-
server = bot.get_guild(879548962464493619)
|
116 |
-
await fetch_all_members(server)
|
117 |
-
|
118 |
channel = bot.get_channel(900125909984624713)
|
119 |
if channel:
|
120 |
try:
|
@@ -821,38 +809,6 @@ def create_plot(username, year):
|
|
821 |
|
822 |
return fig
|
823 |
#-------------------------------------------------------------------------------------------------------------------------------
|
824 |
-
async def add_verified_role_to_member(member, role):
|
825 |
-
await member.add_roles(role)
|
826 |
-
|
827 |
-
|
828 |
-
def add_verified_role(member, role):
|
829 |
-
loop = asyncio.get_event_loop()
|
830 |
-
loop.run_until_complete(add_role_to_member(member, role))
|
831 |
-
|
832 |
-
|
833 |
-
async def send_lunar_verification_logs(lunar, member, username):
|
834 |
-
org_link = "https://huggingface.co/organizations/discord-community/share/wPKRAHYbAlaEaCxUxcqVyaaaeZcYagDvqc"
|
835 |
-
invite_message = "Click to join our community org on the HF Hub!"
|
836 |
-
await lunar.send(f"Verification successful! [{member} <---> {username}] \nπ€ {invite_message}\n{org_link} ")
|
837 |
-
|
838 |
-
def send_lunar_verification_logs_def(lunar, member, username):
|
839 |
-
loop = asyncio.get_event_loop()
|
840 |
-
loop.run_until_complete(send_lunar_verification_logs(lunar, member, username))
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
async def get_member_async(user_id, server):
|
847 |
-
member = await server.fetch_member(user_id)
|
848 |
-
return member
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
def get_member_def(user_id, server):
|
853 |
-
loop = asyncio.get_event_loop()
|
854 |
-
return loop.run_until_complete(get_member_async(user_id, server))
|
855 |
-
|
856 |
|
857 |
def verify_button(profile: gr.OAuthProfile | None, request: gr.Request) -> str:
|
858 |
url_str = str(request.url)
|
@@ -873,31 +829,11 @@ def verify_button(profile: gr.OAuthProfile | None, request: gr.Request) -> str:
|
|
873 |
if profile is None:
|
874 |
return f"# β Not logged in with Hugging Face yet."
|
875 |
|
876 |
-
server = bot.get_guild(879548962464493619)
|
877 |
-
print(f"server={server}")
|
878 |
-
role = server.get_role(900063512829755413)
|
879 |
-
member = server.get_member(user_id)
|
880 |
-
print(f"member={member}")
|
881 |
-
verified_date = datetime.now().strftime("%m/%d/%Y, %H:%M:%S")
|
882 |
-
likes = 0
|
883 |
-
models = 0
|
884 |
-
datasets = 0
|
885 |
-
spaces = 0
|
886 |
-
discussions = 0
|
887 |
-
papers = 0
|
888 |
-
upvotes = 0
|
889 |
-
|
890 |
-
# do they have the verified role already?
|
891 |
-
if role in member.roles:
|
892 |
-
return (f" β {member} already has has the '{role}' role! To change discord accounts or HF accounts, contact @lunarflu on discord or [email protected]")
|
893 |
-
|
894 |
-
|
895 |
# check if hf_user_name in dataframe:
|
896 |
if profile.username in global_df['hf_user_name'].values:
|
897 |
return (f"The HF account {profile.username} is already verified! To change discord accounts or HF accounts, contact @lunarflu or [email protected]")
|
898 |
|
899 |
# check if discord_user_id in dataframe:
|
900 |
-
lunar = bot.get_user(811235357663297546)
|
901 |
altered_member_id = "L" + str(member.id) + "L"
|
902 |
if altered_member_id in global_df['discord_user_id'].values:
|
903 |
|
@@ -907,12 +843,10 @@ def verify_button(profile: gr.OAuthProfile | None, request: gr.Request) -> str:
|
|
907 |
# empty (no link created yet between discord_user_id and hf_user_name) so we can update
|
908 |
global_df.loc[global_df['discord_user_id'] == altered_member_id, 'hf_user_name'] = profile.username
|
909 |
global_df.loc[global_df['discord_user_id'] == altered_member_id, 'verified_date'] = verified_date
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
send_lunar_verification_logs_def(lunar, member, profile.username)
|
915 |
-
print(f" β
Verification successful! [{member} <---> {profile.username}] π€")
|
916 |
else:
|
917 |
return (f" β The Discord account {member} is already verified! To change discord accounts or HF accounts, contact @lunarflu or [email protected]")
|
918 |
print(f"The Discord account {member} is already verified! To change discord accounts or HF accounts, contact @lunarflu or [email protected]")
|
|
|
94 |
def generate_unique_string(length=6):
|
95 |
return secrets.token_hex(length // 2)
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
|
|
98 |
@bot.event
|
99 |
async def on_ready():
|
100 |
try:
|
|
|
103 |
print(f'Logged in as {bot.user.name}')
|
104 |
print(f"XP_PER_MESSAGE: {XP_PER_MESSAGE}")
|
105 |
|
|
|
|
|
|
|
106 |
channel = bot.get_channel(900125909984624713)
|
107 |
if channel:
|
108 |
try:
|
|
|
809 |
|
810 |
return fig
|
811 |
#-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
812 |
|
813 |
def verify_button(profile: gr.OAuthProfile | None, request: gr.Request) -> str:
|
814 |
url_str = str(request.url)
|
|
|
829 |
if profile is None:
|
830 |
return f"# β Not logged in with Hugging Face yet."
|
831 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
832 |
# check if hf_user_name in dataframe:
|
833 |
if profile.username in global_df['hf_user_name'].values:
|
834 |
return (f"The HF account {profile.username} is already verified! To change discord accounts or HF accounts, contact @lunarflu or [email protected]")
|
835 |
|
836 |
# check if discord_user_id in dataframe:
|
|
|
837 |
altered_member_id = "L" + str(member.id) + "L"
|
838 |
if altered_member_id in global_df['discord_user_id'].values:
|
839 |
|
|
|
843 |
# empty (no link created yet between discord_user_id and hf_user_name) so we can update
|
844 |
global_df.loc[global_df['discord_user_id'] == altered_member_id, 'hf_user_name'] = profile.username
|
845 |
global_df.loc[global_df['discord_user_id'] == altered_member_id, 'verified_date'] = verified_date
|
846 |
+
org_link = "https://huggingface.co/organizations/discord-community/share/wPKRAHYbAlaEaCxUxcqVyaaaeZcYagDvqc"
|
847 |
+
invite_message = "Click to join our community org on the HF Hub!"
|
848 |
+
return (f" β
Verification successful! [{member} <---> {profile.username}] π€\n{invite_message}\n{org_link} ")
|
849 |
+
print(f" β
Verification successful! [{member} <---> {profile.username}] π€")
|
|
|
|
|
850 |
else:
|
851 |
return (f" β The Discord account {member} is already verified! To change discord accounts or HF accounts, contact @lunarflu or [email protected]")
|
852 |
print(f"The Discord account {member} is already verified! To change discord accounts or HF accounts, contact @lunarflu or [email protected]")
|