def data_models_updater(self, thread_name, models): while True: try: logger.debug(f"updating data model {thread_name}") for x in models: x.update_data() x.store_in_pystore() x.save_to_csvs() time.sleep(5) if JalaliDatetime.now().hour < 16: time.sleep((16 - JalaliDatetime.now().hour) * 3600 + 100) else: time.sleep((40 - JalaliDatetime.now().hour) * 3600 + 100) except: logger.exception("WTF in data_model_updater")
def test_dilami_date(): gdate = datetime(2018, 2, 1) ddate = DilamiDatetime(gdate, tzinfo=TehranTimezone) assert ddate.year == 1591 assert ddate.month == 6 assert ddate.day == 28 ddate = DilamiDatetime(1591, 6, 28, tzinfo=TehranTimezone) assert ddate ddate = DilamiDatetime(1592, 5, 1, tzinfo=TehranTimezone) dilami_date = DilamiDatetime(ddate) assert dilami_date # Check Dilami date return today ddate = DilamiDatetime().now() jy, jm, jd = dilami_to_jalali(ddate.year, ddate.month, ddate.day) today = JalaliDatetime.now(TehranTimezone()) assert today.year == jy assert today.month == jm assert today.day == jd with freeze_time(datetime.now()): dilami_now = DilamiDatetime(datetime.now()).to_datetime() assert dilami_now.time() == datetime.now().time() now = datetime.now() dilami_date = DilamiDatetime(now) assert dilami_date.to_date() == now.date()
def __init__(self, payment_type, price, is_paid=False): self.uuid = uuid.uuid4() self.payment_type = payment_type self.is_paid = is_paid self.datetime = datetime.now() self.price = price self.jalali_datetime = JalaliDatetime.now() self.payment_list.append(self) super().__init__()
def crawling_thread(self, thread_name, start_date, q_xls): while True: if start_date < date.today(): end_date_jalali = JalaliDate.today() if JalaliDatetime.now().hour < 14: end_date_jalali = end_date_jalali - timedelta(days=1) self.crawl(start_date, end_date_jalali.todate(), q_xls) start_date = end_date_jalali.todate() with open(f'{self.excel_location}/crawlstat', 'w') as statfile: lastcheck = JalaliDatetime.now() print("last check:", file=statfile) print(lastcheck, file=statfile) print("last crawl:", file=statfile) print(end_date_jalali, file=statfile) if JalaliDatetime.now().hour < 16: time.sleep((16 - JalaliDatetime.now().hour) * 3600 + 100) else: time.sleep((40 - JalaliDatetime.now().hour) * 3600 + 100)
def __init__(self, item_dict, in_out, payment_type='cash', table=None): self.uuid = uuid.uuid4() self.item_dict = item_dict self.in_out = in_out self.bill = self.set_bill(payment_type) self.table = table self.datetime = datetime.now() self.jalali_datetime = JalaliDatetime.now() self.order_list.append(self) super().__init__()
def __init__(self, name, item_type, price): self.uuid = uuid.uuid1() self.name = name self.item_type = item_type self.type_handler(self, item_type) self.price = price self.datetime = datetime.now() self.jalali_datetime = JalaliDatetime.now() self.item_id = self.id_generator() self.item_list.append(self) super().__init__()
def __init__( self, year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None, tzinfo=None, ): if callable(tzinfo): tzinfo = tzinfo() if isinstance(year, datetime): jd = JalaliDatetime(year, tzinfo=tzinfo) year, month, day = j2d(jd.year, jd.month, jd.day) hour, minute, second, microsecond = ( jd.hour, jd.minute, jd.second, jd.microsecond, ) elif isinstance(year, DilamiDatetime): dd = year year, month, day, hour, minute, second, microsecond = ( dd.year, dd.month, dd.day, dd.hour, dd.minute, dd.second, dd.microsecond, ) jdt = JalaliDatetime.now(tzinfo) dy, dm, dd = j2d(jdt.year, jdt.month, jdt.day) self.year = year if year else dy self.month = month if month is not None else dm self.day = day if day is not None else dd self.year, self.month, self.day = self._validate( self.year, self.month, self.day ) self._hour = hour if hour else jdt.hour self._minute = minute if minute else jdt.minute self._second = second if second else jdt.second self._microsecond = microsecond if microsecond else jdt.microsecond self._time = time( self._hour, self._minute, self._second, self._microsecond, tzinfo )
def clean_start_time(self, *args, **kwargs): year, month, day = self.cleaned_data['start_time'].strftime( '%Y-%m-%d').split('-') hours, minutes, seconds = self.cleaned_data['start_time'].strftime( '%H:%M:%S').split(':') shamsi = jd(int(year), int(month), int(day), int(hours), int(minutes), int(seconds)) # import pdb; pdb.set_trace() four_hours_later = jd.now() + timedelta(hours=4) result = four_hours_later - shamsi.now() threshold = result.total_seconds() / 3600 if threshold < 4: raise forms.ValidationError( 'مدت انتظار هر سفر حداقل چهار ساعت است.') # return converted to miladi return shamsi.todatetime()
def now(cls, tz=None): jalali_date = JalaliDatetime.now(tz) dy, dm, dd = j2d(jalali_date.year, jalali_date.month, jalali_date.day) return cls(dy, dm, dd, tzinfo=tz)
def main_multi() : try : if not db.sismember("bot:users",m.from_user.id) : sub = None if m.text and m.text.startswith("/start ") : sub = m.text.replace("/start ","") if sub and db.sismember("bot:users",int(sub)) : sub = int(sub) db.sadd("user:"******":subs",m.from_user.id) try : bot.send_message(sub,'🚀 کاربر\n'+inf(m.from_user)+'\nبه عنوان زیر مجموعه شما وارد ربات شد.') except : pass w = ug(m.from_user.id,"waiting") if ug(m.from_user.id, "geted_link") : check = False try : check = bot.get_chat_member("@"+channel , m.from_user.id).status in ["creator", "administrator", "member"] except : pass if check == False : markup = types.InlineKeyboardMarkup() markup.row(types.InlineKeyboardButton(text="@"+channel,url="https://telegram.me/"+channel)) bot.reply_to(m, string["join_channel"], reply_markup = markup) return if m.text.startswith("/start") or not db.sismember("bot:users",m.from_user.id) : db.sadd("bot:users",m.from_user.id) bot.reply_to(m,string["start"].format(m.from_user.first_name, JalaliDatetime.now().strftime('%A'), internet_cmd),reply_markup = mainkb(m.from_user.id)) us(m.from_user.id,"waiting","main") elif m.text == string["status"] : bot.reply_to(m, string["status_txt"].format(link_cmd, members_must, db.scard("user:"******":subs")), reply_markup = mainkb(m.from_user.id)) elif m.text == link_cmd : us(m.from_user.id, "geted_link", True) file = open(adv_photo, "rb") bot.send_photo(m.chat.id, file, string["link_txt"].format(boti_info.username, m.from_user.id), reply_markup = mainkb(m.from_user.id), reply_to_message_id = m.message_id) file.close() elif m.text == internet_cmd : markup = types.ReplyKeyboardMarkup(resize_keyboard = True) markup.add(*internet_choices) bot.reply_to(m, string["internet_choose"], reply_markup = markup) us(m.from_user.id, "waiting", "ich") elif w == "ich" : if m.text in internet_choices : bot.reply_to(m, string["ich_send_num"], reply_markup = types.ReplyKeyboardRemove(selective = True)) us(m.from_user.id, "waiting", "ich2") else : bot.reply_to(m, string["ich_error"], reply_markup = markup) elif w == "ich2" : bot.reply_to(m, string["ich_submited"].format(link_cmd, members_must), reply_markup = mainkb(m.from_user.id)) us(m.from_user.id, "waiting", "main") elif m.from_user.id in admins : if m.text == "/stats" : bot.reply_to(m,"💠 تعداد کاربران : "+str(db.scard("bot:users"))) elif m.text.startswith("/bc ") : ntime = time() textt = m.text.replace("/bc ","") glist = db.smembers("bot:users") agcount = len(glist) suc = 0 fail = 0 bot.reply_to(m,"شروع شد!") for gp in glist : try : bot.send_message(gp,textt) suc += 1 except Exception as e : se = str(e) if "Bad Request: message to forward not found" in se : bot.reply_to(m,"🔸 پیام برای ارسال یافت نشد.") if suc != 0 : bot.reply_to(m,"✨ پیام به "+str(suc + fail)+" کاربر از "+str(agcount)+" کاربر ربات ارسال شد\n\n☑️ موفق : "+str(suc)+"\n\n🔘 ناموفق : "+str(fail)) us(bid,m.from_user.id,"waiting","main") return elif "bot was blocked by the user" in se: inviter = ug(gp,"host") if inviter : bot.send_message(inviter,"😪 کاربر "+inf(int(gp))+" از لیست کاربران شما حذف شد .") db.srem("bot:users",gp) fail += 1 bot.reply_to(m,"✨ پیام به "+str(suc + fail)+" کاربر از "+str(agcount)+" کاربر ربات ارسال شد\n\n☑️ موفق : "+str(suc)+"\n\n🔘 ناموفق : "+str(fail)+"\nزمان : "+timetostr(time() - ntime)) except Exception as e : exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno,e)
def handle(msg): content_type, chat_type, chat_id = telepot.glance(msg) if content_type == 'text': command = msg['text'] print('Got command: %s' % command) mss = command mss = mss.replace('/', ',') mss = mss.replace('.', ',') mss = mss.replace('-', ',') mss = mss.split(',') now = JalaliDatetime.now() zz = "" zzz = '' kk = 0 if len(mss) < 3: if command == 'Time': ss = str(datetime.datetime.now()) elif command == '/help': sss = 'سلام واسه استفاده بايد تاريخ رو با يکي از فرمت هاي زير وارد کني' + '\n' + '1364/3/27' + '\n' + '1382-3-27' + '\n' + '1373.1.15' + '\n' + '1373,4,5' ss = str(sss) elif command == 'راهنما': sss = 'سلام واسه استفاده بايد تاريخ رو با يکي از فرمت هاي زير وارد کني' + '\n' + '1364/3/27' + '\n' + '1382-3-27' + '\n' + '1373.1.15' + '\n' + '1373,4,5' ss = str(sss) elif command == '/start': markupp = ReplyKeyboardMarkup(keyboard=[['راهنما']], resize_keyboard=True) bot.sendMessage(chat_id, "خیلی خوش اومدی لطفا یه تاریخ وارد کن", reply_markup=markupp) elif command == 'ممنون': ss = str("خواهش میکنم مهربون .. قابلی نداشت ") elif command == 'احمق': ss = str("خودتی") else: ss = 'اگه میشه تاریخ رو اینجوری وارد کن تا من بتونم بخونمش' + '\t' + '1372.11.5' kk = 1 else: databa = User.query.filter_by(name=str(chat_id)) if databa.count() > 0: tedadestefade = databa.count() com = databa[tedadestefade - 1].comment sumofuse = db.session.query(User).count() markup = ReplyKeyboardMarkup(keyboard=[[command], ['راهنما']], resize_keyboard=True) bot.sendMessage(chat_id, command, reply_markup=markup) old = JalaliDatetime(int(mss[0]), int(mss[1]), int(mss[2])) dif = [ 100, 200, 222, 300, 333, 400, 444, 500, 555, 600, 666, 700, 777, 800, 888, 900, 999, 1000, 1111, 2000, 2222, 3000, 3333, 4000, 4444, 5000, 5555, 6000, 6006, 6116, 6226, 6336, 6446, 6556, 6666, 6776, 6886, 6996, 7000, 7007, 7100, 7117, 7200, 7227, 7300, 7337, 7400, 7447, 7500, 7557, 7600, 7667, 7700, 7777, 7800, 7887, 7900, 7997, 8000, 8100, 8200, 8228, 8300, 8338, 8400, 8448, 8500, 8558, 8668, 8778, 8888, 9000, 9009, 9999, 10000, 11111, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 21000, 22000, 22222, 23000, 24000, 25000, 26000, 27000 ] i = 0 d = (now - old).days if now.dayofyear() < old.dayofyear(): ruzt = old.dayofyear() - now.dayofyear() else: ruzt = old.dayofyear() + 365 - now.dayofyear() ss = 'سلام امروز ' + str(d) + ' روزه هستی ' ss = ss + "\n" + str(ruzt) + " روز مونده تا به دنیا بیای " zzz = " you are " + str(d) + " days old " cc = d for x in dif: dif1 = datetime.timedelta(x) date = old + dif1 jdate = JalaliDatetime(date) if (jdate > now and i < 10): ss = ss + '\n' + str( jdate.strftime('%A %D %B %N')) + ' میشی ' + str( dif1.days) + " روزه " if (i < 1): zz = zz + '\n' + 'You will be ' + str( dif1.days) + ' days old in the next ' + str( dif1.days - cc) + ' days' i = i + 1 ss = ss + '\n' + '\n' + str( tedadestefade ) + " تعداد استفاده شما " + '\n' + str( sumofuse ) + " تعداد استفاده کل " + '\n' + 'مواظب خوبیات باش' + " @strixdaybot " zz = zz + '\n' + '\n' + ' Take care of your good behaviors' + '\n' + ' and appreciate your days of life' + '\n' + '\n' + '\n' + '\n' + '\n' + ' telegram: @strixdaybot ' img = requests.get("http://behkaroma.ir/p.jpg") ff = requests.get("http://behkaroma.ir/p.ttf") font1 = ImageFont.truetype(StringIO(ff.content), 30) font2 = ImageFont.truetype(StringIO(ff.content), 40) font3 = ImageFont.truetype(StringIO(ff.content), 50) image = Image.open(StringIO(img.content)) draw = ImageDraw.Draw(image) draw.text((30, 150), zzz, (0, 0, 0), font=font3) draw.text((20, 400), zz, (255, 255, 255), font=font1) bio = BytesIO() bio.name = 'image.jpeg' image.save(bio, 'JPEG') bio.seek(0) if (kk == 0): if len(zz) > 10: bot.sendPhoto(chat_id, photo=bio) reg = User(str(chat_id), command) print(reg) db.session.add(reg) db.session.commit() bot.sendMessage(chat_id, text=ss)
def to_jalali(date_time): """Converts datetime object to Jalali datetime object """ offset_hour = 4 if JalaliDatetime.now(TehranTimezone()).month <= 6 else 3 date_time = date_time + timedelta(hours=offset_hour, minutes=30) return JalaliDatetime(date_time, TehranTimezone())
def now(): raise NotImplementedError('BchDatetime Deprecation') return BchDatetime.from_jalali_datetime(JalaliDatetime.now())
def test_now(self): self.assertIsNotNone(JalaliDatetime.now()) self.assertIsNone(JalaliDatetime.now().tzinfo) self.assertIsNotNone(JalaliDatetime.now(TehranTimezone()).tzinfo)
class DriverTripForm(forms.ModelForm): start_time = forms.DateTimeField( initial=jd.now().strftime('%Y-%m-%d %H:%M:%S'), label=_('زمان و تاریخ حرکت')) passenger_capacity = forms.ChoiceField(choices=Trip.CAPACITIES, label=_('ظرفیت مسافر'), initial=4) suggested_price = forms.CharField(max_length=100000) def __init__(self, *args, **kwargs): super(DriverTripForm, self).__init__(*args, **kwargs) for field in self.fields.values(): field.error_messages = { 'required': _('فیلد {} اجباری است.'.format(field.label)) } self.fields['back_seat_price'].required = True class Meta: model = Trip fields = ('origin', 'destination', 'origin_region', 'destination_region', 'discount', 'gender', 'start_time', 'is_dispatcher', 'item_capacity', 'front_seat_price', 'back_seat_price', 'passenger_capacity', 'status', 'driver', 'type_creator', 'suggested_price') widgets = { "status": forms.HiddenInput(), "driver": forms.HiddenInput(), "type_creator": forms.HiddenInput(), } labels = { "origin": _('مبدا'), "destination": _('مقصد'), "origin_region": _('ناحیه مبدا'), "destination_region": _('ناحیه مقصد'), "discount": _('میزان تخفیف'), "gender": _('جنسیت سفر'), "start_time": _('تاریخ و زمان حرکت'), "front_seat_price": _('قیمت صندلی جلو'), "back_seat_price": _('قیمت صندلی عقب'), "passenger_capacity": _('ظرفیت مسافر'), "item_capacity": _('ظرفیت بار'), "is_dispatcher": _('امکان ارسال مرسوله'), } def clean(self, *args, **kwargs): origin = self.cleaned_data.get('origin') destination = self.cleaned_data.get('destination') front_price = self.cleaned_data.get('front_seat_price') back_price = self.cleaned_data.get('back_seat_price') passenger_cap = self.cleaned_data.get('passenger_capacity') price = self.cleaned_data.get('suggested_price') distance = Distance.objects.filter(url__contains=origin.name).filter( url__contains=destination.name)[0] if int(price) > distance.price or int( front_price) > distance.price or int( back_price) > distance.price: raise forms.ValidationError( 'قیمت فیلدهای صندلی جلو، صندلی عقب و قیمت پیشنهادی نمی تواند بیشتر از قیمت پیشنهاد داده شده باشد.' ) driver = self.cleaned_data.get('driver') if Trip.objects.has_active_trip(driver): raise forms.ValidationError('شما یک سفر فعال دارید.') if origin == destination: raise forms.ValidationError('مبدا و مقصد نمی توانند یکی باشند.') if not passenger_cap: raise forms.ValidationError( 'تعداد ظرفیت مسافرین را وارد نکرده اید.') if not front_price: if front_price == 0: cap = int(passenger_cap) if cap > 3: raise forms.ValidationError( 'زمانی که صندلی جلو پر باشد، ظرفیت حداکثر تا سه نفر می تواند باشد.' ) else: raise forms.ValidationError('قیمت صندلی جلو را وارد نکرده اید') if not back_price: raise forms.ValidationError('قیمت صندلی عقب را وارد نکرده اید') def clean_origin_region(self, *args, **kwargs): if self.cleaned_data.get('origin_region') == 0: raise forms.ValidationError('شهری ابتدا انتخاب کنید') return self.cleaned_data.get('origin_region') def clean_destination_region(self, *args, **kwargs): if self.cleaned_data.get('destination_region') == 0: raise forms.ValidationError('شهری ابتدا انتخاب کنید') return self.cleaned_data.get('destination_region') def clean_start_time(self, *args, **kwargs): year, month, day = self.cleaned_data['start_time'].strftime( '%Y-%m-%d').split('-') hours, minutes, seconds = self.cleaned_data['start_time'].strftime( '%H:%M:%S').split(':') shamsi = jd(int(year), int(month), int(day), int(hours), int(minutes), int(seconds)) # import pdb; pdb.set_trace() four_hours_later = jd.now() + timedelta(hours=4) result = four_hours_later - shamsi.now() threshold = result.total_seconds() / 3600 if threshold < 4: raise forms.ValidationError( 'مدت انتظار هر سفر حداقل چهار ساعت است.') # return converted to miladi return shamsi.todatetime()
def new_chat_members(msg): try: mems = msg.new_chat_members s = bot.get_chat_member(msg.chat.id, msg.from_user.id).status for i in mems: if i.id == bot.get_me().id: if is_admin(msg.from_user.id) or s == "creator": print colored("Bot Added To Group > {} | [{}] ({}) [@{}]".format(msg.chat.title, msg.from_user.first_name, msg.from_user.id, msg.from_user.username or '---'), "yellow"), colored("\n"+JalaliDatetime.now().strftime('%C'), 'cyan') for i in admins: bot.send_message(i, "گروه جدیدی در تاریخ {} به لیست گروه های تحت مدیریت ربات اضافه شد\n\nنام گروه : {}\nاطلاعات کاربر اضافه کننده :\n نام : {}\nآیدی : {}\nیوزرنیم : @{}\n".format(JalaliDatetime.now().strftime('%C'), msg.chat.title, msg.from_user.first_name, msg.from_user.id, msg.from_user.username or '---')) redis.sadd("{}:groups_list".format(msg.from_user.id), msg.chat.id) redis.set("{}:b_owner".format(msg.chat.id), msg.from_user.id) redis.sadd('supergroupsbot',msg.chat.id) bot.reply_to(msg, "{} عزیز \nگروه {} فعال گردید و به لیست گروه های شما اضافه شد.".format(msg.from_user.first_name, msg.chat.title)) else: bot.reply_to(msg, "کاربر گرامی،\nبرای فعال شدن ربات باید مالک گروه/مالک ربات آن را به گروه افزوده کند.") bot.leave_chat(msg.chat.id) else: if msg.from_user.id != i.id: if i.username.endswith("bot"): if get_bots(msg.chat.id): redis.sadd("{}:adds:{}".format(msg.from_user.id, msg.chat.id), i.id) else: redis.sadd("{}:adds:{}".format(msg.from_user.id, msg.chat.id), i.id) except Exception as e: bot.reply_to(msg, "شما یک کاربر اضافه کردید") print colored(e, "red")
def test_now(self): self.assertTrue(JalaliDatetime.now() != None)
def handle(msg): content_type, chat_type, chat_id = telepot.glance(msg) if content_type == 'text': command = msg['text'] print('Got command: %s' % command) mss = command mss = mss.replace('/', ',') mss = mss.replace('.', ',') mss = mss.replace('-', ',') mss = mss.split(',') now = JalaliDatetime.now() zz = "" zzz = '' kk = 0 if len(mss) < 3: if command == 'Time': ss = str(datetime.datetime.now()) elif command == '/help': sss = 'سلام واسه استفاده بايد تاريخ رو با يکي از فرمت هاي زير وارد کني' + '\n' + '1364/3/27' + '\n' + '1382-3-27' + '\n' + '1373.1.15' + '\n' + '1373,4,5' ss = str(sss) elif command == '/start': ss = str("خیلی خوش اومدی لطفا یه تاریخ وارد کن") elif command == 'ممنون': ss = str("خواهش میکنم مهربون .. قابلی نداشت ") elif command == 'احمق': ss = str("خودتی") else: ss = 'اگه میشه تاریخ رو اینجوری وارد کن تا من بتونم بخونمش' + '\t' + '1372.11.5' kk = 1 else: old = JalaliDatetime(int(mss[0]), int(mss[1]), int(mss[2])) dif = [ 100, 200, 222, 300, 333, 400, 444, 500, 555, 600, 666, 700, 777, 800, 888, 900, 999, 1000, 1111, 2000, 2222, 3000, 3333, 4000, 4444, 5000, 5555, 6000, 6006, 6116, 6226, 6336, 6446, 6556, 6666, 6776, 6886, 6996, 7000, 7007, 7100, 7117, 7200, 7227, 7300, 7337, 7400, 7447, 7500, 7557, 7600, 7667, 7700, 7777, 7800, 7887, 7900, 7997, 8000, 8100, 8200, 8228, 8300, 8338, 8400, 8448, 8500, 8558, 8668, 8778, 8888, 9000, 9009, 9999, 10000, 11111, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 21000, 22000, 22222, 23000, 24000, 25000, 26000, 27000 ] i = 0 d = (now - old).days ss = 'سلام امروز ' + str(d) + ' روزه هستی ' zzz = " you are " + str(d) + " days old " cc = d for x in dif: dif1 = datetime.timedelta(x) date = old + dif1 jdate = JalaliDatetime(date) if (jdate > now and i < 10): ss = ss + '\n' + str( jdate.strftime('%A %D %B %N')) + ' میشی ' + str( dif1.days) + " روزه " if (i < 1): zz = zz + '\n' + 'You will be ' + str( dif1.days) + ' days old in the next ' + str( dif1.days - cc) + ' days' i = i + 1 ss = ss + '\n' + '\n' + 'مواظب خوبیات باش' + " @strixdaybot " zz = zz + '\n' + '\n' + ' Take care of your good behaviors' + '\n' + ' and appreciate your days of life' + '\n' + '\n' + '\n' + '\n' + '\n' + ' telegram: @strixdaybot ' img = requests.get("http://behkaroma.ir/p.jpg") ff = requests.get("http://behkaroma.ir/p.ttf") font1 = ImageFont.truetype(StringIO(ff.content), 30) font2 = ImageFont.truetype(StringIO(ff.content), 40) font3 = ImageFont.truetype(StringIO(ff.content), 50) image = Image.open(StringIO(img.content)) draw = ImageDraw.Draw(image) draw.text((30, 150), zzz, (0, 0, 0), font=font3) draw.text((20, 400), zz, (255, 255, 255), font=font1) bio = BytesIO() bio.name = 'image.jpeg' image.save(bio, 'JPEG') bio.seek(0) if (kk == 0): bot.sendPhoto(chat_id, photo=bio) bot.sendMessage(chat_id, text=ss)