Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- BUFFER = 1024
- def custom_glit_upload(sock, feed_owner_id, publisher_avatar, background_color, date, content, font_color):
- """
- Custom glit uploading with editable parameters (the application allows u to edit only the content label,
- here you can edit additional parameters) @param sock: current opened socket @param publisher_avatar: set any
- avatar ( im1->im8) @param background_color: set any background color @param date: set any date
- YYYY-MM-DD'T'HH:MM:SS.MSMSMS'Z' @param content: the content of the uploaded glit @param font_color: the font
- color of the text
- """
- sock.sendall(('550#{gli&&er}{"feed_owner_id":' + feed_owner_id + ',"publisher_id":' + MY_ID + ','
- '"publisher_screen_name":"Yonka", '
- '"publisher_avatar":"' + publisher_avatar + '","background_color":"' + background_color
- + '","date":"' + date + '",' # UTC
- '"content":"' + content + '","font_color":"' + font_color + '","id":-1}##').encode())
- print(sock.recv(BUFFER).decode())
- def custom_comment_upload(sock, content, date):
- """
- Custom comment uploading with editable parameters (the application allows u to edit only the content label,
- here you can edit additional parameters)
- @param sock: current opened socket
- @param content: the content of the uploaded comment
- @param date: set any date YYYY-MM-DD'T'HH:MM:SS.MSMSMS'Z'
- """
- sock.sendall(('650#{gli&&er}{"glit_id":5214,"user_id":' + MY_ID + ',"user_screen_name":"Yonka","id":-1,"content":"'
- + content
- + '","date":"' + date + '"}##').encode())
- print(sock.recv(BUFFER))
- def get_description(sock, profile_id):
- """
- Returns the description (Life Motto) of the given profile (id)
- @param sock: current opened socket
- @param profile_id: id of the profile which we want to get his description
- @return: (str) the description (Life Motto) of the profile (that we set in the settings)
- """
- description_pattern = r'description":"(.+?)"'
- sock.sendall(('310#{gli&&er}' + profile_id + '##').encode())
- reply = sock.recv(BUFFER).decode()
- print(reply)
- matches = re.search(description_pattern, reply)
- return matches.group(1)
- def login(sock, username, password, checksum):
- """
- login into the system
- @param sock: current opened socket
- @param username: user name to log with
- @param password: password to log with
- @param checksum: checksum of username+password
- """
- sock.sendall(('100#{gli&&er}{"user_name":"' + username + '","password":"' + password + '",'
- '"enable_push_notifications":true}##').encode()) # Login
- sock.recv(BUFFER)
- sock.sendall(('110#{gli&&er}' + str(checksum) + '##').encode()) # CHECKSUM send
- reply = sock.recv(BUFFER).decode()
- print(reply)
- user_id = get_id(reply)
- password = get_password(reply)
- screen_name = get_screen_name(reply)
- return user_id, password, screen_name
- def get_password(message):
- password_pattern = r'"password":"(.+?)",'
- matches = re.search(password_pattern, message)
- if matches:
- return matches.group(1)
- else:
- return None
- def get_id(message):
- id_pattern = r'"id":(.+?),'
- matches = re.search(id_pattern, message)
- if matches:
- return matches.group(1)
- else:
- return None
- def get_screen_name(message):
- screen_name_pattern = r'"screen_name":"(.+?)",'
- matches = re.search(screen_name_pattern, message)
- if matches:
- return matches.group(1)
- else:
- return None
- def calc_checksum(data):
- """
- Calcualtes the checksum of the given data
- @param data: data to calculate his checksum
- @return: calculated checksum
- """
- num = 0
- for letter in data:
- num += ord(letter)
- return num
- def login_without_pass(sock, username, user_id):
- logout(sock, user_id)
- checksum_pattern = r"checksum: (\d+){"
- sock.sendall(('100#{gli&&er}{"user_name":"' + username +
- '","password":"-----","enable_push_notifications":true}##').encode())
- matches = re.search(checksum_pattern, sock.recv(BUFFER).decode())
- if matches is None:
- return None, None
- checksum = int(matches.group(1))
- current_id, password, screen_name = login(sock, username, chr(checksum - calc_checksum(username)), checksum)
- return current_id, password, screen_name
- def logout(sock, user_id):
- sock.sendall(('200#{gli&&er}' + user_id + '##').encode())
- sock.recv(BUFFER).decode()
- def add_likes(sock, user_id, glit_id, user_screen_name, likes_number):
- """
- Add any number of likes to the given glit
- @param sock: current opened glit
- @param glit_id: id of the glit to add likes
- @param likes_number: number of likes to add to the given glit
- """
- for i in range(likes_number):
- sock.sendall(
- ('710#{gli&&er}{"glit_id":' + glit_id + ',"user_id":' + user_id +
- ',"user_screen_name":"' + user_screen_name + '","id":-1}##').encode())
- print(sock.recv(BUFFER).decode())
- def get_email(sock, username):
- """
- Returns the email of the given username in the Glit system
- @param sock: current opened socket
- @param username: username to get his email
- @return: (str) email of the given username
- """
- email_pattern = r'{"screen_name":"' + username + '".+?"mail":"(.+?)"'
- sock.sendall(('300#{gli&&er}{"search_type":"SIMPLE","search_entry":"' + username + '"}##').encode())
- reply = sock.recv(BUFFER).decode()
- print(reply)
- matches = re.search(email_pattern, reply)
- return matches.group(1)
- def accept_glance_request(sock, future_friend_id):
- """
- Accept some glance request that we sent from another user
- @param sock: current opened socket
- @param future_friend_id: friend which we send and want to accept the glance
- """
- sock.sendall(('420#{gli&&er}[' + MY_ID + ',' + future_friend_id + ']##').encode())
- print(sock.recv(BUFFER).decode())
- def glits_list(sock, user_id):
- glit_count = 3
- glits_pattern = r'"date":"(\d+?)-(\d+?)-(\d+?)T.+?"content":"(.+?)".+?"id":(\d+)'
- sock.sendall(('500#{gli&&er}{"feed_owner_id":' + user_id + ',"end_date":"2021-06-26T11:01:35.206Z","glit_count":' + str(glit_count) + '}##').encode())
- matches = re.findall(glits_pattern, sock.recv(BUFFER * glit_count).decode())
- return matches
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement