ayn2op / discordo

A lightweight, secure, and feature-rich Discord terminal client.
MIT License
2.02k stars 63 forks source link

Add bookmark feature #307

Closed emanueljg closed 5 months ago

emanueljg commented 1 year ago

This PR implements a very basic bookmark system for discordo.

A bookmark is a channel (including DMs) that exists top-level, before the DM node and list of servers, and is always reachable through the server list through a keyboard shortcut. Bookmarks are added in the config. Here is an example:

  bookmarks:
      - alias: foobar general
        id: 741347063077535874
      - alias: bazchan
        id: 568306982717751328

This is not only my first discordo PR but also my first golang code written ever, so I don't know if I've written idiomatic Go or not. I'm open to changes.

ghost commented 1 year ago

Would it be possible to add bookmarks and remove them throw the TUI?

It should be simple, like:
Read the config file, parse it, check for channel ID in the bookmarks list, if the ID exist, delete the bookmark, else add a new bookmark, write the new config file.

emanueljg commented 1 year ago

Would it be possible to add bookmarks and remove them throw the TUI?

It should be simple, like: Read the config file, parse it, check for channel ID in the bookmarks list, if the ID exist, delete the bookmark, else add a new bookmark, write the new config file.

I'm not sure I understood your explanation of your idea but just the idea of adding/removing bookmarks dynamically with for example a keyboard shortcut sounds interesting, but then I would want the bookmarks to exist in a seperate file. I am strongly opposed to the idea of the program editing user configuration.

I'll probably be too busy to implement this myself the following days as I don't require this quirk myself and I'm already satisfied with this PR as-is, but if anyone wants to add this, feel free.

ghost commented 1 year ago

Would it be possible to add bookmarks and remove them throw the TUI? It should be simple, like: Read the config file, parse it, check for channel ID in the bookmarks list, if the ID exist, delete the bookmark, else add a new bookmark, write the new config file.

I'm not sure I understood your explanation of your idea but just the idea of adding/removing bookmarks dynamically with for example a keyboard shortcut sounds interesting, but then I would want the bookmarks to exist in a seperate file. I am strongly opposed to the idea of the program editing user configuration.

I'll probably be too busy to implement this myself the following days as I don't require this quirk myself and I'm already satisfied with this PR as-is, but if anyone wants to add this, feel free.

I should have explained it better, but your idea is good. Having a file (e.g. $HOME/.config/discord/bookmarks) in a line-terminated format that contain bookmarks is better than trying to change user's config file. Here is an example prototype:

# channel_ID Alias name
6969420420420 The best channel
1234567890887 Some other channel

I will try to implement it my self. If you didn't see any PRs from my about this, then I failed horribly.