Advertisement
Guest User

Untitled

a guest
Jan 27th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. import re
  2. import requests
  3. import getpass
  4. from texttable import Texttable
  5. import sys, msvcrt
  6. from colorama import init, Fore, Back, Style
  7. init()
  8.  
  9. vrcApiBase = 'https://api.vrchat.cloud/api/1/'
  10. allFriendsEndPoint = vrcApiBase + 'auth/user/friends'
  11. apiKeyEndPoint = vrcApiBase + 'config'
  12. sendNotificationEndPoint = vrcApiBase + 'user/%s/notification'
  13.  
  14. def getApiKey():
  15. response = requests.get(apiKeyEndPoint).json()
  16. print(Style.BRIGHT + Fore.RED + "Api key: " + Fore.BLUE + response['apiKey'] + "\n")
  17. return response['apiKey']
  18. def getOnlineFriends(username, password, apiKey):
  19. response = requests.get(allFriendsEndPoint, auth=(username, password), data={'apiKey': apiKey}).json()
  20. return response
  21. def sendNotification(username, password, apiKey, message, usr_str):
  22. response = requests.post(sendNotificationEndPoint % usr_str, auth=(username, password), data={'apiKey': apiKey, 'type': 'all', 'message': message})
  23. if response.status_code == 200:
  24. print('Notification send!')
  25.  
  26.  
  27. def main():
  28. apiKey = getApiKey()
  29. t = Texttable()
  30. t.set_max_width(0)
  31. print(Fore.RED + 'Bay\'s message sender' + Fore.GREEN)
  32. print(Fore.BLUE + 'Discord: bay#0001' + Fore.GREEN)
  33. username = input('Enter your username: ')
  34. password = getpass.getpass("Enter your password: ")
  35.  
  36. while True:
  37. friends = getOnlineFriends(username, password, apiKey)
  38. friendsList = []
  39. for idx, friend in enumerate(friends):
  40. if friend.get('username') != None:
  41. f_username = friend['username']
  42. else:
  43. f_username = 'No username'
  44. if friend.get('displayName') != None:
  45. f_displayName = friend['displayName']
  46. else:
  47. f_displayName = 'No displayName'
  48. if friend.get('statusDescription') != None:
  49. f_statusDescription = friend['statusDescription']
  50. else:
  51. f_statusDescription = 'No statusDescription'
  52. if friend.get('status') != None:
  53. f_status = friend['status']
  54. else:
  55. f_status = 'No status'
  56. if friend.get('id') != None:
  57. f_id = friend['id']
  58. else:
  59. f_id = 'No location'
  60. t.add_rows([['id', 'username', 'displayName', 'statusDescription', 'status', 'usr_id'], [idx, f_username, f_displayName, f_statusDescription, f_status, f_id]])
  61. friendsList.append({'idx': idx, 'id': f_id, 'username': f_username, 'displayName': f_displayName, 'statusDescription': f_status, 'status': f_status})
  62. print(Back.MAGENTA + Fore.WHITE + t.draw() + Back.BLACK + Fore.GREEN)
  63. print(str(len(friends)) + " Friends are online")
  64. selectedUserId = input('Choose a friend via id: ')
  65. usr_str = friendsList[int(selectedUserId)]['id']
  66. print(Fore.RED + 'Selected: ' + friendsList[int(selectedUserId)]['displayName'] + Fore.GREEN)
  67. message = input('Enter custom message: ')
  68. sendNotification(username, password, apiKey, message, usr_str)
  69. print(Fore.RED + 'End tool with ESC now or continue?')
  70. ch = msvcrt.getwche()
  71. if ch == u'\x1b':
  72. exit(0)
  73. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement