def telegram(channelname, msg, sid): for item in Rooms: roomchat = item['channel_post']['chat'] if channelname == roomchat['title'] and DarkNet_Notice.select().where(DarkNet_Notice.sid == sid): rid = roomchat['id'] bot.sendMessage(rid, msg) query = DarkNet_Notice.update({ 'telegram': True }).where(DarkNet_Notice.sid == sid) query.execute()
def get_model_details(uid, sid): details = DarkNet_DataSale.select().where( (DarkNet_DataSale.sid == sid)) person = DarkNet_Saler.select().where((DarkNet_Saler.uid == uid)) notice = DarkNet_Notice.select().where((DarkNet_Notice.sid == sid)) img = DarkNet_IMGS.select().where((DarkNet_IMGS.sid == sid)) return details, person, notice, img
def telegram_withpic(pic, details, sid, rid): # bot.sendDocument(rid,pic,details) # unpretty~ bot.sendPhoto(rid, pic, details) query = DarkNet_Notice.update({ "telegram": True }).where(DarkNet_Notice.sid == sid) query.execute()
def telegram_with_pic(pics, details, sid, rid): try: target = pics[0] gps_data = None for pic in pics: try: gps_data = read_exif_gps(copy.deepcopy(pic)) if gps_data: success(f"find gps data: {gps_data}") target = pic break except Exception as e: error(e) bot.sendPhoto( rid, target, details + (f"\nEXIF GPS: {gps_data}" if gps_data else "")) if gps_data: bot.sendLocation(rid, *gps_data[::-1]) query = DarkNet_Notice.update({ "telegram": True }).where(DarkNet_Notice.sid == sid) query.execute() except Exception as e: error(f"telegram_with_pic: {e}")
def create_notice(datas): return DarkNet_Notice.create(**datas)
def GetDetails(self, url, muti): # time.sleep(2) resp = self.session.get(url) resp.encoding = "utf8" self.CheckIfNeedLogin(resp) jqdata = jq(resp.text) jqdetail = jqdata(".v_table_1") jqperson = jqdata(".v_table_2") try: uid = FixNums(jqperson("tr:nth-child(5) > td:nth-child(2)").text()) sid = FixNums(jqdetail("tr:nth-child(3) > td:nth-child(2)").text()) details = DarkNet_DataSale.select().where( (DarkNet_DataSale.sid == sid)) person = DarkNet_Saler.select().where((DarkNet_Saler.uid == uid)) notice = DarkNet_Notice.select().where((DarkNet_Notice.sid == sid)) img = DarkNet_IMGS.select().where((DarkNet_IMGS.sid == sid)) personDatas = { "salenums": FixNums(jqperson("tr:nth-child(3) > td:nth-child(4)").text()), "totalsales": float(jqperson("tr:nth-child(5) > td:nth-child(4)").text()), "totalbuys": float(jqperson("tr:nth-child(7) > td:nth-child(4)").text()), } username = jqperson("tr:nth-child(3) > td:nth-child(2)").text() if not person: personDatas.update({ "uid": uid, "user": username, "regtime": moment.date( jqperson("tr:nth-child(7) > td:nth-child(2)").text()). format("YYYY-MM-DD"), }) person = DarkNet_Saler.create(**personDatas) else: DarkNet_Saler.update(personDatas).where( (DarkNet_Saler.uid == uid)).execute() person = person[0].uid if not notice: notice = DarkNet_Notice.create(**{"sid": sid}) else: notice = notice[0].sid detailImages = None detailContent = " ".join( jqdata(".postbody .content").text().split()) if not img: urls = [_.attr("src") for _ in jqdata(".postbody img").items()] img = DarkNet_IMGS.create(**{ "sid": sid, "img": urls, "detail": detailContent }) detailImages = self.SavePics(urls, sid) else: img = img[0].sid currentYear = moment.now().year soldNum = FixNums( jqdetail("tr:nth-child(7) > td:nth-child(4)").text(), to=99999) toCurrentYearDateTime = moment.date( f"{currentYear} " + jqdetail("tr:nth-child(3) > td:nth-child(6)").text()) RealUpTimeJQ = jqdata(".author") RealUpTimeJQ.remove("a") RealUpTimeJQ.remove("span") RealUpTime = moment.date(RealUpTimeJQ.text().replace( "年", "").replace("月", "").replace("日", "")) RealUpTime = RealUpTime if RealUpTime._date else toCurrentYearDateTime detailsDatas = { "lasttime": moment.date(f"{currentYear} " + jqdetail("tr:nth-child(7) > td:nth-child(6)").text( )).format("YYYY-MM-DD HH:mm:ss"), "priceBTC": float( jqdetail( "tr:nth-child(3) > td:nth-child(4) > span").text()), "priceUSDT": float( jqdetail("tr:nth-child(5) > td:nth-child(4)").text().split( )[0]), "lines": muti["lines"], "uptime": RealUpTime.format("YYYY-MM-DD HH:mm:ss"), "hot": muti["hot"], "types": jqdetail("tr:nth-child(5) > td:nth-child(2)").text(), "status": jqdetail("tr:nth-child(7) > td:nth-child(2)").text(), "oversell": jqdetail("tr:nth-child(9) > td:nth-child(2)").text(), "sold": soldNum, } if not details: detailsDatas.update({ "sid": sid, "user": person, "area": muti["area"], "title": muti["title"], "detailurl": url, "img": img, "notice": notice, }) details = DarkNet_DataSale.create(**detailsDatas) self.MakeMsg(details, detailContent, detailImages, sid, username) else: self.warn(f'-{RealUpTime}- {muti["title"]}') DarkNet_DataSale.update(detailsDatas).where( (DarkNet_DataSale.sid == sid)).execute() except Exception as e: self.error(f"GetDetails {e}") self.SaveError("error_264.html", resp) raise
def telegram(msg, sid, rid): bot.sendMessage(rid, msg) query = DarkNet_Notice.update({ "telegram": True }).where(DarkNet_Notice.sid == sid) query.execute()