Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import requests
- import getpass
- from texttable import Texttable
- import sys, msvcrt
- from colorama import init, Fore, Back, Style
- init()
- vrcApiBase = 'https://api.vrchat.cloud/api/1/'
- allFriendsEndPoint = vrcApiBase + 'auth/user/friends'
- apiKeyEndPoint = vrcApiBase + 'config'
- sendNotificationEndPoint = vrcApiBase + 'user/%s/notification'
- def getApiKey():
- response = requests.get(apiKeyEndPoint).json()
- print(Style.BRIGHT + Fore.RED + "Api key: " + Fore.BLUE + response['apiKey'] + "\n")
- return response['apiKey']
- def getOnlineFriends(username, password, apiKey):
- response = requests.get(allFriendsEndPoint, auth=(username, password), data={'apiKey': apiKey}).json()
- return response
- def sendNotification(username, password, apiKey, message, usr_str):
- response = requests.post(sendNotificationEndPoint % usr_str, auth=(username, password), data={'apiKey': apiKey, 'type': 'all', 'message': message})
- if response.status_code == 200:
- print('Notification send!')
- def main():
- apiKey = getApiKey()
- t = Texttable()
- t.set_max_width(0)
- print(Fore.RED + 'Bay\'s message sender' + Fore.GREEN)
- print(Fore.BLUE + 'Discord: bay#0001' + Fore.GREEN)
- username = input('Enter your username: ')
- password = getpass.getpass("Enter your password: ")
- while True:
- friends = getOnlineFriends(username, password, apiKey)
- friendsList = []
- for idx, friend in enumerate(friends):
- if friend.get('username') != None:
- f_username = friend['username']
- else:
- f_username = 'No username'
- if friend.get('displayName') != None:
- f_displayName = friend['displayName']
- else:
- f_displayName = 'No displayName'
- if friend.get('statusDescription') != None:
- f_statusDescription = friend['statusDescription']
- else:
- f_statusDescription = 'No statusDescription'
- if friend.get('status') != None:
- f_status = friend['status']
- else:
- f_status = 'No status'
- if friend.get('id') != None:
- f_id = friend['id']
- else:
- f_id = 'No location'
- t.add_rows([['id', 'username', 'displayName', 'statusDescription', 'status', 'usr_id'], [idx, f_username, f_displayName, f_statusDescription, f_status, f_id]])
- friendsList.append({'idx': idx, 'id': f_id, 'username': f_username, 'displayName': f_displayName, 'statusDescription': f_status, 'status': f_status})
- print(Back.MAGENTA + Fore.WHITE + t.draw() + Back.BLACK + Fore.GREEN)
- print(str(len(friends)) + " Friends are online")
- selectedUserId = input('Choose a friend via id: ')
- usr_str = friendsList[int(selectedUserId)]['id']
- print(Fore.RED + 'Selected: ' + friendsList[int(selectedUserId)]['displayName'] + Fore.GREEN)
- message = input('Enter custom message: ')
- sendNotification(username, password, apiKey, message, usr_str)
- print(Fore.RED + 'End tool with ESC now or continue?')
- ch = msvcrt.getwche()
- if ch == u'\x1b':
- exit(0)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement