Skip to content

Commit

Permalink
Merge branch 'release/1.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r3f committed Jul 15, 2021
2 parents dc67bf3 + 75502f7 commit 434facc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ db.sqlite
*.tar
log
wallbot.log.*
.DS_Store
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.5
1.0.6
31 changes: 11 additions & 20 deletions dbhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, " \
Expand All @@ -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()

Expand Down Expand Up @@ -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
18 changes: 10 additions & 8 deletions ssbo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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__':
Expand Down

0 comments on commit 434facc

Please sign in to comment.