def create_msg(rq_raw, u): ''' create msg from user form ''' rq = check_check(rq_raw) date = str(gts()) txt = rq.txt if rq.pic: for n in rq.pic.split(): txt += '\n\n@image: %s' % n o = mydict(txt=txt, title=rq.title, date=date, ea=rq.ea, who=u.uname, addr=u.uaddr, to=rq.to) if rq.repto: o.repto = rq.repto if rq.tags and not rq.topicid: o.tags = mk_tags(rq.tags) blob = fo.obj_to_file(o, 60).encode('utf-8') msgid = hsh(blob) o.topicid = rq.topicid or msgid o = msghook.hook(o, True) blob = fo.obj_to_file(o).encode('utf-8') write_msg(o, msgid, blob, date, True) return msgid
def toss(msgfrom, addr, tmsg): lines = b64d(tmsg).decode('utf-8').splitlines() if flt.echo_flt(lines[0]): mo = sx.mydict(date=sx.gts(), msgfrom=msgfrom, addr=addr, echoarea=lines[0], msgto=lines[1], subj=lines[2], msg='\n'.join(lines[4:])) return mo
def file_to_obj(s): ''' transform ii msg to object ''' pz = s.splitlines() o = sx.mydict() optz = pz[0].split('/') o.update(dict(zip(optz[::2], optz[1::2]))) for i, n in enumerate(('ea', 'date', 'who', 'addr', 'to', 'title')): o[n] = pz[i + 1] o.txt = '\n'.join(pz[8:]) o.date = int(o.date) if o.date else sx.gts() return o
def _parze(msg): pz = msg.splitlines() mo = sx.mydict() optz = pz[0].split('/') mo.update(dict(zip(optz[::2], optz[1::2]))) for i, n in enumerate( ('echoarea', 'date', 'msgfrom', 'addr', 'msgto', 'subj')): mo[n] = pz[i + 1] mo.msg = '\n'.join(pz[8:]) mo.date = int(mo.date) if mo.date else sx.gts() return mo
def accept_msg(rq_raw): ''' accept msg from fetcher ''' rq = check_check(rq_raw) if rq: date = str(gts()) msgid = rq.msgid if not msg_flt(msgid): return o = rq blob = fo.obj_to_file(o).encode('utf-8') write_msg(o, msgid, blob, date, True) return msgid
def point_newmsg(tags): mo = sx.mydict(date=sx.gts()) mo.update(**tags) if _filter_msg_call(tags): return mkmsg(mo)
def toss(msgfrom,addr,tmsg): lines = b64d(tmsg).decode('utf-8').splitlines() if flt.echo_flt(lines[0]): mo = sx.mydict(date=sx.gts(),msgfrom=msgfrom,addr=addr,echoarea=lines[0],msgto=lines[1],subj=lines[2],msg='\n'.join(lines[4:])) return mo