int MTime::gmttotime(VString line){ // Friday, 31-Dec-99 23:59:59 GMT line=PartLineOT(line, ","); dspacev(line, 7); if(line<22) return 0; day=line.str(0,2).toi(); year=line.str(7,4).toi(); hour=line.str(12,2).toi(); minute=line.str(15,2).toi(); sec=line.str(18,2).toi(); for(int i=0; i<12; i++) if(cmp(mtmonths[i].data, line.data+3, 3)){ month=i+1; break; } return mktime(year, month, day, hour, minute, sec, 1); }
VString PartLineST(VString line, VString &two){ // one = "Text Part ONe" [Space || Tab] "Text Part Two" -> two unsigned char *ln = line, *to =line.endu(); while(ln < to && (*ln != ' ' || *ln !='\t')) ln ++; if(ln == to){ two.Clean(); return line; } line = line.str(ln - line.data); while(ln < to && (*ln == ' ' || *ln =='\t')) ln ++; two.setu(ln, to - ln); return line; }
int TgBotCall(LightServerAccept &acc, VString head, VString post){ XDataCont ct(post); XDataPEl message = ct("message"); XDataPEl chat = message("chat"); VString text = message["text"]; VString chat_id = chat["id"]; if(message && text){ text = Replace(text, "\\/", "/"); print("Message from: ", chat_id, ", text: ", text, "\r\n"); if(text[0] == '/') TgBotCallCmd(chat_id, text.str(1)); else return TgBotCallMsg(chat_id, text); return 1; } return 0; }