Skip to content

Commit 6f403e2

Browse files
authored
Typing Action ⌨️
Une statut écrit... quand le bot traduit
1 parent 6ef4bd1 commit 6f403e2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

main.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def traduire_texte(texte, de, a):
5252
# Commande /start
5353
@bot.message_handler(commands=['start'])
5454
def afficher_message_bienvenue(message):
55+
bot.send_chat_action(
56+
chat_id=message.chat.id,
57+
action="typing"
58+
)
5559
message_bienvenue = '''👋 Bienvenue ! Je suis votre *traducteur Anglais Francais* 🌍
5660
*Voici les principales commandes que je propose :*
5761
🇺🇸 `/fr hello this is a test` - Traduire le texte en anglais vers francais.
@@ -68,6 +72,10 @@ def afficher_message_bienvenue(message):
6872
# Commande /fr
6973
@bot.message_handler(commands=['fr'])
7074
def traduire_fr(message):
75+
bot.send_chat_action(
76+
chat_id=message.chat.id,
77+
action="typing"
78+
)
7179
texte = message.text.replace('/fr', '').strip()
7280
if texte:
7381
reponse = traduire_texte(texte, 'en', 'fr')
@@ -78,6 +86,10 @@ def traduire_fr(message):
7886
# Commande /en
7987
@bot.message_handler(commands=['en'])
8088
def traduire_en(message):
89+
bot.send_chat_action(
90+
chat_id=message.chat.id,
91+
action="typing"
92+
)
8193
texte = message.text.replace('/en', '').strip()
8294
if texte:
8395
reponse = traduire_texte(texte, 'fr', 'en')
@@ -88,6 +100,10 @@ def traduire_en(message):
88100
# Répondre aux autres messages
89101
@bot.message_handler(func=lambda message: True)
90102
def repondre_autre(message):
103+
bot.send_chat_action(
104+
chat_id=message.chat.id,
105+
action="typing"
106+
)
91107
bot.reply_to(message, 'Veuillez utiliser la commande /fr ou /en pour traduire le texte.')
92108

93109
# Lancer le bot

0 commit comments

Comments
 (0)