Skip to content

Commit 53180c1

Browse files
committed
White-listing groups
White listing groups, improving translation
1 parent 62fabaa commit 53180c1

1 file changed

Lines changed: 41 additions & 38 deletions

File tree

tg_bot/__main__.py

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,42 @@
4242
from tg_bot.modules.helper_funcs.chat_status import is_user_admin
4343
from tg_bot.modules.helper_funcs.misc import paginate_modules
4444

45+
# Federated list of groups
46+
GROUPS = [-1001340370511, -1001253839516, -1001184755706]
47+
4548
PM_START_TEXT = """
46-
Ciao {}, io sono {}! Il bot numero 1 di python_ita. Se hai qualche dubbio su come usarmi, leggi l'output del comando /help .
49+
Ciao {}, io sono {}! Il bot di Python Italia e gruppi associati. Se hai qualche dubbio su come usarmi, leggi l'output del comando /help .
4750
48-
Se vuoi contribuire al bot contatta @itsMett oppure @christiancavuti :).
51+
Se vuoi contribuire al bot guarda la repo ufficiale: https://github.com/pythonitalia/python-italy-telegram-bot :).
4952
50-
Se pensi che io sia un buon bot, e/o ti piacerebbe aiutarmi a sopravvivere nella giungla, scrivi /donate per aiutarmi ad aggiornare i miei server!
53+
Se pensi che io sia un buon bot, e/o ti piacerebbe aiutarmi a sopravvivere nella giungla, sarei molto felice di ricevere una PR su GH!
5154
"""
5255

5356
HELP_STRINGS = """
5457
Ciao! Io sono *{}*.
55-
Sono il bot principale del gruppo PythonItalia
58+
Sono il bot principale del gruppo Python Italia e gruppi associati.
5659
5760
I *principali* comandi disponibili sono:
58-
- /start: start the bot
59-
- /help: PM's you this message.
60-
- /help <module name>: PM's you info about that module.
61-
- /donate: information about how to donate!
61+
- /start: avvia il bot
62+
- /help: messaggio privato con l'help.
63+
- /help <module name>: messaggio privato con le informazioni su <module>.
6264
- /settings:
63-
- in PM: will send you your settings for all supported modules.
64-
- in a group: will redirect you to pm, with all that chat's settings.
65+
- in PM: Invio informazioni per tutti i moduli.
66+
- in un gruppo: Ti ridirigo alla chat privata per avere più informazioni.
6567
6668
{}
6769
E anche questi:
6870
""".format(
6971
dispatcher.bot.first_name,
70-
"" if not ALLOW_EXCL else "\nAll commands can either be used with / or !.\n",
72+
"" if not ALLOW_EXCL else "\nTutti i comandi possono essere richiamati con / oppure !.\n",
7173
)
7274

7375
DONATE_STRING = """Heya, felice di sentire che vuoi donare!
74-
Tutti i soldi per le donazioni andranno per una VPS migliore per ospitarmi e/o birra \
75-
per ora il canale delle donazioni non è attivo."""
76+
Attualmente il sistema di donazioni per il bot non è attivo, però il mio codice sorgente è su github ;)"""
7677

77-
COC_STRING = """Hey! Complimenti e benvenuto su Python Italia. \nOra puoi chattare nel gruppo e inviare messaggi :)\nSe hai ancora bisogno di me puoi
78-
usare il comando /help per più informazioni.\n\n[Torna sul gruppo](https://t.me/python_ita)"""
78+
COC_STRING = """Hey! Grazie per la verifica e benvenuto nel gruppo.
79+
In caso tu sia ancora mutato, invia questo comando: /CoCDone per essere sbloccato.\nOra puoi chattare nel gruppo e inviare messaggi :)\nSe hai ancora bisogno di me puoi
80+
usare il comando /help per più informazioni."""
7981

8082

8183
IMPORTED = {}
@@ -172,15 +174,16 @@ def start(bot: Bot, update: Update, args: List[str]):
172174
update.effective_message.reply_text(
173175
COC_STRING, parse_mode=ParseMode.MARKDOWN
174176
)
175-
# Deactivating mute
176-
bot.restrict_chat_member(
177-
DEFAULT_CHAT_ID,
178-
int(update.effective_message.from_user.id),
179-
can_send_messages=True,
180-
can_send_media_messages=True,
181-
can_send_other_messages=True,
182-
can_add_web_page_previews=True,
183-
)
177+
# Deactivating mute for every associated group
178+
for group_id in GROUPS:
179+
bot.restrict_chat_member(
180+
group_id,
181+
int(update.effective_message.from_user.id),
182+
can_send_messages=True,
183+
can_send_media_messages=True,
184+
can_send_other_messages=True,
185+
can_add_web_page_previews=True,
186+
)
184187

185188
else:
186189
first_name = update.effective_user.first_name
@@ -193,7 +196,7 @@ def start(bot: Bot, update: Update, args: List[str]):
193196
parse_mode=ParseMode.HTML,
194197
)
195198
else:
196-
update.effective_message.reply_text("Non ci siamo già visti?")
199+
update.effective_message.reply_text("Non ci siamo già visti? Utente abilitato.")
197200

198201

199202
# for test purposes
@@ -236,10 +239,10 @@ def help_button(bot: Bot, update: Update):
236239
if mod_match:
237240
module = mod_match.group(1)
238241
text = (
239-
"Questo e' l'help per il modulo *{}*:\n".format(
240-
HELPABLE[module].__mod_name__
241-
)
242-
+ HELPABLE[module].__help__
242+
"Questo e' l'help per il modulo *{}*:\n".format(
243+
HELPABLE[module].__mod_name__
244+
)
245+
+ HELPABLE[module].__help__
243246
)
244247
query.message.reply_text(
245248
text=text,
@@ -317,10 +320,10 @@ def get_help(bot: Bot, update: Update):
317320
elif len(args) >= 2 and any(args[1].lower() == x for x in HELPABLE):
318321
module = args[1].lower()
319322
text = (
320-
"Questo e' l'help per il modulo *{}*:\n".format(
321-
HELPABLE[module].__mod_name__
322-
)
323-
+ HELPABLE[module].__help__
323+
"Questo e' l'help per il modulo *{}*:\n".format(
324+
HELPABLE[module].__mod_name__
325+
)
326+
+ HELPABLE[module].__help__
324327
)
325328
send_help(
326329
chat.id,
@@ -345,7 +348,7 @@ def send_settings(chat_id, user_id, user=False):
345348
user_id,
346349
"Queste sono le tue impostazioni attuali:" + "\n\n" + settings,
347350
parse_mode=ParseMode.MARKDOWN,
348-
)
351+
)
349352

350353
else:
351354
dispatcher.bot.send_message(
@@ -397,7 +400,7 @@ def CoCDone(bot: Bot, update: Update):
397400
)
398401
else:
399402
update.effective_message.reply_text(
400-
"Non hai letto le CoC? Sei una delusione... \nNon sei abilitato per questo comando.",
403+
"Prima di interagire nel gruppo devi prendere visione e accettare il Codice di Condotta.",
401404
parse_mode=ParseMode.MARKDOWN,
402405
disable_web_page_preview=True,
403406
)
@@ -531,7 +534,7 @@ def donate(bot: Bot, update: Update):
531534
DONATE_STRING, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True
532535
)
533536

534-
if OWNER_ID != 254318997 and DONATION_LINK:
537+
if DONATION_LINK:
535538
update.effective_message.reply_text(
536539
"Puoi donare all'associazione qui " "[here]({})".format(DONATION_LINK),
537540
parse_mode=ParseMode.MARKDOWN,
@@ -547,11 +550,11 @@ def donate(bot: Bot, update: Update):
547550
)
548551

549552
update.effective_message.reply_text(
550-
"Ti ho inviato un messaggio privato su come donare!"
553+
"Grazie per il tuo interesse. Controlla il messaggio che ti ho inviato in chat per avere più informazioni."
551554
)
552555
except Unauthorized:
553556
update.effective_message.reply_text(
554-
"Contattami in privato per più informazioni su come donare."
557+
"Grazie per il tuo interesse. Contattami in privato per avere più informazioni."
555558
)
556559

557560

0 commit comments

Comments
 (0)