Skip to content

Commit

Permalink
feat: welcome message enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
Picred committed Oct 21, 2023
1 parent 186a8b3 commit c2b5def
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
9 changes: 8 additions & 1 deletion data/welcome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"it": ["Benvenuto USER nel nostro gruppo ^-^","Ciao USER!","Salve USER!"],
"en": ["Welcome USER to our group ^-^","Hello USER!","Howdy USER!"]
"en": ["Welcome USER to our group ^-^","Hello USER!","Howdy USER!"],
"readme": "https://t.me/c/1095167198/67194",
"utils": [
"Se hai idee o suggerimenti, condividili con noi. Siamo aperti a nuove prospettive!",
"Non esitare a fare domande se hai bisogno di aiuto.",
"Speriamo che ti possa sentire come a casa tua.",
"Ricorda di rispettare le opinioni degli altri membri, anche se non sempre concordi. La diversità ci arricchisce."
]
}
14 changes: 11 additions & 3 deletions module/commands/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def generate_welcome(new_member: User) -> str:


def send_welcome(update: Update, _: CallbackContext) -> None:
for new_member in update['message']['new_chat_members']:
if not new_member['is_bot']:
update.message.reply_text(f'{generate_welcome(new_member)}')
if update.message.new_chat_members:
for new_member in update.message.new_chat_members:
if not new_member.is_bot:
handle_welcome(update, new_member)


def handle_welcome(update: Update, new_member: User) -> None:
welcome_msg = f'{generate_welcome(new_member)}\n' + \
f"- Dai un'occhiata al [README]({welcome['readme']})\n" + \
f"- {welcome['utils'][randrange(0, len(welcome['utils']))]}"
update.message.reply_markdown(welcome_msg, disable_web_page_preview=True)

0 comments on commit c2b5def

Please sign in to comment.