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

Suggest a GitHub Connection #32

Merged
merged 9 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions juniorguru_chick/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,12 @@ async def handle_intro_thread(starting_message: discord.Message, thread: discord
emojis = intro.choose_intro_emojis(starting_message.content)
logger.info(f"Processing thread {thread.name!r} (reacting with {emojis!r} and more…)")
tasks = [ensure_thread_name(thread, intro.THREAD_NAME_TEMPLATE),
manage_intro_thread(thread)]
manage_intro_thread(thread, starting_message.content)]
tasks.extend([starting_message.add_reaction(emoji) for emoji in emojis])
await asyncio.gather(*tasks)


async def manage_intro_thread(thread: discord.Thread):
await thread.send(**intro.generate_intro_message())
async def manage_intro_thread(thread: discord.Thread, intro_message_content: str):
await thread.send(**intro.generate_intro_message(intro_message_content))
await add_members_with_role(thread, intro.GREETER_ROLE_ID)


Expand Down
32 changes: 30 additions & 2 deletions juniorguru_chick/lib/intro.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
from typing import Any
from textwrap import dedent
honzajavorek marked this conversation as resolved.
Show resolved Hide resolved

from discord import ui, ButtonStyle, Message, MessageType

Expand Down Expand Up @@ -57,13 +58,16 @@ def choose_intro_emojis(intro_message_content: str) -> list[str]:
return ["👋", "🐣", "👍"] + list(emojis)


def generate_intro_message() -> dict[str, Any]:
content = (
def generate_intro_message(intro_message_content: str) -> dict[str, Any]:
greeting = (
'Píp, píp! Tady kuře, místní robot. '
'Vítej v klubu 👋'
'\n\n'
'Dík, že se představuješ! '
'Když o tobě víme víc, můžeme ti líp radit <:meowthumbsup:842730599906279494>'
)

tips = (
'\n\n'
'Představení můžeš kdyžtak doplnit či změnit přes tři tečky a „Upravit zprávu“ 📝'
'\n\n'
Expand All @@ -75,10 +79,34 @@ def generate_intro_message() -> dict[str, Any]:
'- Záznamy přednášek? <#788822884948770846>\n'
'- Něco jiného? <#769966887055392768> snese cokoliv\n'
'- Nevíš, jak to tady funguje? Ptej se v <#806215364379148348>'
)

gh_connection_snippet = (
'\n\n'
'Vidím, že máš **profil na GitHubu**. Když si GitHub propojíš s Discordem, bude tvůj profil viditelnější. Do budoucna navíc chystáme pro lidi s propojeným GitHub profilem spoustu vychytávek <a:yayfrog:976193164471853097> '
'\n\n'
'1. Jdi do [nastavení](https://discord.com/channels/@me) '
'\n'
'2. Klikni na Propojení (_Connections_). '
'\n'
'3. Přidej GitHub. '
)

footer = (
'\n\n'
'A nezapomeň, že junior.guru není jenom klub. '
'Tady aspoň dva odkazy, které fakt nechceš minout: '
)

# Compose the greeting message depending on the intro message content
content = greeting

if "github.com/" in intro_message_content:
content = content + gh_connection_snippet

content = content + tips + footer
content = dedent(content)

view = ui.View(ui.Button(emoji='📖',
label='Příručka',
url='https://junior.guru/handbook/',
Expand Down
Loading