Exemple #1
0
async def novobud(call: CallbackQuery):
    await call.answer(cache_time=4)
    await call.message.edit_text(text="Собираем дание...\nПодождите несколько минут")
    delete_data("novobud")
    start_novobud()
    data = get_from_novobud()
    for row in data:
        status = row[1]
        district = row[2]
        address = row[3]
        description = row[4]
        construction_end = row[5]
        link = row[6]
        image = row[7]
        price = row[8]
        map_d = row[9]
        map_w = row[10]
        await call.message.answer_photo(image)
        await call.message.answer_location(map_d, map_w)
        await call.message.answer(text=f"<b>Статус:</b> {status}\n"
                                       f"<b>Район:</b>  {district}\n"
                                       f"<b>Адресс:</b> {address}\n"
                                       f"<b>Окончание строительства:</b> {construction_end}\n"
                                       f"<b>Описание:</b> {description}\n"
                                       f"<b>Цена за грн/м2:</b>  {price}\n"
                                       f"<b>Цена за 40м2:</b> {int(price) * 40}\n"
                                       f"<b>Ссылка:</b> {link}")
    await call.message.answer(text="<b>Подбор закончен</b>", reply_markup=offers_kb)
Exemple #2
0
def delete_item(tablename):
    con = database.get_engine().connect()
    data = request.values.get('key')
    print(data, file=sys.stderr)
    if data != '':
        if tablename == 'Take_Course':
            data = data.split('&')
            temp = []
            temp.append(data[0].split('=')[1])
            temp.append(data[1].split('=')[1])
            data = temp
        else:
            data = data.split('=')[1]
        database.delete_data(tablename, data)
    ##Execute select all from Academy table
    table = database.get_table(tablename)
    table = table.select().execute().fetchall()
    table_name = tablename

    ##Parse result data
    columns, results = parse_result(table)

    con.close()
    return render_template('delete.html',
                           table_name=table_name,
                           columns=columns,
                           results=results)
Exemple #3
0
 def update_schedule(self):
     self.req = requests.get(self.schedulelink)
     self.tree = BeautifulSoup(self.req.text, 'lxml')
     self.id += 1
     showlist = {show.title for show in self.iter_schedule()}
     all_shows = list_all_shows()
     if showlist == all_shows:
         logger.info(f"Update successful, id: {self.id}")
         return True
     else:
         logger.warning("Show mismatch found, flushing old data...")
         delete_data()
         return False
Exemple #4
0
def phonebook_delete():
    if request.method == 'POST':
        index = request.form.get('index')
        is_success = database.delete_data(index)
        return is_success + "<br> <a href=\'/phonebook\'>Go To Main Page!</a>"
    item = database.fetch_all_data()
    if item:
        return render_template('PhoneBook_Delete.html', items=item)
Exemple #5
0
async def flafy(call: CallbackQuery):
    await call.answer(cache_time=4)
    await call.message.edit_text(text="Собираем дание...\nПодождите несколько минут")
    delete_data("flafy")
    start_flafy()
    data = get_from_flafy()
    for row in data:
        title = row[1]
        price = row[2]
        link = row[3]
        district = row[4]
        await call.message.answer(text=f" {title} \n"
                                       f"Цена: {price}\n"
                                       f"Район: {district}\n"
                                       f"ссылка: {link}"
                                  )
    await call.message.answer(text="<b>Подбор закончен</b>", reply_markup=offers_kb)
Exemple #6
0
async def domria(call: CallbackQuery):
    await call.answer(cache_time=4)
    await call.message.edit_text(text="Собираем дание...\nПодождите несколько минут")
    delete_data("olx")
    start_olx()
    data = get_from_olx()
    for row in data:
        title = row[1]
        price = row[2]
        link = row[3]
        image = row[4]
        add_date = row[5]
        await call.message.answer_photo(image)
        await call.message.answer(text=f" {title} \n"
                                       f"Цена: {price}\n"
                                       f"Дата публикации: {add_date}\n"
                                       f"ссылка: {link}"
                                  )
    await call.message.answer(text="<b>Подбор закончен</b>", reply_markup=offers_kb)
 def delete_value(self):
     db,cu = database.connect_db()
     input_letter = self.letterLineEdit.text().toUtf8()
     input_letter = str(input_letter).strip()
     label = 'one'
     try:
         database.delete_data(input_letter,label,cu,db)
         self.letterLineEdit.clear()
         self.valueLineEdit.clear()
         try:
             for i in range(self.verticalLayoutScroll.count()): self.verticalLayoutScroll.itemAt(i).widget().close()
         except:
             pass
         self.list_alpha(label)
     except database.DataErorr as e :
         QtGui.QMessageBox.warning(self, "Cannot store value",
                                   e.message,
                                   QtGui.QMessageBox.Cancel, QtGui.QMessageBox.NoButton,
                                   QtGui.QMessageBox.NoButton)
         return 
Exemple #8
0
async def domria(call: CallbackQuery):
    await call.answer(cache_time=4)
    await call.message.edit_text(text="Собираем дание...\nПодождите несколько минут")
    delete_data("domria")
    start_domria()
    data = get_from_domria()
    for row in data:
        link = row[1]
        description = row[2]
        latitude = row[3]
        longitude = row[4]
        price_USD = row[5]
        price_EUR = row[6]
        price_UAH = row[7]
        street_name = row[8]
        building_number = row[9]
        publishing_date = row[10]
        photo_link = row[11]
        # TODO   Написать добавление изображений медиагрупой
        photo = photo_link.replace("'", "").replace("[", "").replace("]", "").split(",")
        try:
            await call.message.answer_photo(photo=photo[0])
        except exceptions.RetryAfter:
            await call.message.answer_photo(photo=photo[1])

        if longitude is not None:
            await call.message.answer_location(latitude=latitude, longitude=longitude)
        else:
            await call.message.answer(text="Координаты не указаны")
        await call.message.answer(text=f"<b>Описание:</b> {description}\n"
                                       f"<b>Дата публикации:</b>  {publishing_date}\n"
                                       f"<b>Адресс:</b> {street_name} №{building_number}\n"
                                       f"<b>Цена USD:</b> {price_USD}\n"
                                       f"<b>Цена EUR:</b> {price_EUR}\n"
                                       f"<b>Цена UAH:</b> {price_UAH}\n"
                                       f"<b>Ссылка:</b> {link}\n"
                                  )
    await call.message.answer(text="<b>Подбор закончен</b>", reply_markup=offers_kb)
Exemple #9
0
    def handle_command(self, command):
        """Here the command given from the gui is handled"""

        #Main Menu

        if self.pos == 0:
            if command == "begin":
                self.pos = 1
                return (self.get_description(),"clear Wooden House first check")

            else:
                return("Please type in one of the above.","")

        if self.pos == 666:
            return("RESTART THE GAME TO TRY AGAIN.","")

        if self.pos == 7777:
            return("RESTART THE GAME IF YOU WANT TO PLAY AGAIN!","")


        #General
         #~Note
        elif self.pos == self.note.position and command in self.takeNote \
        and self.note.status == "dropped":
            self.note.status = "picked up"
            return ("You picked up a note.", "note")

        elif self.note.status == "picked up" and command == "read note":
            self.readNote = True
            return (self.note.description, "")

        elif command == "drop note" and self.note.status == "picked up":
            self.note.position = self.pos
            self.note.status = "dropped"
            return("You dropped the note.", "dropNote")

        elif command in self.noteInfo:
            return(self.note.get_position(),"")

        #~Ruby
        elif self.pos == self.ruby.position and command in self.takeRuby \
        and self.ruby.status == "dropped" and self.stone_correct == True:
            self.ruby.status = "picked up"
            return ("You picked up a ruby.", "ruby")

        elif command == "drop ruby" and self.ruby.status == "picked up":
            self.ruby.position = self.pos
            self.ruby.status = "dropped"
            return("You dropped the ruby.", "dropRuby")

        elif command in self.rubyInfo:
            found = 0
            if self.bandit_conv_over == True:
                found = 1
            if self.stone_conv_over == True:
                found = 2
            return(self.ruby.get_position(found),"")

        elif command in self.info:
            return (self.get_description(),"check")

        #~Save and Load

        elif command == "save":
            self.save = True
            return('Enter your name to create a new save, "overwrite" to overwrite or "delete" to delete',"")

        elif self.save == True:
            self.save = False
            if command == "overwrite":
                self.overwrite = True
                saves = self.get_saves()
                saves += "Enter the ID of the save you wish to overwrite."
                return(saves,"")
            else:
                save_name = command
                database.save_data((save_name, self.pos, self.readNote, \
                self.note.status,self.note.position, self.bandit_conv_over))
                return("Your name is "+save_name+" and you have saved succesfully.","")

        elif self.overwrite == True:
            saveID = int(command)
            database.update_data((self.pos, self.readNote, \
            self.note.status,self.note.position, self.bandit_conv_over,saveID))
            return("You have overwritten save number: "+str(saveID)+" succesfully.","")

        elif command == "load":
            self.load = True
            saves = self.get_saves()
            saves += "Enter the ID of the save you wish to load."
            return(saves,"")

        elif self.load == True:
            self.load = False
            id = command
            selected_data = database.select_data(id)
            self.pos = [x[1] for x in selected_data][0]
            self.readNote = [x[2] for x in selected_data][0]
            self.note.status = [x[3] for x in selected_data][0]
            self.note.position = [x[4] for x in selected_data][0]
            self.bandit_conv_over = [x[5] for x in selected_data][0]
            print(self.pos, self.readNote, self.note.status, self.bandit_conv_over)

            return(self.get_description(),"")

        elif command == "delete":
            self.delete = True
            saves = self.get_saves()
            saves += "Enter the ID of the save you wish to delete"
            return(saves,"")

        elif self.delete == True:
            self.delete = False
            id = command
            database.delete_data(id)
            return("You have deleted save number: "+str(command)+" succesfully.","")

        #Room 1 Wooden House
        elif self.pos == 1:
            if command in self.compass[1]:
                self.pos = 2
                return(self.get_description(),"clear Forest check")

            elif command in self.compass[0] or command == "enter house":
                return("The door is locked.","")

            elif command == "describe house" or command == "examine house":
                return(self.one.house_description,"")

            elif command in self.lockpick:
                return("You don't have a lockpick.","")

            elif command == self.break_door:
                return("Don't overestimate your strength.","")

            elif command == "break window":
                if self.window == "whole":
                    self.window = "broken"
                    return(self.break_window,"")
                elif self.window == "broken":
                    return("The window is already broken.","")

            elif command in self.compass[2] or command in self.compass[3] or \
            command in self.compass[4] or command in self.compass[5] or \
            command in self.compass[6] or command in self.compass[7]:
                return("The forest is to dense, you can't go there.","")

            else:
                return ("I beg your pardon?", "")

        #Room 2 Forest
        elif self.pos == 2:
            if command in self.compass[3]:
                self.pos = 1
                if self.quest == "complete":
                    self.pos = 7777
                    return("YOU WON THE GAME!","clear Wooden House")
                return (self.get_description(),"clear Wooden House check")

            elif command in self.compass[1]:
                self.pos = 3
                return (self.get_description(),"clear Clearing check")

            elif command in self.compass[0] or command in self.compass[2] or \
            command in self.compass[4] or command in self.compass[5] or \
            command in self.compass[6] or command in self.compass[7]:
                return("The forest is to dense, you can't go there.","")

            else:
                return ("I beg your pardon?", "")

        #Room 3 Clearing
        elif self.pos == 3:
            if command in self.compass[1]:
                return("You're not Jesus, you can't walk on water.","")

            elif command in self.swim_west:
                return("You never learned how to swim.","")

            elif command in self.compass[0]:
                self.pos = 4
                return(self.get_description(),"clear Cave check")

            elif command in self.compass[2]:
                self.pos = 5
                if self.quest == "declined":
                    self.pos = 666
                    return(self.bandit_lose,"clear")
                elif self.quest == "incomplete":
                    if self.ruby.status == "picked up" and self.bandit_conv_over == True:
                        self.ruby.position = 123123
                        self.quest = "complete"
                        self.pos = 3
                        return(self.happybandit,"Clearing dropRuby")
                    else:
                        return(("Bandit: Do you have the Ruby?\nYou: No. \n"
                        "Bandit: Then go get it if you want the dwarf!"),"")
                else:
                    return(self.get_description(),"clear BanditCamp check")

            elif command in self.compass[3]:
                self.pos = 2
                return(self.get_description(),"clear Forest check")

            elif command in self.compass[4] or command in self.compass[5] or \
            command in self.compass[6] or command in self.compass[7]:
                return("The forest is to dense, you can't go there.","")

            else:
                return ("I beg your pardon?", "")


        #Room 4 Cave entrance
        elif self.pos == 4:
            if command in self.compass[2]:
                self.pos = 3
                return(self.get_description(),"clear Clearing check")

            elif command in self.compass[4]:
                self.pos = 6
                return(self.get_description(),"clear Cave check")

            elif command in self.compass[0] or command in self.compass[1] or \
            command in self.compass[3] or command in self.compass[5] or \
            command in self.compass[6] or command in self.compass[7]:
                return("It's to dark for you to go there.","")



        #Room 6 Stone Guardian
        elif self.pos == 6:
            if command in self.stone_conv_start and self.stone_conv_over == False:
                self.pos = 6.1
                return(self.stone_opener,"")
            elif command in self.compass[7]:
                self.pos = 4
                return(self.get_description(),"clear Cave check")

            elif command in self.compass[0] or command in self.compass[1] or \
            command in self.compass[2] or command in self.compass[3] or \
            command in self.compass[4] or command in self.compass[5] or \
            command in self.compass[6]:
                return("It's not recommended to talk into a wall.","")

            else:
                return("I beg your pardon?","")
        elif self.pos == 6.1:
            if command == "yes":
                self.pos = 6.2
                return(self.stone_conversation(),"")
            elif command == "no":
                self.pos = 6
                return("You may leave or speak to the guardian again. ","clear")
            else:
                return("I require a yes or no answer.","")

        elif self.pos == 6.2:
            if command == "david":
                self.pos = 6
                self.stone_conv_over = True
                self.stone_correct = True
                string_for_print = ("Correct. \n"
                "The treasure is up for grabs; a shining red ruby \
                lays in the rooms before you.")
                return(string_for_print,"")
            elif command != "david":
                print(self.chances)
                self.chances += 1
                if self.chances == 1:
                    chance_for_print = "Wrong. Two chances remaining."
                elif self.chances == 2:
                    chance_for_print = "Wrong. One chance remaining"
                elif self.chances == 3:
                    self.stone_conv_over = True
                    self.stone_correct = False
                    self.pos = 6
                    string_for_print = ("All wrong. Leave. \n"
                    "The door is closed and your chances of saving the \
                    dwarf with the ruby looks slim.")
                    return(string_for_print,"")

                return(chance_for_print,"")



        #Room 5 Bandit Camp
        elif self.pos == 5:
            if self.quest == "incomplete":
                if self.bandit_conv_over == True:
                    if command in self.compass[0]:
                        self.pos = 3
                        return(self.get_description(),"clear Clearing check")
                    else:
                        return("Leave the place by taking the northern path seems"
                        "like your only option.","")
            if self.quest == "not started":
                if self.bandit_conv_over == False:
                    if command in self.bandit_conv_start:
                        self.pos = 5.1
                        return(self.bandit_conversation(),"cursorTop")
                    else:
                        return("Talk to the bandits before doing anything else.","")


        elif self.pos == 5.1:
            if command == "yes":
                self.pos = 5
                self.quest = "incomplete"
                return(self.bandit_accept,"")
            elif command == "no":
                self.pos = 3
                self.quest = "declined"
                return(self.bandit_decline,"Clearing")
            else:
                return("Bandit: Answer me yes or no.","")

        else:
            return ("I beg your pardon?", "")