def setup_torrent(self): self.torrent.startSession() upload_limit = self.__settings__.getSetting("upload_limit") if self.__settings__.getSetting( "upload_limit") != "" else 0 if 0 < int(upload_limit): self.torrent.setUploadLimit(int(upload_limit) * 1000000 / 8) # MBits/second download_limit = self.__settings__.getSetting("download_limit") if self.__settings__.getSetting( "download_limit") != "" else 0 if 0 < int(download_limit): self.torrent.setDownloadLimit( int(download_limit) * 1000000 / 8) # MBits/second self.torrent.status = False self.fullSize = self.torrent.getFileSize(self.contentId) Offset = calculate(self.fullSize) # print 'Offset: '+str(Offset) # mp4 fix label = os.path.basename(self.torrent.getFilePath(self.contentId)) isMP4 = False if '.' in label: ext = label.split('.')[-1] if ext.lower() == 'mp4': isMP4 = True # print 'setup_torrent: '+str((self.contentId, Offset, isMP4, label, ext)) self.torrent.continueSession(self.contentId, Offset=Offset, isMP4=isMP4)
def setup_torrent(self): self.torrent.initSession() if self.__settings__.getSetting("encryption") == "true": self.torrent.encryptSession() self.torrent.startSession() upload_limit = ( self.__settings__.getSetting("upload_limit") if self.__settings__.getSetting("upload_limit") != "" else 0 ) if 0 < int(upload_limit): self.torrent.setUploadLimit(int(upload_limit) * 1024 * 1024 / 8) # MBits/second download_limit = ( self.__settings__.getSetting("download_limit") if self.__settings__.getSetting("download_limit") != "" else 0 ) if 0 < int(download_limit): self.torrent.setDownloadLimit(int(download_limit) * 1024 * 1024 / 8) # MBits/second self.torrent.status = False self.fullSize = self.torrent.getFileSize(self.contentId) Offset = calculate(self.fullSize) debug("Offset: " + str(Offset)) # mp4 fix label = os.path.basename(self.torrent.getFilePath(self.contentId)) isMP4 = False if "." in label and str(label.split(".")[-1]).lower() == "mp4": isMP4 = True debug("setup_torrent: " + str((self.contentId, Offset, isMP4, label))) self.torrent.continueSession(self.contentId, Offset=Offset, isMP4=isMP4)
def setup_torrent(self): self.torrent.initSession() if self.__settings__.getSetting('encryption') == 'true': self.torrent.encryptSession() self.torrent.startSession() upload_limit = self.__settings__.getSetting( "upload_limit" ) if self.__settings__.getSetting("upload_limit") != "" else 0 if 0 < int(upload_limit): self.torrent.setUploadLimit(int(upload_limit) * 1024 * 1024 / 8) # MBits/second download_limit = self.__settings__.getSetting( "download_limit" ) if self.__settings__.getSetting("download_limit") != "" else 0 if 0 < int(download_limit): self.torrent.setDownloadLimit( int(download_limit) * 1024 * 1024 / 8) # MBits/second self.torrent.status = False self.fullSize = self.torrent.getFileSize(self.contentId) self.path = self.torrent.getFilePath(self.contentId) Offset = calculate(self.fullSize) debug('Offset: ' + str(Offset)) # mp4 fix label = os.path.basename(self.path) isMP4 = False if '.' in label and str(label.split('.')[-1]).lower() == 'mp4': isMP4 = True debug('setup_torrent: ' + str((self.contentId, Offset, isMP4, label))) self.torrent.continueSession(self.contentId, Offset=Offset, isMP4=isMP4)
def eval_genome(genomes, config): for genome_id, genome in genomes: genome.fitness = 0 net = neat.nn.recurrent.RecurrentNetwork.create(genome, config) p = subprocess.Popen("2048-qt") time.sleep(2) os.system('import -window "2048 Game" picture.jpg') x,score = func.calculate() d_u_v = [0 for i in range(4)] d_u = 0 prev_x = x genome.fitness = score # print(satisfied(x)) step = 0 death = 1 death_flag = 0 while func.satisfied(x): output = net.activate(x) dic_used = func.action(output) if d_u_v[dic_used] == 0: d_u += 1 d_u_v[dic_used] = 1 time.sleep(1) os.system('import -window "2048 Game" picture.jpg') x,score = func.calculate() if x == prev_x: if death_flag == 0: death = -5 death_flag = 1 else: death += 1 else: death_flag = 0 death = 1 prev_x = x if death == 0: break genome.fitness = score*d_u print("Genome: ",genome_id) print("Fitness: ", genome.fitness) p.terminate()
def update(self): # set information about the process self.integer_progress_show.set("updating") self.integer_error_com.set("") # boom angle get data self.ser_boom.write("#0%d\r\n".encode() % self.ID) time.sleep(0.1) boom_angle_read = self.ser_boom.readline() # cable length get data # ceate a package for requesting data: EOT 1 1 : 9 ENQ packet1 = bytearray() packet1.append(0x04) packet1.append(0x31) packet1.append(0x31) packet1.append(0x3A) packet1.append(0x39) packet1.append(0x05) self.ser_cable.write(packet1) time.sleep(0.1) cable_length_read = self.ser_cable.readline() # boom angle proses data # calculate the actual angle of the boom # calculate cable angle and cable length boom_angle_read_string = boom_angle_read.decode() angle = (float(boom_angle_read_string[43:49]) * 1.25 + 59.8) calculated_angle = calculate(angle) # show angle, cable angle and cable length in the GUI self.integer_cable_angle.set(round(calculated_angle[1], 2)) self.integer_cable_length.set(round(calculated_angle[0], 2)) self.integer_angle.set(round(angle, 2)) # calculate x and y end points of the boom (not good yet) angle_in_radians = angle * math.pi / 180 line_length = 100 center_x = 3 center_y = 1 end_x = center_x * line_length * math.sin(angle_in_radians) end_y = center_y * line_length * math.cos(angle_in_radians) # extract the cable length from the received string cable_length_read_string = cable_length_read.decode() print("cable length str", cable_length_read_string) cable_length_read_int = int(cable_length_read_string[4:10]) # draw crane interactive boom and cable self.canvas.delete(self.boom, self.wire, self.wire2, self.load) self.boom = self.canvas.create_line(200, 150, end_x, end_y, fill="black", width=3) # boom self.wire = self.canvas.create_line( 150, 49, end_x, end_y, width=2) # wire from the back of the crane to the boom self.wire2 = self.canvas.create_line( end_x, end_y, end_x, cable_length_read_int - 117100, fill="black", width=2) # wire from the boom to the load self.load = self.canvas.create_line(end_x - 5, cable_length_read_int - 117100, end_x + 5, cable_length_read_int - 117100, fill="black", width=2) # load # sent the angle over UDP to read it in in qinsy (format: $DATA,DATA,DATA) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP sock.sendto(bytes("$", "utf-8"), (self.udp_ip.get(), int(self.udp_port.get()))) sock.sendto(bytes(str(angle), "utf-8"), (str(self.udp_ip.get()), int(self.udp_port.get()))) # update the GUI root.update() # self.update_button.after(100, self.update) # time.sleep(0.1) self.update()
"""Основной файл для запуска приложения.""" from functions import calculate, matrix_from_file if __name__ == '__main__': matrix = matrix_from_file('input_file.txt') print('Введена матрица') print(matrix) print('Количество кратеров : ' + str(calculate(matrix)))
def test(self): self.assertEquals(4, calculate(2, 2))
import sys from data import * import functions as func for car in carList: print(car) for fruit in fruitList: print(fruit) sum, num1, num2 = func.calculate(2, 4) print(f'The sum is {sum}')
async def calc(ctx, num1='x', op='x', num2='x'): ans = functions.calculate(num1, op, num2) await ctx.send(ans)
from functions import calculate a = input('Valor A: ') b = input('Valor B: ') print(calculate(a, b))
def handle_keyboard_callback(update: Update, context=None): # Gets callback_data from the pushed button query = update.callback_query # Gets query from callback data = query.data # callback_data of pushed button chat_id = update.effective_message.chat_id # chat id for sending messages banks_individuals = db_banks.get_individuals() is_simple = False try: with open(f"personal/personal_{chat_id}.json", mode='r') as handle: if json.load(handle).get("is_simple"): is_simple = True else: is_simple = False except OSError: pass if data == CALLBACK_BUTTON_SIMPLE: bot.send_message(chat_id=update.effective_message.chat_id, text="Давайте определимся с вашим статусом. Вы:", reply_markup=InlineKeyboardFactory.get_individual_entity_keyboard()) InlineCallback.update_data({"is_simple": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_SIMPLE elif data == CALLBACK_BUTTON_STANDARD: bot.send_message(chat_id=update.effective_message.chat_id, text="Давайте определимся с вашим статусом. Вы:", reply_markup=InlineKeyboardFactory.get_individual_entity_keyboard()) InlineCallback.update_data({"is_simple": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_STANDARD elif data == CALLBACK_BUTTON_INDIVIDUAL: with open(f"personal/personal_{chat_id}.json") as handle: if json.load(handle)['is_simple']: bot.send_message(chat_id=update.effective_message.chat_id, text="Что для Вас важнее всего?", reply_markup=InlineKeyboardFactory.get_preferences_keyboard()) else: bot.send_message(chat_id=chat_id, text=f"Какой способ связи с банком вы предпочитаете?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_help_keyboard()) InlineCallback.update_data({"is_help_phone": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_email": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_vk": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_human": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_bot": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_individual": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_INDIVIDUAL elif data == CALLBACK_BUTTON_ENTITY: if is_simple: bot.send_message(chat_id=update.effective_message.chat_id, text="Ваша компания будет взаимодействовать с ДБО преимущественно с мобильных устройств или ПК?", reply_markup=InlineKeyboardFactory.get_mobile_pc_keyboard()) InlineCallback.update_data({"is_individual": False}, f"personal/personal_{chat_id}.json") else: bot.send_message(chat_id=update.effective_message.chat_id, text="Вам необходимы SMS-, e-mail-, push-уведомления о движениях по счёту?", reply_markup=InlineKeyboardFactory.get_sms_mail_push_keyboard()) InlineCallback.update_data({"is_individual": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_ENTITY elif data == CALLBACK_BUTTON_PRICE: # ЦЕНА bot.send_message(chat_id=chat_id, text=f"Вы предпочитаете вклады или инвестиции?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_invest_keyboard()) InlineCallback.update_data({"most_important": "price"}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_PRICE elif data == CALLBACK_BUTTON_RELIABILITY: # НАДЁЖНОСТЬ bot.send_message(chat_id=chat_id, text=f"Вы предпочитаете вклады или инвестиции?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_invest_keyboard()) InlineCallback.update_data({"most_important": "reliability"}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_RELIABILITY elif data == CALLBACK_BUTTON_CONVENIENCE: # УДОБСТВО bot.send_message(chat_id=chat_id, text=f"Вы предпочитаете вклады или инвестиции?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_invest_keyboard()) InlineCallback.update_data({"most_important": "convenience"}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_CONVENIENCE elif data == CALLBACK_BUTTON_DEPOSITS: bot.send_message(chat_id=chat_id, text=f"Вы желаете пользоваться контролем расходов?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_expenses_control_keyboard()) InlineCallback.update_data({"deposits_investments_both_account": 0}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_DEPOSITS elif data == CALLBACK_BUTTON_INVESTMENTS: bot.send_message(chat_id=chat_id, text=f"Вы желаете пользоваться контролем расходов?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_expenses_control_keyboard()) InlineCallback.update_data({"deposits_investments_both_account": 1}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_INVESTMENTS elif data == CALLBACK_BUTTON_DEPOSITS_INVESTMENTS: bot.send_message(chat_id=chat_id, text=f"Вы желаете пользоваться контролем расходов?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_expenses_control_keyboard()) InlineCallback.update_data({"deposits_investments_both_account": 2}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_DEPOSITS_INVESTMENTS elif data == CALLBACK_BUTTON_ONLY_ACCOUNT: bot.send_message(chat_id=chat_id, text=f"Вы желаете пользоваться контролем расходов?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_expenses_control_keyboard()) InlineCallback.update_data({"deposits_investments_both_account": 3}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_ONLY_ACCOUNT elif data == CALLBACK_BUTTON_EXPENSES_CONTROL_YES: bot.send_message(chat_id=chat_id, text=f"Вы используете Google Pay?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_gpay_keyboard()) InlineCallback.update_data({"is_expenses_control": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_EXPENSES_CONTROL_YES elif data == CALLBACK_BUTTON_EXPENSES_CONTROL_NO: bot.send_message(chat_id=chat_id, text=f"Вы используете Google Pay?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_gpay_keyboard()) InlineCallback.update_data({"is_expenses_control": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_EXPENSES_CONTROL_NO elif data == CALLBACK_BUTTON_GPAY_YES: InlineCallback.update_data({"is_gpay": True}, f"personal/personal_{chat_id}.json") if is_simple: bot.send_message(chat_id=chat_id, text=f"Какой способ связи с банком вы предпочитаете?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_help_keyboard()) InlineCallback.update_data({"is_help_phone": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_email": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_vk": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_human": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_bot": False}, f"personal/personal_{chat_id}.json") else: bot.send_message(chat_id=chat_id, text=f"Вы используете VISA или Mastercard?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_visa_mc_keyboard()) return CALLBACK_BUTTON_GPAY_YES elif data == CALLBACK_BUTTON_GPAY_NO: InlineCallback.update_data({"is_gpay": False}, f"personal/personal_{chat_id}.json") if is_simple: bot.send_message(chat_id=chat_id, text=f"Какой способ связи с банком вы предпочитаете?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_help_keyboard()) InlineCallback.update_data({"is_help_phone": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_email": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_vk": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_human": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_bot": False}, f"personal/personal_{chat_id}.json") else: bot.send_message(chat_id=chat_id, text=f"Выберите ограничение по стоимости ДБО:", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_standard_individual_price_keyboard()) return CALLBACK_BUTTON_GPAY_NO elif data == CALLBACK_BUTTON_VISA: bot.send_message(chat_id=chat_id, text=f"Выберите ограничение по стоимости ДБО:", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_standard_individual_price_keyboard()) InlineCallback.update_data({"is_visa": True}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_mastercard": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_VISA elif data == CALLBACK_BUTTON_MASTERCARD: bot.send_message(chat_id=chat_id, text=f"Выберите ограничение по стоимости ДБО:", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_standard_individual_price_keyboard()) InlineCallback.update_data({"is_visa": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_mastercard": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_MASTERCARD elif data == CALLBACK_BUTTON_VISA_MASTERCARD: bot.send_message(chat_id=chat_id, text=f"Выберите ограничение по стоимости ДБО:", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_standard_individual_price_keyboard()) InlineCallback.update_data({"is_visa": True}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_mastercard": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_VISA_MASTERCARD elif data == CALLBACK_BUTTON_NO_VISA_MC: bot.send_message(chat_id=chat_id, text=f"Выберите ограничение по стоимости ДБО:", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_standard_individual_price_keyboard()) InlineCallback.update_data({"is_visa": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_mastercard": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_NO_VISA_MC elif data == CALLBACK_BUTTON_HELP_PHONE or data == CALLBACK_BUTTON_HELP_EMAIL \ or data == CALLBACK_BUTTON_HELP_VK or data == CALLBACK_BUTTON_HELP_CHAT_HUMAN or data == CALLBACK_BUTTON_HELP_CHAT_BOT: with open(f"personal/personal_{chat_id}.json", mode='r') as handle: personal = json.load(handle) if data == CALLBACK_BUTTON_HELP_PHONE: if not personal['is_help_phone']: InlineCallback.update_data({"is_help_phone": True}, f"personal/personal_{chat_id}.json") else: InlineCallback.update_data({"is_help_phone": False}, f"personal/personal_{chat_id}.json") elif data == CALLBACK_BUTTON_HELP_EMAIL: if not personal['is_help_email']: InlineCallback.update_data({"is_help_email": True}, f"personal/personal_{chat_id}.json") else: InlineCallback.update_data({"is_help_email": False}, f"personal/personal_{chat_id}.json") elif data == CALLBACK_BUTTON_HELP_VK: if not personal['is_help_vk']: InlineCallback.update_data({"is_help_vk": True}, f"personal/personal_{chat_id}.json") else: InlineCallback.update_data({"is_help_vk": False}, f"personal/personal_{chat_id}.json") elif data == CALLBACK_BUTTON_HELP_CHAT_HUMAN: if not personal['is_help_chat_human']: InlineCallback.update_data({"is_help_chat_human": True}, f"personal/personal_{chat_id}.json") else: InlineCallback.update_data({"is_help_chat_human": False}, f"personal/personal_{chat_id}.json") elif data == CALLBACK_BUTTON_HELP_CHAT_BOT: if not personal['is_help_chat_bot']: InlineCallback.update_data({"is_help_chat_bot": True}, f"personal/personal_{chat_id}.json") else: InlineCallback.update_data({"is_help_chat_bot": False}, f"personal/personal_{chat_id}.json") with open(f"personal/personal_{chat_id}.json", mode='r') as handle: personal = json.load(handle) tmp = bot.send_message(text=f"Какой способ связи с банком вы предпочитаете?", chat_id=chat_id, reply_markup=InlineKeyboardFactory.get_help_keyboard( is_phone=personal['is_help_phone'], is_email=personal['is_help_email'], is_vk=personal['is_help_vk'], is_chat_h=personal['is_help_chat_human'], is_chat_bot=personal['is_help_chat_bot'])) bot.delete_message(chat_id=chat_id, message_id=tmp.message_id - 1) elif data == CALLBACK_BUTTON_HELP_NEXT: if is_simple: with open(f"personal/personal_{chat_id}.json", mode='r') as handle: personal = json.load(handle) if personal['is_individual']: bot.send_message(chat_id=chat_id, text=f"Желаете учитывать стоимость СМС-банкинга?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_sms_banking_keyboard()) else: bot.send_message(chat_id=chat_id, text=f"Спасибо за уделённое время, подводим итог...") calculate(chat_id=chat_id) else: with open(f"personal/personal_{chat_id}.json", mode='r') as handle: personal = json.load(handle) if personal['is_individual']: bot.send_message(chat_id=chat_id, text=f"Вы предпочитаете вклады или инвестиции?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_invest_keyboard()) else: bot.send_message(chat_id=chat_id, text=f"Спасибо за уделённое время, подводим итог...") calculate(chat_id=chat_id) return CALLBACK_BUTTON_HELP_NEXT elif data == CALLBACK_BUTTON_INDIVIDUAL_0_50: InlineCallback.update_data({"min price": 0}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"max price": 50}, f"personal/personal_{chat_id}.json") bot.send_message(chat_id=chat_id, text=f"Желаете учитывать стоимость СМС-банкинга?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_sms_banking_keyboard()) return CALLBACK_BUTTON_INDIVIDUAL_0_50 elif data == CALLBACK_BUTTON_INDIVIDUAL_0_150: InlineCallback.update_data({"min price": 0}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"max price": 150}, f"personal/personal_{chat_id}.json") bot.send_message(chat_id=chat_id, text=f"Желаете учитывать стоимость СМС-банкинга?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_sms_banking_keyboard()) return CALLBACK_BUTTON_INDIVIDUAL_0_150 elif data == CALLBACK_BUTTON_INDIVIDUAL_150_2000: InlineCallback.update_data({"min price": 150}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"max price": 2000}, f"personal/personal_{chat_id}.json") bot.send_message(chat_id=chat_id, text=f"Желаете учитывать стоимость СМС-банкинга?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_sms_banking_keyboard()) return CALLBACK_BUTTON_INDIVIDUAL_150_2000 elif data == CALLBACK_BUTTON_INDIVIDUAL_2000_10000: InlineCallback.update_data({"min price": 2000}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"max price": 10000}, f"personal/personal_{chat_id}.json") bot.send_message(chat_id=chat_id, text=f"Желаете учитывать стоимость СМС-банкинга?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_sms_banking_keyboard()) return CALLBACK_BUTTON_INDIVIDUAL_2000_10000 elif data == CALLBACK_BUTTON_INDIVIDUAL_10000_MORE: InlineCallback.update_data({"min price": 10000}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"max price": 999999999}, f"personal/personal_{chat_id}.json") bot.send_message(chat_id=chat_id, text=f"Желаете учитывать стоимость СМС-банкинга?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_sms_banking_keyboard()) return CALLBACK_BUTTON_INDIVIDUAL_10000_MORE elif data == CALLBACK_BUTTON_INDIVIDUAL_ANY_COST: InlineCallback.update_data({"min price": 0}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"max price": 999999999}, f"personal/personal_{chat_id}.json") bot.send_message(chat_id=chat_id, text=f"Желаете учитывать стоимость СМС-банкинга?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_sms_banking_keyboard()) return CALLBACK_BUTTON_INDIVIDUAL_ANY_COST elif data == CALLBACK_BUTTON_SMS_BANK_YES: InlineCallback.update_data({"sms": True}, f"personal/personal_{chat_id}.json") bot.send_message(chat_id=chat_id, text=f"Спасибо за уделённое время, подводим итог...") calculate(chat_id=chat_id) return CALLBACK_BUTTON_SMS_BANK_YES elif data == CALLBACK_BUTTON_SMS_BANK_NO: InlineCallback.update_data({"sms": False}, f"personal/personal_{chat_id}.json") bot.send_message(chat_id=chat_id, text=f"Спасибо за уделённое время, подводим итог...") calculate(chat_id=chat_id) return CALLBACK_BUTTON_SMS_BANK_NO # Only entity elif data == CALLBACK_BUTTON_NOTIFY_SMS: bot.send_message(chat_id=chat_id, text=f"Вас интересует возможность отправки писем, заверенных электронной подписью, в банк из системы ДБО?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_send_mail_keyboard()) InlineCallback.update_data({"notify": 1}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_NOTIFY_SMS elif data == CALLBACK_BUTTON_NOTIFY_SMS_EMAIL: if is_simple: bot.send_message(chat_id=chat_id, text=f"Ваша компания будет оперировать с валютой через ДБО?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_simple_currency_keyboard()) else: bot.send_message(chat_id=chat_id, text=f"Вас интересует возможность отправки писем, заверенных электронной подписью, в банк из системы ДБО?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_send_mail_keyboard()) InlineCallback.update_data({"notify": 2}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_NOTIFY_SMS_EMAIL elif data == CALLBACK_BUTTON_NOTIFY_ALL: if is_simple: bot.send_message(chat_id=chat_id, text=f"Ваша компания будет оперировать с валютой через ДБО?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_simple_currency_keyboard()) else: bot.send_message(chat_id=chat_id, text=f"Вас интересует возможность отправки писем в банк из системы ДБО?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_send_mail_keyboard()) InlineCallback.update_data({"notify": 3}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_NOTIFY_ALL elif data == CALLBACK_BUTTON_NOTIFY_NONE: if is_simple: bot.send_message(chat_id=chat_id, text=f"Ваша компания будет оперировать с валютой через ДБО?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_simple_currency_keyboard()) else: bot.send_message(chat_id=chat_id, text=f"Вас интересует возможность отправки писем в банк из системы ДБО?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_send_mail_keyboard()) InlineCallback.update_data({"notify": 0}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_NOTIFY_NONE elif data == CALLBACK_BUTTON_SEND_MAIL_YES: bot.send_message(chat_id=chat_id, text=f"Вам важна возможность отправки реестров на заработную плату?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_salary_registers_keyboard()) InlineCallback.update_data({"send_mail": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_SEND_MAIL_YES elif data == CALLBACK_BUTTON_SEND_MAIL_NO: bot.send_message(chat_id=chat_id, text=f"Вам важна возможность отправки реестров на заработную плату?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_salary_registers_keyboard()) InlineCallback.update_data({"send_mail": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_SEND_MAIL_NO elif data == CALLBACK_BUTTON_SALARY_REG_YES: bot.send_message(chat_id=chat_id, text=f"Должна ли система ДБО формировать сведения о валютных операциях?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_currency_transactions_keyboard()) InlineCallback.update_data({"salary_registers": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_SALARY_REG_YES elif data == CALLBACK_BUTTON_SALARY_REG_NO: bot.send_message(chat_id=chat_id, text=f"Должна ли система ДБО формировать сведения о валютных операциях?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_currency_transactions_keyboard()) InlineCallback.update_data({"salary_registers": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_SALARY_REG_NO elif data == CALLBACK_BUTTON_SIMPLE_CURRENCY_YES: bot.send_message(chat_id=chat_id, text=f"Выберите приемлемую стоимость услуг ДБО:", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_entity_price_keyboard()) InlineCallback.update_data({"using_currency": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_SIMPLE_CURRENCY_YES elif data == CALLBACK_BUTTON_SIMPLE_CURRENCY_NO: bot.send_message(chat_id=chat_id, text=f"Выберите приемлемую стоимость услуг ДБО:", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_entity_price_keyboard()) InlineCallback.update_data({"using_currency": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_SIMPLE_CURRENCY_NO elif data == CALLBACK_BUTTON_ENTITY_3000: bot.send_message(chat_id=chat_id, text=f"Какой способ связи с банком вы предпочитаете?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_help_keyboard()) InlineCallback.update_data({"is_help_phone": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_email": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_vk": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_human": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_bot": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"max price": 3001}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_ENTITY_3000 elif data == CALLBACK_BUTTON_ENTITY_6000: bot.send_message(chat_id=chat_id, text=f"Какой способ связи с банком вы предпочитаете?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_help_keyboard()) InlineCallback.update_data({"is_help_phone": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_email": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_vk": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_human": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_bot": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"max price": 6001}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_ENTITY_6000 elif data == CALLBACK_BUTTON_ENTITY_10000: bot.send_message(chat_id=chat_id, text=f"Какой способ связи с банком вы предпочитаете?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_help_keyboard()) InlineCallback.update_data({"is_help_phone": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_email": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_vk": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_human": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_bot": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"max price": 10001}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_ENTITY_10000 elif data == CALLBACK_BUTTON_ENTITY_ANY_COST: bot.send_message(chat_id=chat_id, text=f"Какой способ связи с банком вы предпочитаете?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_help_keyboard()) InlineCallback.update_data({"is_help_phone": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_email": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_vk": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_human": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"is_help_chat_bot": False}, f"personal/personal_{chat_id}.json") InlineCallback.update_data({"max price": 999999999}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_ENTITY_ANY_COST elif data == CALLBACK_BUTTON_CURRENCY_TRANSACTIONS_YES: bot.send_message(chat_id=chat_id, text=f"Требуется ли вам поддержка мультивалютных платежей?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_multicurrency_keyboard()) InlineCallback.update_data({"form_currency_transactions": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_CURRENCY_TRANSACTIONS_YES elif data == CALLBACK_BUTTON_CURRENCY_TRANSACTIONS_NO: bot.send_message(chat_id=chat_id, text=f"Требуется ли вам поддержка мультивалютных платежей?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_multicurrency_keyboard()) InlineCallback.update_data({"form_currency_transactions": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_CURRENCY_TRANSACTIONS_NO elif data == CALLBACK_BUTTON_MULTICURRENCY_YES: bot.send_message(chat_id=chat_id, text=f"Важно ли вам уведомлять партнёров о платежах в системе ДБО?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_partner_notification_keyboard()) InlineCallback.update_data({"is_multicurrency": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_MULTICURRENCY_YES elif data == CALLBACK_BUTTON_MULTICURRENCY_NO: bot.send_message(chat_id=chat_id, text=f"Важно ли вам уведомлять партнёров о платежах в системе ДБО?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_partner_notification_keyboard()) InlineCallback.update_data({"is_multicurrency": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_MULTICURRENCY_NO elif data == CALLBACK_BUTTON_PARTNER_NOTIFY_YES: bot.send_message(chat_id=chat_id, text=f"Вы желаете получать все виды счетов и выписок?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_all_types_of_accounts_keyboard()) InlineCallback.update_data({"notify_partner": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_PARTNER_NOTIFY_YES elif data == CALLBACK_BUTTON_PARTNER_NOTIFY_NO: bot.send_message(chat_id=chat_id, text=f"Вы желаете получать все виды счетов и выписок?", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_all_types_of_accounts_keyboard()) InlineCallback.update_data({"notify_partner": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_PARTNER_NOTIFY_NO elif data == CALLBACK_BUTTON_ALL_TYPES_ACC_YES: bot.send_message(chat_id=chat_id, text=f"Выберите приемлемую стоимость услуг ДБО:", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_entity_price_keyboard()) InlineCallback.update_data({"get_all_types_acc": True}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_ALL_TYPES_ACC_YES elif data == CALLBACK_BUTTON_ALL_TYPES_ACC_NO: bot.send_message(chat_id=chat_id, text=f"Выберите приемлемую стоимость услуг ДБО:", parse_mode=telegram.ParseMode.HTML, reply_markup=InlineKeyboardFactory.get_entity_price_keyboard()) InlineCallback.update_data({"get_all_types_acc": False}, f"personal/personal_{chat_id}.json") return CALLBACK_BUTTON_ALL_TYPES_ACC_NO
def __init__(self): self.position = np.random.rand(params.get_dimension()) * ( params.get_domain_max() - params.get_domain_min()) + params.get_domain_min() self.fitness = fn.calculate(self.position)