def delete_user(phone_number): Profile = Atom('Profile') remove = Atom('remove') user_delete_f = (Profile, phone_number, [], [], [], [], [], [], remove) print('=' * 5 + 'REQUEST' + '=' * 5 + '\r\n' + str(user_delete_f) + '\r\n') user_delete = bert.encode(user_delete_f) return user_delete
def sms(main_number): phone_num = main_number module = Atom('Auth') client_id = [] # client_id = [] :: [] | binary(), dev_key = phone_num # dev_key = [] :: [] | binary(), user_id = [] # user_id = [] :: [] | binary(), phone = phone_num # phone = [] :: [] | binary(), token = [] # token = [] :: [] | binary(), sms_code = '903182' # type = [] :: [] | atom(), type_r = Atom('verify') # sms_code = [] :: [] | binary(), attempts = [] # attempts = [] :: [] | integer(), services = [] # services = [] :: list(atom()), settings = [('Feature', "id_DEFAULT_LANGUAGE", "DEFAULT_LANGUAGE", "English:en", "LANGUAGE_SETTING")] push = [] # push = [] :: [] | binary(), os = [] # os = [] :: [] | atom() | ios | android | web, created = [] # created = [] :: [] | integer() | binary(), last_online = [] # last_online = [] :: [] | integer()}) request_f = (module, client_id, dev_key, user_id, phone, token, type_r, sms_code, attempts, services, settings, push, os, created, last_online) request = bert.encode(request_f) # log.info('='*5 + 'REQUEST' + '='*5 + '\r\n'+ str(request_f)+'\r\n') log.debug("Send sms verify") return request
def login(main_number): phone_num = main_number feature = Atom('Feature') module = Atom('Auth') client_id = "reg_" + phone_num # client_id = [] :: [] | binary(), dev_key = phone_num # dev_key = [] :: [] | binary(), user_id = [] # user_id = [] :: [] | binary(), phone = phone_num # phone = [] :: [] | binary(), token = [] # token = [] :: [] | binary(), sms_code = [] # type = [] :: [] | atom(), type_r = Atom('reg') # sms_code = [] :: [] | binary(), attempts = [] # attempts = [] :: [] | integer(), services = [] # services = [] :: list(atom()), # settings = [] :: [] | list(#'Feature'{}), settings = [(feature, phone_num + "__152775413346297", "AppVersion", "0.2.95", "AUTH_DATA"), (feature, phone_num + "__152775413346297", "OS", "iOS 11.3", "AUTH_DATA"), (feature, phone_num + "__152775413346297", "DeviceModel", "simulator/sandbox", "AUTH_DATA")] push = [] # push = [] :: [] | binary(), os = [] # os = [] :: [] | atom() | ios | android | web, created = [] # created = [] :: [] | integer() | binary(), last_online = [] # last_online = [] :: [] | integer()}) request_f = (module, client_id, dev_key, user_id, phone, token, type_r, sms_code, attempts, services, settings, push, os, created, last_online) request = bert.encode(request_f) # log.info('='*5 + 'REQUEST' + '='*5 + '\r\n' + str(request_f)+'\r\n') log.debug("Send Auth/check") return request
def room(**data): module = Atom('Room') expected = [ 'room_id', 'name', 'links', 'description', 'settings', 'members', 'admins', 'data', 'room_type', 'tos', 'tos_update', 'unread', 'mentions', 'readers', 'last_msg', 'update', 'created', 'room_status' ] actual = data my_dict = {} for i in expected: if i in actual.keys(): my_dict.update({i: actual[i]}) else: my_dict.update({i: []}) request_f = (module, my_dict['room_id'], my_dict['name'], my_dict['links'], my_dict['description'], my_dict['settings'], my_dict['members'], my_dict['admins'], my_dict['data'], my_dict['room_type'], my_dict['tos'], my_dict['tos_update'], my_dict['unread'], my_dict['mentions'], my_dict['readers'], my_dict['last_msg'], my_dict['update'], my_dict['created'], my_dict['room_status']) request = bert.encode(request_f) log.info('=' * 5 + 'REQUEST' + '=' * 5 + '\r\n' + str(request_f) + '\r\n') return request
def encode(input_sentence, pca, bert, pooling): return pca.transform( bert.encode([input_sentence], [1], batch_size=1, strategy=pooling, fname="dummy.txt", write=False))
def patch_group(room_id, room_name): module = Atom('Room') room_id = room_id # id = [] :: [] | binary(), name = room_name # name = [] :: [] | binary(), links = [] description = [] # description = [] :: [] | binary(), settings = [] # settings = [] :: list(), members = [] # members = [] :: list(#'Member'{}), admins = [] # admins = [] :: list(#'Member'{}), data = [] # data = [] :: [] | list(#'Desc'{}), room_type = [] # type = [] :: [] | atom() | group | channel, tos = [] # tos = [] :: [] | binary(), tos_update = [] # tos_update = 0 :: [] | integer(), unread = [] # unread = 0 :: [] | integer(), mentions = [] # mentions = [] :: [] | list(integer()), readers = [] # readers = [] :: list(integer()), last_msg = [] # last_msg = [] :: [] | #'Message'{}, update = [] # update = 0 :: [] | integer(), created = [] # created = 0 :: [] | integer(), room_status = Atom('patch') # status = [] :: [] | create | leave| add | remove | patch | get | delete | last_msg}). request_f = (module,room_id,name,links,description,settings,members,admins,data,room_type, tos,tos_update,unread,mentions,readers,last_msg,update,created,room_status) request = bert.encode(request_f) # log.info('='*5 + 'REQUEST' + '='*5 + '\r\n'+ str(request_f)+'\r\n') log.debug("Send group creation request") return request
def get_profile(): module = Atom('Profile') phone_id = '12566018988' settings = [] status = Atom('get') request_f = (module,phone_id,settings,settings,settings,settings,settings,settings,status) request = bert.encode(request_f) print('='*5 + 'REQUEST' + '='*5 + '\r\n'+ str(request_f)+'\r\n') return request
def sendTuple(self,data): # TODO: review this in context of plugins. """sends a line to the server if connected""" if self.isConnected: data=bert.encode((bert.Atom(data[0]),)+data[1:]) try: self.sendString(data) except basic.StringTooLongError: self.controller.gotException("you're trying to send to much data at once") else: self.controller.gotException("not connected")
def ban_user(): module = Atom('Friend') phone_id = '8613777322455_544' # phone_id = [] :: [] | binary(), friend_id = '380998681837_437' # friend_id = [] :: [] | binary(), settings = [] # settings = [] :: list(#'Feature'{}), status = Atom('ban') # status = [] :: [] | ban | unban # | request | confirm | update request_f = (module, phone_id, friend_id, settings, status) request = bert.encode(request_f) print('=' * 5 + 'REQUEST' + '=' * 5 + '\r\n' + str(request_f) + '\r\n') return request
def ignore_request(): module = Atom('Friend') phone_id = '12566018988_727' # phone_id = [] :: [] | binary(), friend_id = '51997259024_549' # friend_id = [] :: [] | binary(), settings = [] # settings = [] :: list(#'Feature'{}), status = Atom('ignore') # status = [] :: [] | ban | unban # | request | confirm | update request_f = (module,phone_id,friend_id,settings,status) request = bert.encode(request_f) print('='*5 + 'REQUEST' + '='*5 + '\r\n'+ str(request_f)+'\r\n') return request
def history_schedule(): model = Atom('History') user_id = '38000000001_13825' # roster_id = [] :: [] | binary(), history_type = Atom('act') name = 'publish' # name = <<"publish">> :: [] | binary(), dt = '38000000001_13825' # data = []:: binary() | integer() | list(term())}) action = Atom('get') size = [] # size = 0 :: [] | integer(), entity_id = [] # entity_id = 0 :: [] | integer(), data = [] # data = [] :: list(#'Message'{}) | list(#'Job'{}), request_f = (model,user_id,(history_type,name,dt),size,entity_id,data,action) request = bert.encode(request_f) print('='*5 + 'REQUEST' + '='*5 + '\r\n'+ str(request_f)+'\r\n') return request
def history_group(user_id, group_id): model = Atom('History') user_id = user_id # roster_id = [] :: [] | binary(), history_type = Atom('muc') group_id = group_id # group_id = [] :: [] | binary(), size = [] # size = 0 :: [] | integer(), entity_id = [] # entity_id = 0 :: [] | integer(), data = [] # data = [] :: list(#'Message'{}) | list(#'Job'{}), action = Atom('delete') request_f = (model,user_id,(history_type,group_id),size,entity_id,data,action) request = bert.encode(request_f) # log.debug('='*5 + 'REQUEST' + '='*5 + '\r\n'+ str(request_f)+'\r\n') log.debug('Clear group chat history request') return request
def history_p2p(): model = Atom('History') user_id = '8613777322455_544' # roster_id = [] :: [] | binary(), history_type = Atom('p2p') from_r = '12566018988_541' # from = [] :: [] | binary(), to_r = '51997259024_542' # to = [] :: [] | binary() action = Atom('get') size = -15 # size = 0 :: [] | integer(), entity_id = 20483 # entity_id = 0 :: [] | integer(), data = [] # data = [] :: list(#'Message'{}) | list(#'Job'{}), request_f = (model,user_id,(history_type,from_r,to_r),size,entity_id,data,action) request = bert.encode(request_f) print('='*5 + 'REQUEST' + '='*5 + '\r\n'+ str(request_f)+'\r\n') return request
def friend(**data): module = Atom('Friend') expected = ['my_id', 'friend_id', 'settings', 'status'] actual = data my_dict = {} for i in expected: if i in actual.keys(): my_dict.update({i: actual[i]}) else: my_dict.update({i: []}) request_f = (module, my_dict['my_id'], my_dict['friend_id'], my_dict['settings'], my_dict['status']) by_phone = bert.encode(request_f) return by_phone
def search(**data): module = Atom('Search') expected = ['user_id', 'ref', 'field', 'type_r', 'value', 'status'] actual = data my_dict = {} for i in expected: if i in actual.keys(): my_dict.update({i: actual[i]}) else: my_dict.update({i: []}) request_f = (module, my_dict['user_id'], my_dict['ref'], my_dict['field'], my_dict['type_r'], my_dict['value'], my_dict['status']) by_phone = bert.encode(request_f) # log.info('='*5 + 'REQUEST' + '='*5 + '\r\n'+ str(by_phone_f)+'\r\n') log.debug("Search by number {}".format(str(my_dict['value']))) return by_phone
def broadcastForPlaces(self): places = [] my_addr = socket.getfqdn() bc_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) bc_socket.settimeout(5) bc_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST,1) if self.verbose: print "\tBroadcasting for an RPR on %s:%s" % ('<broadcast>' ,self.bport) bc_socket.sendto(bert.encode(my_addr), ('<broadcast>' ,self.bport)) while True: try: message , address = bc_socket.recvfrom(8192) except socket.timeout, e: if self.verbose: if places: print "\tNo more replies to the broadcast" else: print "\tNo replies to the broadcast" break
def roster(**data): module = Atom('Roster') expected = ['user_id', 'first_name', 'last_name', 'email', 'my_username', 'user_list', 'room_list', 'favorite', 'tags', 'phone', 'avatar', 'update', 'status'] actual = data my_dict = {} for i in expected: if i in actual.keys(): my_dict.update({i: actual[i]}) else: my_dict.update({i: []}) request_f = (module, my_dict['user_id'], my_dict['first_name'], my_dict['last_name'], my_dict['email'], my_dict['my_username'], my_dict['user_list'], my_dict['room_list'], my_dict['favorite'], my_dict['tags'], my_dict['phone'], my_dict['avatar'], my_dict['update'], my_dict['status']) request = bert.encode(request_f) log.info('='*5 + 'REQUEST' + '='*5 + '\r\n'+ str(request_f)+'\r\n') return request
def update_username(): model = Atom('Roster') user_id = 544 # id = [] :: [] | integer(), first_name = [] # names = [] :: [] | binary(), last_name = [] # surnames = [] :: [] | binary(), email = [] # email = [] :: [] | binary(), my_username = '******' # nick = [] :: [] | binary(), user_list = [] # userlist = [] :: list(#'Contact'{}), room_list = [] # roomlist = [] :: list(#'Room'{}), favorite = [] # favorite = [] :: list(#'ExtendedStar'{}), tags = [] # tags = [] :: list(#'Tag'{}), phone = [] # phone = [] :: [] | binary(), avatar = [] # avatar = [] :: [] | binary(), update = [] # update = 0 :: [] | integer(), status = Atom('nick') # status = [] :: [] | get | create | del | remove | nick | add | update # | list | patch | last_msg request_f = (model,user_id,first_name,last_name,email,my_username,user_list,room_list,favorite, tags,phone,avatar,update,status) request = bert.encode(request_f) print('='*5 + 'REQUEST' + '='*5 + '\r\n'+ str(request_f)+'\r\n') return request
def member(**data): module = Atom('Member') expected = ['member_id', 'container', 'feed_id', 'prev', 'next', 'feeds', 'phone_id', 'avatar', 'names', 'surnames', 'alias', 'reader', 'update', 'settings', 'services', 'presence', 'status'] actual = data my_dict = {} for i in expected: if i in actual.keys(): my_dict.update({i: actual[i]}) else: my_dict.update({i: []}) request_f = (module, my_dict['member_id'], my_dict['container'], my_dict['feed_id'], my_dict['prev'], my_dict['next'], my_dict['feeds'], my_dict['phone_id'], my_dict['avatar'], my_dict['names'], my_dict['surnames'], my_dict['alias'], my_dict['reader'], my_dict['update'], my_dict['settings'], my_dict['services'], my_dict['presence'], my_dict['status']) request = bert.encode(request_f) log.info('='*5 + 'REQUEST' + '='*5 + '\r\n'+ str(request_f)+'\r\n') log.debug("Send group creation request") return request
def run(self): bc_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) bc_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) bc_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) bc_socket.bind(('',self.bcport)) while not self.terminate: i,o,r = select.select([bc_socket], [], [], 1) for sock in i: message , address = sock.recvfrom(8192) if self.verbose: print "\tReceived broadcast from %s" % (str(address)) msg = bert.decode(message) #print "msg= %s" % (str(msg)) msg = bert.encode(('reply', (socket.getfqdn(), self.port))) try: sock.sendto(msg, address) except: pass
def collect_bert_states(bert, data: List[Tuple], layers: List[int], final_transform: bool, mask_prob: float): data_with_states = [] for i, d in tqdm.tqdm(enumerate(data), total=len(data)): sent, ind, label = d["text"], d["ind"], d["label"] preds, orig2tok, bert_tokens = bert.encode( sent, layers=layers, pos_ind=ind, mask_prob=mask_prob, final_transform=final_transform) j = orig2tok[ind] v = preds[j] dict_with_state = d.copy() dict_with_state["vec"] = v data_with_states.append(dict_with_state) return data_with_states
def job(**data): module = Atom('Job') expected = [ 'id', 'container', 'feed_id', 'next', 'prev', 'context', 'proc', 'time', 'data', 'events', 'settings', 'status' ] actual = data my_dict = {} for i in expected: if i in actual.keys(): my_dict.update({i: actual[i]}) else: my_dict.update({i: []}) request_f = (module, my_dict['id'], my_dict['container'], my_dict['feed_id'], my_dict['next'], my_dict['prev'], my_dict['context'], my_dict['proc'], my_dict['time'], my_dict['data'], my_dict['events'], my_dict['settings'], my_dict['status']) by_phone = bert.encode(request_f) log.info('=' * 5 + 'REQUEST' + '=' * 5 + '\r\n' + str(request_f) + '\r\n') return by_phone
def write_berp(self, output, obj): data = bert.encode(obj) output.write(struct.pack("!L", len(data))) output.write(data) output.flush()
def encodePayload(*args, **kwargs): return bert.encode(args)
def create_group(main_id, main_firstname, main_lastname, main_alias, friend_id, friend_firstname, friend_lastname, friend_alias, group_avatar): module = Atom('Room') room_id = 'Autotest_group_id' + str( time.time()).split('.')[0] # id = [] :: [] | binary(), name = magic.get_word # name = [] :: [] | binary(), links = [] description = [] # description = [] :: [] | binary(), settings = [] # settings = [] :: list(), friend_member = member(container=Atom('chain'), phone_id=friend_id, names=friend_firstname, surnames=friend_lastname, alias=friend_alias, status=Atom('member')) main_admin = member(container=Atom('chain'), phone_id=main_id, names=main_firstname, surnames=main_lastname, alias=main_alias, status=Atom('admin')) members = [bert.decode(friend_member) ] # members = [] :: list(#'Member'{}), admins = [bert.decode(main_admin) ] # admins = [] :: list(#'Member'{}), data = [] # data = [] :: [] | list(#'Desc'{}), room_type = Atom( 'group') # type = [] :: [] | atom() | group | channel, tos = [] # tos = [] :: [] | binary(), tos_update = [] # tos_update = 0 :: [] | integer(), unread = [] # unread = 0 :: [] | integer(), mentions = [] # mentions = [] :: [] | list(integer()), readers = [] # readers = [] :: list(integer()), last_msg = [] # last_msg = [] :: [] | #'Message'{}, update = [] # update = 0 :: [] | integer(), created = [] # created = 0 :: [] | integer(), room_status = Atom( 'create' ) # status = [] :: [] | create | leave| add | remove | patch | get | delete | last_msg}). if group_avatar: avatar_module = Atom('Desc') avatar_id = 'Autotest_avatar' + str(time.time()).split('.')[0] mime = 'image' avatar_payload = "https://s3-us-west-2.amazonaws.com/nynja-defaults/Image_" \ "153310818583129_86FC1EF5-C297-4A1A-9FA1-A7D3C5E27E0E1533108186.jpg" parentid = [] avatar_data = [] data = [(avatar_module, avatar_id, mime, avatar_payload, parentid, avatar_data)] request_f = (module, room_id, name, links, description, settings, members, admins, data, room_type, tos, tos_update, unread, mentions, readers, last_msg, update, created, room_status) request = bert.encode(request_f) log.info('=' * 5 + 'REQUEST' + '=' * 5 + '\r\n' + str(request_f) + '\r\n') log.debug("Send group creation request") log.debug(request_f) return request
def encode(self, python_request): return bert.encode(python_request)
def _encodeMessage(self, message): '''Encode a bert message, pre-pending the 4 size bytes''' bmsg = bert.encode(message) size = struct.pack("!L",len(bmsg)) return ''.join([size, bmsg])
max_results = st.slider( 'Max number of results', 1, 5000, 25) #int(st.text_input("Max number of results", 25)) show_results = True start = st.button('Run') if start: if mode == "Start with Sentence": #input_sentence = st.text_input('Input sentence', 'The virus can spread rapidly via different transimission vectors.') encoding = pca.transform( bert.encode([input_sentence], [1], batch_size=1, strategy=pooling, fname="dummy.txt", write=False)) #.squeeze() #st.write("filter by spike: ", filter_by_spike) #st.write(encoding.shape) #st.write(index.d) if not filter_by_spike: #st.write(encoding.shape, pca.components_.shape, index.d) #st.write(help(index)) D, I = index.search( np.ascontiguousarray(encoding).astype("float32"), number_of_sentence_results) else:
def write_berp(self, obj): data = bert.encode(obj) self.wfile.write(struct.pack("!L", len(data))) self.wfile.write(data) self.wfile.flush()
def message_model(mime, message_text=None, **kwargs): module = Atom('Message') msg_id = 'Autotest_message_id_' + timestamp_time if mime in mime_enums.mime: if mime == 'audio': payload = "https://s3-us-west-2.amazonaws.com/nynja-defaults/A8CE6719-EB5E-4D8D-BF3E-5B5377463A73_" \ "380977917979_240_380667578356_623_153302368105645_361B7E18-302C-469D-BC86-9EF954E28179.mp3" features = [ (Atom('Feature'), 'Feature_DURATION_' + timestamp_time, 'DURATION', '50000', 'FILE_DATA'), (Atom('Feature'), 'Feature_INFO_' + timestamp_time, 'INFO', '[0.00694619, 0.00598051, 0.00640373, 0.00411694, 0.00376302, ' '0.00385633, 0.00388491, 0.00562793, 0.00556369, 0.00590717, ' '0.00427526, 0.00305555, 0.00245941, 0.00367912, 0.0020681, ' '0.00200623, 0.00172327, 0.00153149, 0.00197051, 0.00254462, ' '0.00124885, 0.0190442, 0.0110677, 0.00437577, 0.0332922, 0.0111691,' ' 0.00486005, 0.00158101, 0.0013417, 0.00131789, 0.00140617,' ' 0.00129963, 0.00131394, 0.00181012, 0.0018368, 0.00159087, ' '0.00116367, 0.00132543, 0.00125508, 0.00166154, 0.00189293, ' '0.00109495, 0.00113848, 0.00128676, 0.00201494, 0.00321521, ' '0.00129334, 0.00115214, 0.00152102, 0.00297446, 0.00526876, ' '0.00282387, 0.00194889, 0.0026418, 0.00224314, 0.00122276, ' '0.00119336, 0.000969137, 0.000954979, 0.0010043, 0.00112306, ' '0.00074907, 0.00112774, 0.00106222, 0.00108591, 0.00102118, ' '0.00108384, 0.00132377, 0.00195076, 0.00223557, 0.00235106, ' '0.00229124, 0.0017405, 0.00125239, 0.000841596, 0.000576772, ' '.000592627, 0.000601461, 0.000991837, 0.00103431, 0.00111168, ' '0.000606259, 0.000560362, 0.000567207, 0.000628491, 0.000589819, ' '0.000622787, 0.000529032, 0.000557232, 0.000599589, 0.000763404, ' '0.000702032, 0.000524995, 0.000689804, 0.00060228, 0.000614362, ' '0.0021555, 1.0, 0.462762, 0.18173]', 'FILE_DATA'), (Atom('Feature'), 'Feature_LANGUAGE_' + timestamp_time, 'LANGUAGE', 'en', 'FILE_DATA') ] files = desc_model(mime, payload, features) if mime == 'text': if message_text: payload = message_text else: payload = magic.get_word features = [] files = desc_model(mime, payload, features) if mime == 'image': payload = "https://s3-us-west-2.amazonaws.com/nynja-defaults/thumb" \ "_153657407372743_9B03C956-E679-4541-BE9A-86A710290131.jpg" features = [ (Atom('Feature'), 'Feature_SIZE_' + timestamp_time, 'SIZE', '64575', 'FILE_DATA'), (Atom('Feature'), 'Feature_FILENAME_' + timestamp_time, 'FILENAME', 'thumb_153657407372743_9B03C956-E679-4541-BE9A-86A710290131.jpg', 'FILE_DATA'), (Atom('Feature'), 'Feature_RESOLUTION_' + timestamp_time, 'RESOLUTION', '256:171', 'FILE_DATA') ] files = desc_model(mime, payload, features) if mime == 'video': payload = "https://s3-us-west-2.amazonaws.com/nynja-defaults/" \ "tmp_1536658896_B3C85DE6-D7BE-4870-BD03-BDC69FDFE0EF.mp4" features = [(Atom('Feature'), 'Feature_SIZE_' + timestamp_time, 'SIZE', '22935809', 'FILE_DATA'), (Atom('Feature'), 'Feature_DURATION_' + timestamp_time, 'DURATION', '58000', 'FILE_DATA'), (Atom('Feature'), 'Feature_FILENAME_' + timestamp_time, 'FILENAME', 'tmp_1536658896_B3C85DE6-D7BE-4870-' 'BD03-BDC69FDFE0EF.mp4', 'FILE_DATA')] files = desc_model(mime, payload, features) if mime == 'location': payload = "37.785834,-122.406417" features = [] files = desc_model(mime, payload, features) if mime == 'sticker': payload = "https://s3.eu-central-1.amazonaws.com/sticker-packs/defaults/ny1.png" features = [] files = desc_model(mime, payload, features) expected = [ 'id', 'container', 'feed_id', 'prev', 'next', 'from_user', 'to', 'created', 'type', 'link', 'seenby', 'repliedby', 'mentioned', 'status' ] actual = kwargs my_dict = {} for i in expected: if i in actual.keys(): my_dict.update({i: actual[i]}) else: my_dict.update({i: []}) request_f = (module, my_dict['id'], my_dict['container'], my_dict['feed_id'], my_dict['prev'], my_dict['next'], msg_id, my_dict['from_user'], my_dict['to'], my_dict['created'], [files], my_dict['type'], my_dict['link'], my_dict['seenby'], my_dict['repliedby'], my_dict['mentioned'], my_dict['status']) request = bert.encode(request_f) log.debug('=' * 5 + 'REQUEST' + '=' * 5 + '\r\n' + str(request_f) + '\r\n') return request
import bert from erlastic import Atom Auth = Atom('Auth') Feature = Atom('Feature') reg = Atom('reg') stri = (Auth, "reg_234BD084-5883-4E89-B86A-97305E903007", "234BD084-5883-4E89-B86A-97305E903007", [], "8613777322455", [], reg, [], [], [], [(Feature, "234BD084-5883-4E89-B86A-97305E903007__152423881122539", "AppVersion", "0.2.92", "AUTH_DATA"), (Feature, "234BD084-5883-4E89-B86A-97305E903007__152423881122904", "OS", "iOS 11.3", "AUTH_DATA"), (Feature, "234BD084-5883-4E89-B86A-97305E903007__152423881123003", "DeviceModel", "simulator/sandbox", "AUTH_DATA")], [], [], [], []) login = bert.encode(stri) verify = Atom('verify') sms_f = (Auth,[],"234BD084-5883-4E89-B86A-97305E903007",[],"8613777322455",[],verify,"903182",[],[],[],[],[],[],[]) sms = bert.encode(sms_f) Roster = Atom('Roster') nick = Atom('nick') username_f = (Roster,456,[],[],[],"SomeNew",[],[],[],[],[],[],[],nick) username = bert.encode(username_f)
def send_message(main_id, friend_id, chat, mime, message_id, message_type, member_id=None, message_text=None): module = Atom('Message') id_r = [] container = Atom('chain') feed_id = chat prev = [] next_r = [] msg_id = 'Autotest_message_id_' + str(time.time()).split('.')[0] from_r2 = main_id to_r2 = friend_id created = [] if mime in mime_enums.mime: if mime == 'audio': payload = "https://s3-us-west-2.amazonaws.com/nynja-defaults/A8CE6719-EB5E-4D8D-BF3E-5B5377463A73_" \ "380977917979_240_380667578356_623_153302368105645_361B7E18-302C-469D-BC86-9EF954E28179.mp3" features = [ (Atom('Feature'), '6BB6C217-A628-4C2C-99F8-A59FF9B07674_8613777322455_777_duration' '_8368BD20-0725-40F1-B679-8641DC5592B1_153631532376920', 'DURATION', '50000', 'FILE_DATA'), (Atom('Feature'), '6BB6C217-A628-4C2C-99F8-A59FF9B07674_8613777322455' '_777_info_C996B373-42CD-4C1B-A3D7-E53A7DB6D0E4_' '153631532377008', 'INFO', '[0.00694619, 0.00598051, 0.00640373, 0.00411694, 0.00376302, ' '0.00385633, 0.00388491, 0.00562793, 0.00556369, 0.00590717, ' '0.00427526, 0.00305555, 0.00245941, 0.00367912, 0.0020681, ' '0.00200623, 0.00172327, 0.00153149, 0.00197051, 0.00254462, ' '0.00124885, 0.0190442, 0.0110677, 0.00437577, 0.0332922, 0.0111691,' ' 0.00486005, 0.00158101, 0.0013417, 0.00131789, 0.00140617,' ' 0.00129963, 0.00131394, 0.00181012, 0.0018368, 0.00159087, ' '0.00116367, 0.00132543, 0.00125508, 0.00166154, 0.00189293, ' '0.00109495, 0.00113848, 0.00128676, 0.00201494, 0.00321521, ' '0.00129334, 0.00115214, 0.00152102, 0.00297446, 0.00526876, ' '0.00282387, 0.00194889, 0.0026418, 0.00224314, 0.00122276, ' '0.00119336, 0.000969137, 0.000954979, 0.0010043, 0.00112306, ' '0.00074907, 0.00112774, 0.00106222, 0.00108591, 0.00102118, ' '0.00108384, 0.00132377, 0.00195076, 0.00223557, 0.00235106, ' '0.00229124, 0.0017405, 0.00125239, 0.000841596, 0.000576772, ' '.000592627, 0.000601461, 0.000991837, 0.00103431, 0.00111168, ' '0.000606259, 0.000560362, 0.000567207, 0.000628491, 0.000589819, ' '0.000622787, 0.000529032, 0.000557232, 0.000599589, 0.000763404, ' '0.000702032, 0.000524995, 0.000689804, 0.00060228, 0.000614362, ' '0.0021555, 1.0, 0.462762, 0.18173]', 'FILE_DATA'), (Atom('Feature'), '6BB6C217-A628-4C2C-99F8-A59FF9B07674_8613777322455_777_language_A809409D' '-788A-4946-B1AC-78BB6FDA238B_153631532377081', 'LANGUAGE', 'en', 'FILE_DATA') ] files = desc_model(mime, payload, features) if mime == 'text': if message_text: payload = message_text else: payload = magic.get_word features = [] files = desc_model(mime, payload, features) if mime == 'image': payload = "https://s3-us-west-2.amazonaws.com/nynja-defaults/thumb" \ "_153657407372743_9B03C956-E679-4541-BE9A-86A710290131.jpg" features = [ (Atom('Feature'), '2EC12976-9521-48E7-9898-D1CE304CD34F_8613777322455_655_size_31E96AB9-A4DB-' '4538-B93B-3987C24D3FC5_153657407840657', 'SIZE', '64575', 'FILE_DATA'), (Atom('Feature'), '2EC12976-9521-48E7-9898-D1CE304CD34F_8613777322455_655_filename_D185367A-' '5103-404F-B51A-7C89F99C738B_153657407840569', 'FILENAME', 'thumb_153657407372743_9B03C956-E679-4541-BE9A-86A710290131.jpg', 'FILE_DATA'), (Atom('Feature'), '2EC12976-9521-48E7-9898-D1CE304CD34F_8613777322455_655_resolution_1074DE19-' 'A186-4D7D-8719-BC439C15D4AC_153657407374066', 'RESOLUTION', '256:171', 'FILE_DATA') ] files = desc_model(mime, payload, features) if mime == 'video': payload = "https://s3-us-west-2.amazonaws.com/nynja-defaults/" \ "tmp_1536658896_B3C85DE6-D7BE-4870-BD03-BDC69FDFE0EF.mp4" features = [ (Atom('Feature'), '2EC12976-9521-48E7-9898-D1CE304CD34F_817090909090_661_size_CCE6EA22-4152-476C-BBFB-' 'A0AA17A6D6D0_153665894794709', 'SIZE', '22935809', 'FILE_DATA'), (Atom('Feature'), '2EC12976-9521-48E7-9898-D1CE304CD34F_817090909090_661_duration_AAADD0A7-BE02-4EF8-' '82CF-4B74683C7EEE_153665889713910', 'DURATION', '58000', 'FILE_DATA'), (Atom('Feature'), '2EC12976-9521-48E7-9898-D1CE304CD34F_817090909090_661_filename_76848893-8F18-4523-' '319-BEA112BB4D94_153665894794633', 'FILENAME', 'tmp_1536658896_B3C85DE6-D7BE-4870-' 'BD03-BDC69FDFE0EF.mp4', 'FILE_DATA') ] files = desc_model(mime, payload, features) if mime == 'location': payload = "37.785834,-122.406417" features = [] files = desc_model(mime, payload, features) if mime == 'sticker': payload = "https://s3.eu-central-1.amazonaws.com/sticker-packs/defaults/ny1.png" features = [] files = desc_model(mime, payload, features) type_m = [] link = [] seenby = [] repliedby = [] mentioned = [] status = [] if message_type == 'reply': type_m = [Atom('reply')] link = message_id if message_type == 'forward': type_m = [Atom('forward')] link = message_id container = [] if message_type == 'edit': type_m = [Atom('edited')] status = Atom('edit') id_r = message_id created = created if message_type == 'delete for all': status = Atom('delete') seenby = [-1] id_r = message_id created = created files = [] if message_type == 'delete for me': status = Atom('delete') seenby = [member_id] id_r = message_id created = created files = [] request_f = (module, id_r, container, feed_id, prev, next_r, msg_id, from_r2, to_r2, created, [files], type_m, link, seenby, repliedby, mentioned, status) request = bert.encode(request_f) log.debug('=' * 5 + 'REQUEST' + '=' * 5 + '\r\n' + str(request_f) + '\r\n') return request