Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: beudbeud/discoger
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.3
Choose a base ref
...
head repository: beudbeud/discoger
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.1.0
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Jul 9, 2023

  1. feat: Add synchronize wantlist

    Adrien Beudin committed Jul 9, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c241a73 View commit details
  2. Merge pull request #2 from beudbeud/discogs-wantlist

    feat: Add synchronize wantlist
    beudbeud authored Jul 9, 2023
    Copy the full SHA
    11bbf6d View commit details
  3. fix: update version

    Adrien Beudin committed Jul 9, 2023
    Copy the full SHA
    d0492a7 View commit details
Showing with 40 additions and 1 deletion.
  1. +1 −1 discoger/_info.py
  2. +39 −0 discoger/client.py
2 changes: 1 addition & 1 deletion discoger/_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.0.3"
__version__ = "2.1.0"

__title__ = "discoger"
__author__ = "Beudbeud"
39 changes: 39 additions & 0 deletions discoger/client.py
Original file line number Diff line number Diff line change
@@ -170,6 +170,45 @@ def process_delete_step(message):
chat_id, "%s is deleted in following list" % (id_item)
)

@self.bot.message_handler(commands=["wantlist"])
def wantlist(message):
chat_id = message.chat.id
db = YamlDB(filename="%s/%s.yaml" % (self.database_dir, chat_id))
if db.get("wantlist_user"):
message.text = db.get("wantlist_user")
message.chat.id = chat_id
process_wantlist(message)
else:
msg = "Give your discogs username for checking your wantlist?"
answer = self.bot.reply_to(message, msg)
self.bot.register_next_step_handler(answer, process_wantlist)

def process_wantlist(message):
chat_id = message.chat.id
username = message.text
db = YamlDB(filename="%s/%s.yaml" % (self.database_dir, chat_id))
try:
user_info = self.d.user(username)
for i in user_info.wantlist:
release_info = self.d.release(i.id)
if not db.search("release_list[?release_id=='%s']" % (i.id)):
release = scrap.DiscogerInfo(release_info.url, self.d, str(i.id))
db["release_list"].append(release.release_info)
db.save()
logging.info("Item %s added in following list" % (i.id))
else:
logging.info("Item %s already in your following list" % (i.id))
self.bot.send_message(
chat_id, "Your wantlist is synchronized"
)
if not db.get("wantlist_user"):
db["wantlist_user"] = username
except discogs_client.exceptions.DiscogsAPIError as e:
self.bot.send_message(
chat_id, "Error, %s" % e
)


def check_discogs(chat_id=None):
if chat_id:
logging.info("Check user list %s" % (chat_id))