File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 11
22from  discord .ext .commands  import  Cog 
3- from  sqlalchemy . orm  import  Session 
3+ from  config  import  DOMAIN_NAME 
44from  typing  import  Callable 
55
6- from  app .common .database .objects  import  DBUser 
6+ from  app .common .database .objects  import  DBUser ,  DBBeatmapset 
77from  app .common .database  import  users 
88from  app  import  session 
99
10+ import  hashlib 
1011import  asyncio 
1112import  app 
1213
@@ -26,6 +27,19 @@ def __init__(self) -> None:
2627    async  def  run_async (func : Callable , * args ):
2728        return  await  asyncio .get_event_loop ().run_in_executor (None , func , * args )
2829
30+     @staticmethod  
31+     def  avatar_url (user : DBUser ) ->  str :
32+         url  =  f"http://osu.{ DOMAIN_NAME }  /a/{ user .id }  " 
33+         url  +=  f"?c={ user .avatar_hash }  "  if  user .avatar_hash  else  "" 
34+         return  url 
35+ 
36+     @staticmethod  
37+     def  thumbnail_url (beatmapset : DBBeatmapset ) ->  str :
38+         update_hash  =  hashlib .md5 (f'{ beatmapset .last_update }  ' .encode ()).hexdigest ()
39+         url  =  f"http://osu.{ DOMAIN_NAME }  /mt/{ beatmapset .id }  " 
40+         url  +=  f"?c={ update_hash }  " 
41+         return  url 
42+ 
2943    async  def  resolve_user (self , discord_id : int ) ->  DBUser  |  None :
3044        return  await  self .run_async (
3145            users .fetch_by_discord_id ,
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments