Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naming threads #10

Closed
honzajavorek opened this issue Mar 11, 2023 · 3 comments · Fixed by #28
Closed

Naming threads #10

honzajavorek opened this issue Mar 11, 2023 · 3 comments · Fixed by #28
Assignees

Comments

@honzajavorek
Copy link
Member

honzajavorek commented Mar 11, 2023

Idea from @benabraham:

když v past vedle pasti nebo objevu někdo dá na začátek do [] tak by se to mohlo dostat do titulku
[algoritmy] asůdkůlk ad aůsdksůadk ➡️ Past na Honza Javorek: algoritmy
 a vynechat ten den, protože to už bude specifický dost
 jakože regulár ^\[.+?\]

Do we want this? Seems like a neat idea 🤔 This could be also a nice opportunity to have some tests added to the repository. I can help with setting them up.

@dariagrudzien
Copy link
Collaborator

dariagrudzien commented Aug 3, 2023

@honzajavorek I'd go for this next but need a bit more information:

  • how does naming threads work in Discord
  • what is this task exactly about
  • I'd love to contribute to tests, let's do that?

Is it time to chat about this in more detail?

@honzajavorek
Copy link
Member Author

On Discord, threads have explicit names. In two channels in the club, #past-vedle-pasti and #můj-dnešní-objev, this bot automatically creates a thread under every message someone posts there.

Screenshot 2023-08-03 at 10 14 20

Because the thread requires an explicit name, bot generates one according to current weekday, so that people could at least somewhat orientate if discussing in multiple of those threads. The function responsible for that is here:

https://github.com/juniorguru/juniorguru-chick/blob/3bdfa24cb96fdeacf1a70584e699e63983e4da9f/juniorguru_chick/lib/threads.py#L34

As you can see in the screenshot, there's a bottom-up convention where people denote the topic of their post in brackets before the actual post. What @benabraham suggests is that the mechanism for naming those threads parses the message content and if there's something in the brackets in the beginning, it could use it for the thread name instead of the weekday.

Regarding tests, there is already the folder and they're ran on CI, so no need to set them up anymore, but I can definitely imagine testing the parsing. Just by doing a superficial scroll in either #past-vedle-pasti or #můj-dnešní-objev, I can see people get creative with whitespace or emoji, so picking up a few specimen and putting them into @pytest.mark.parametrize would be nice to proof the parsing works well.

@honzajavorek
Copy link
Member Author

To avoid messing with async and IO in the tests, the following lines should become a separate sync function:

weekday = datetime.now().weekday()
name = name_template.format(weekday=DAYS[weekday], author=starting_message.author.display_name)

It would take necessary inputs and return a name for the thread. In the beginning, we can test it work correctly for the weekdays, then add the logic for parsing. I assume that the function will still return name based on the weekday in case there are no brackets to parse or the brackets parsing produce something confusing (better return weekday than crash the bot).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants