11from vrcpy .wss import AWSSClient
22import asyncio
3- import time
3+
4+ """
5+ 2 examples
6+
7+ 1. Class inheratence
8+ 2. Decorators
9+
10+ Remember you don't have to overwrite every event, just the ones you want to use!
11+ """
12+
13+ # Example 1
14+
415
516class AClient (AWSSClient ):
617 async def on_friend_location (self , friend , world , location , instance ):
718 print ("{} is now in {}." .format (friend .displayName ,
8- "a private world" if location == None else world .name ))
19+ "a private world" if location == None else world .name ))
920
1021 async def on_friend_offline (self , friend ):
1122 print ("{} went offline." .format (friend .displayName ))
@@ -26,7 +37,8 @@ async def on_friend_update(self, friend):
2637 print ("{} has updated their profile/account." .format (friend .displayName ))
2738
2839 async def on_notification (self , notification ):
29- print ("Got a {} notification from {}." .format (notification .type , notification .senderUsername ))
40+ print ("Got a {} notification from {}." .format (
41+ notification .type , notification .senderUsername ))
3042
3143 async def on_unhandled_event (self , event , content ):
3244 print ("Recieved unhandled event '{}'." .format (event ))
@@ -50,4 +62,78 @@ def __init__(self):
5062 except KeyboardInterrupt :
5163 asyncio .get_event_loop ().run_until_complete (self .logout ())
5264
65+
5366c = AClient ()
67+
68+ # Example 2
69+
70+ client = AWSSClient ()
71+
72+
73+ @client .event
74+ async def on_friend_location (friend , world , location , instance ):
75+ print ("{} is now in {}." .format (friend .displayName ,
76+ "a private world" if location == None else world .name ))
77+
78+
79+ @client .event
80+ async def on_friend_offline (friend ):
81+ print ("{} went offline." .format (friend .displayName ))
82+
83+
84+ @client .event
85+ async def on_friend_active (friend ):
86+ print ("{} is now {}." .format (friend .displayName , friend .state ))
87+
88+
89+ @client .event
90+ async def on_friend_online (friend ):
91+ print ("{} is now online." .format (friend .displayName ))
92+
93+
94+ @client .event
95+ async def on_friend_add (friend ):
96+ print ("{} is now your friend." .format (friend .displayName ))
97+
98+
99+ @client .event
100+ async def on_friend_delete (friend ):
101+ print ("{} is no longer your friend." .format (friend .displayName ))
102+
103+
104+ @client .event
105+ async def on_friend_update (friend ):
106+ print ("{} has updated their profile/account." .format (friend .displayName ))
107+
108+
109+ @client .event
110+ async def on_notification (notification ):
111+ print ("Got a {} notification from {}." .format (
112+ notification .type , notification .senderUsername ))
113+
114+
115+ @client .event
116+ async def on_unhandled_event (event , content ):
117+ print ("Recieved unhandled event '{}'." .format (event ))
118+
119+
120+ @client .event
121+ async def on_connect ():
122+ print ("Connected to wss pipeline." )
123+
124+
125+ @client .event
126+ async def on_disconnect ():
127+ print ("Disconnected from wss pipeline." )
128+
129+
130+ async def wait_loop ():
131+ await client .login2fa (input ("Username: " ), input ("Password: " ), input ("2FA Code: " ), True )
132+
133+ while True :
134+ await asyncio .sleep (1 )
135+
136+ try :
137+ asyncio .get_event_loop ().run_until_complete (wait_loop ())
138+ except KeyboardInterrupt :
139+ asyncio .get_event_loop ().run_until_complete (client .logout ())
0 commit comments