diff --git a/.gitignore b/.gitignore index e5a3050..a199cce 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ db.sqlite *.tar log wallbot.log.* +.DS_Store diff --git a/VERSION b/VERSION index 1464c52..ece61c6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.5 \ No newline at end of file +1.0.6 \ No newline at end of file diff --git a/dbhelper.py b/dbhelper.py index 12e1202..e81fc40 100644 --- a/dbhelper.py +++ b/dbhelper.py @@ -36,18 +36,13 @@ def __init__(self, item_id, chat_id, title, price, url, publish_date, observacio self.observaciones = observaciones self.item = item -# class Chat: -# def __init__(self, chat_id, last_update_id): -# self.chat_id = chat_id -# self.last_update_id = last_update_id - class DBHelper: def __init__(self, dbname="/data/db.sqlite"): self.dbname = dbname self.conn = sqlite3.connect(dbname, check_same_thread=False) - def setup(self): + def setup(self, version=""): tblstmtitem = "create table if not exists item " \ "(itemId integer, " \ "chatId text, " \ @@ -69,17 +64,21 @@ def setup(self): "max_price text, " \ "dist text default \'400\', " \ "publish_date integer default 24, " \ - "ord text default \'creationDate-des\', " \ + "ord text default \'newest\', " \ "username text, " \ "name text, " \ "active int default 1)" self.conn.execute(tblstmtchat) - # tblstmtupda = "create table if not exists chat_update " \ - # "(chat_id text, " \ - # "last_update_id text, " \ - # "primary key (chat_id))" - # self.conn.execute(tblstmtupda) + if version == '1.0.6': + stmt = "update chat_search " \ + "set ord = \'newest\' " \ + "where ord = \'creationDate-des\'" + try: + self.conn.execute(stmt) + self.conn.commit() + except Exception as e: + print(e) self.conn.commit() @@ -206,11 +205,3 @@ def del_chat_search(self, chat_id, kws): self.conn.commit() except Exception as e: print(e) - - # def get_chats(self): - # stmt = "select chat_id, last_update_id from chat_update" - # lista = [] - # for row in self.conn.execute(stmt): - # c = Chat(row[0], row[1]) - # lista.append(c) - # return lista diff --git a/ssbo.py b/ssbo.py index d4f8e81..59b822c 100644 --- a/ssbo.py +++ b/ssbo.py @@ -58,6 +58,7 @@ def get_url_list(search): url = URL_ITEMS url += '?keywords=' url += "+".join(search.kws.split(" ")) + url += '&time_filter=today' if search.cat_ids is not None: url += '&category_ids=' url += search.cat_ids @@ -70,11 +71,8 @@ def get_url_list(search): if search.dist is not None: url += '&dist=' url += search.dist - if search.publish_date is not None: - url += '&publishDate=' - url += str(search.publish_date) if search.orde is not None: - url += '&order=' + url += '&order_by=' url += search.orde return url @@ -260,12 +258,16 @@ def recovery(times): def main(): print("JanJanJan starting...") logging.info("JanJanJan starting...") - db.setup() - + db.setup(readVersion()) threading.Thread(target=wallapop).start() - recovery(1) - # bot.polling(none_stop=True, timeout=3000) + + +def readVersion(): + file = open("VERSION", "r") + version = file.readline() + logging.info("Version %s", version) + return version if __name__ == '__main__':