@@ -16,7 +16,7 @@ def get_admins_username():
1616 return admins
1717
1818
19- def is_admin (bot , update ):
19+ def is_admin (update , context ):
2020 """Checks if the user is authorized as admin"""
2121 username = update .message .from_user .username
2222 authorized = get_admins_username ()
@@ -30,27 +30,27 @@ def is_admin(bot, update):
3030
3131
3232def admin_needed (f ):
33- def wrap (* args , ** kargs ):
33+ async def wrap (* args , ** kargs ):
3434 logger .info ('Admin nedeed wrapper' )
35- bot , update = args
35+ update , context = args
3636 if is_admin (* args ):
37- return f (* args )
37+ return await f (* args )
3838 else :
39- bot .send_message (
39+ await context . bot .send_message (
4040 chat_id = update .message .chat_id ,
4141 text = "No estas Autorizadx para hacer esta acción"
4242 )
4343 return wrap
4444
4545
46- def grant_admin (bot , update ):
46+ async def grant_admin (update , context ):
4747 username = update .message .from_user .username
4848 chat_id = update .message .chat_id
4949 text = update .message .text
5050
5151 parameters = text .split (' ' )
5252 if not len (parameters ) == 2 :
53- bot .send_message (chat_id = chat_id ,
53+ await context . bot .send_message (chat_id = chat_id ,
5454 text = 'Parametros incorrectos.' )
5555 return
5656
@@ -69,17 +69,17 @@ def grant_admin(bot, update):
6969 logger .error ('PYCAMP_BOT_MASTER_KEY env not set.' )
7070 rply_msg = 'Hay un problema en el servidor, avisale a un admin.'
7171
72- bot .send_message (chat_id = chat_id , text = rply_msg )
72+ await context . bot .send_message (chat_id = chat_id , text = rply_msg )
7373
7474
7575@admin_needed
76- def revoke_admin (bot , update ):
76+ async def revoke_admin (update , context ):
7777 chat_id = update .message .chat_id
7878 text = update .message .text
7979
8080 parameters = text .split (' ' )
8181 if not len (parameters ) == 2 :
82- bot .send_message (chat_id = chat_id ,
82+ await context . bot .send_message (chat_id = chat_id ,
8383 text = 'Parametros incorrectos.' )
8484 return
8585
@@ -88,11 +88,11 @@ def revoke_admin(bot, update):
8888 user = Pycampista .select ().where (Pycampista .username == fallen_admin )[0 ]
8989 user .admin = False
9090 user .save ()
91- bot .send_message (chat_id = chat_id ,
91+ await context . bot .send_message (chat_id = chat_id ,
9292 text = 'Un admin a caido --{}--.' .format (fallen_admin ))
9393
9494
95- def list_admins (bot , update ):
95+ async def list_admins (update , context ):
9696 chat_id = update .message .chat_id
9797
9898 admins = get_admins_username ()
@@ -102,10 +102,10 @@ def list_admins(bot, update):
102102 rply_msg += admin
103103 rply_msg += '\n '
104104
105- bot .send_message (chat_id = chat_id , text = rply_msg )
105+ await context . bot .send_message (chat_id = chat_id , text = rply_msg )
106106
107107
108- def set_handlers (updater ):
109- updater . dispatcher .add_handler (CommandHandler ('su' , grant_admin ))
110- updater . dispatcher .add_handler (CommandHandler ('degradar' , revoke_admin ))
111- updater . dispatcher .add_handler (CommandHandler ('admins' , list_admins ))
108+ def set_handlers (application ):
109+ application .add_handler (CommandHandler ('su' , grant_admin ))
110+ application .add_handler (CommandHandler ('degradar' , revoke_admin ))
111+ application .add_handler (CommandHandler ('admins' , list_admins ))
0 commit comments