2121from tg_bot .modules .sql import warns_sql as sql
2222
2323WARN_HANDLER_GROUP = 9
24- CURRENT_WARNING_FILTER_STRING = "<b>Current warning filters in this chat:</b>\n "
24+ CURRENT_WARNING_FILTER_STRING = "<b>Attuali filtri di ammonimento in questa chat:</b>\n "
2525
2626
2727# Not async
2828def warn (user : User , chat : Chat , reason : str , message : Message , warner : User = None ) -> str :
2929 if is_user_admin (chat , user .id ):
30- message .reply_text ("Damn admins, can't even be warned !" )
30+ message .reply_text ("Maledetti admin, non possono nemmeno essere ammoniti !" )
3131 return ""
3232
3333 if warner :
3434 warner_tag = mention_html (warner .id , warner .first_name )
3535 else :
36- warner_tag = "Automated warn filter ."
36+ warner_tag = "Filtro di ammonimento automatico ."
3737
3838 limit , soft_warn = sql .get_warn_setting (chat .id )
3939 num_warns , reasons = sql .warn_user (user .id , chat .id , reason )
4040 if num_warns >= limit :
4141 sql .reset_warns (user .id , chat .id )
4242 if soft_warn : # kick
4343 chat .unban_member (user .id )
44- reply = "{} warnings , {} has been kicked !" .format (limit , mention_html (user .id , user .first_name ))
44+ reply = "{} ammonimenti , {} è stato cacciato !" .format (limit , mention_html (user .id , user .first_name ))
4545
4646 else : # ban
4747 chat .kick_member (user .id )
48- reply = "{} warnings , {} has been banned !" .format (limit , mention_html (user .id , user .first_name ))
48+ reply = "{} ammonimenti , {} è stato bandito !" .format (limit , mention_html (user .id , user .first_name ))
4949
5050 for warn_reason in reasons :
5151 reply += "\n - {}" .format (html .escape (warn_reason ))
@@ -55,28 +55,28 @@ def warn(user: User, chat: Chat, reason: str, message: Message, warner: User = N
5555 log_reason = "<b>{}:</b>" \
5656 "\n #WARN_BAN" \
5757 "\n <b>Admin:</b> {}" \
58- "\n <b>User :</b> {} (<code>{}</code>)" \
59- "\n <b>Reason :</b> {}" \
60- "\n <b>Counts :</b> <code>{}/{}</code>" .format (html .escape (chat .title ),
58+ "\n <b>Utente :</b> {} (<code>{}</code>)" \
59+ "\n <b>Ragione :</b> {}" \
60+ "\n <b>Conteggio :</b> <code>{}/{}</code>" .format (html .escape (chat .title ),
6161 warner_tag ,
6262 mention_html (user .id , user .first_name ),
6363 user .id , reason , num_warns , limit )
6464
6565 else :
6666 keyboard = InlineKeyboardMarkup (
67- [[InlineKeyboardButton ("Remove warn " , callback_data = "rm_warn({})" .format (user .id ))]])
67+ [[InlineKeyboardButton ("Rimuovere ammonimento " , callback_data = "rm_warn({})" .format (user .id ))]])
6868
69- reply = "{} has {}/{} warnings ... watch out !" .format (mention_html (user .id , user .first_name ), num_warns ,
69+ reply = "{} ha {}/{} ammonimenti ... attenzione !" .format (mention_html (user .id , user .first_name ), num_warns ,
7070 limit )
7171 if reason :
72- reply += "\n Reason for last warn :\n {}" .format (html .escape (reason ))
72+ reply += "\n Ragione dell'ultimo ammonimento :\n {}" .format (html .escape (reason ))
7373
7474 log_reason = "<b>{}:</b>" \
7575 "\n #WARN" \
7676 "\n <b>Admin:</b> {}" \
77- "\n <b>User :</b> {} (<code>{}</code>)" \
78- "\n <b>Reason :</b> {}" \
79- "\n <b>Counts :</b> <code>{}/{}</code>" .format (html .escape (chat .title ),
77+ "\n <b>Utente :</b> {} (<code>{}</code>)" \
78+ "\n <b>Ragione :</b> {}" \
79+ "\n <b>Conteggio :</b> <code>{}/{}</code>" .format (html .escape (chat .title ),
8080 warner_tag ,
8181 mention_html (user .id , user .first_name ),
8282 user .id , reason , num_warns , limit )
@@ -106,19 +106,19 @@ def button(bot: Bot, update: Update) -> str:
106106 res = sql .remove_warn (user_id , chat .id )
107107 if res :
108108 update .effective_message .edit_text (
109- "Warn removed by {}." .format (mention_html (user .id , user .first_name )),
109+ "Ammonimento rimosso da {}." .format (mention_html (user .id , user .first_name )),
110110 parse_mode = ParseMode .HTML )
111111 user_member = chat .get_member (user_id )
112112 return "<b>{}:</b>" \
113113 "\n #UNWARN" \
114114 "\n <b>Admin:</b> {}" \
115- "\n <b>User :</b> {} (<code>{}</code>)" .format (html .escape (chat .title ),
115+ "\n <b>Utente :</b> {} (<code>{}</code>)" .format (html .escape (chat .title ),
116116 mention_html (user .id , user .first_name ),
117117 mention_html (user_member .user .id , user_member .user .first_name ),
118118 user_member .user .id )
119119 else :
120120 update .effective_message .edit_text (
121- "User has already has no warns ." .format (mention_html (user .id , user .first_name )),
121+ "Utente gia privo di ammonimenti ." .format (mention_html (user .id , user .first_name )),
122122 parse_mode = ParseMode .HTML )
123123
124124 return ""
@@ -141,7 +141,7 @@ def warn_user(bot: Bot, update: Update, args: List[str]) -> str:
141141 else :
142142 return warn (chat .get_member (user_id ).user , chat , reason , message , warner )
143143 else :
144- message .reply_text ("No user was designated !" )
144+ message .reply_text ("Nessun utente è stato designato !" )
145145 return ""
146146
147147
@@ -158,17 +158,17 @@ def reset_warns(bot: Bot, update: Update, args: List[str]) -> str:
158158
159159 if user_id :
160160 sql .reset_warns (user_id , chat .id )
161- message .reply_text ("Warnings have been reset !" )
161+ message .reply_text ("Ammonimenti resettati !" )
162162 warned = chat .get_member (user_id ).user
163163 return "<b>{}:</b>" \
164164 "\n #RESETWARNS" \
165165 "\n <b>Admin:</b> {}" \
166- "\n <b>User :</b> {} (<code>{}</code>)" .format (html .escape (chat .title ),
166+ "\n <b>Utente :</b> {} (<code>{}</code>)" .format (html .escape (chat .title ),
167167 mention_html (user .id , user .first_name ),
168168 mention_html (warned .id , warned .first_name ),
169169 warned .id )
170170 else :
171- message .reply_text ("No user has been designated !" )
171+ message .reply_text ("Nessun utente è stato designato !" )
172172 return ""
173173
174174
@@ -184,7 +184,7 @@ def warns(bot: Bot, update: Update, args: List[str]):
184184 limit , soft_warn = sql .get_warn_setting (chat .id )
185185
186186 if reasons :
187- text = "This user has {}/{} warnings, for the following reasons :" .format (num_warns , limit )
187+ text = "Questo utente ha {}/{} ammonimenti, per le seguenti ragioni :" .format (num_warns , limit )
188188 for reason in reasons :
189189 text += "\n - {}" .format (reason )
190190
@@ -193,9 +193,9 @@ def warns(bot: Bot, update: Update, args: List[str]):
193193 update .effective_message .reply_text (msg )
194194 else :
195195 update .effective_message .reply_text (
196- "User has {}/{} warnings, but no reasons for any of them ." .format (num_warns , limit ))
196+ "Questo utente ha {}/{} ammonimenti ma per nessuno di essi è indicata una ragione ." .format (num_warns , limit ))
197197 else :
198- update .effective_message .reply_text ("This user hasn't got any warnings !" )
198+ update .effective_message .reply_text ("Questo utente non ha ricevuto alcun ammonimento !" )
199199
200200
201201# Dispatcher handler stop - do not async
@@ -226,7 +226,7 @@ def add_warn_filter(bot: Bot, update: Update):
226226
227227 sql .add_warn_filter (chat .id , keyword , content )
228228
229- update .effective_message .reply_text ("Warn handler added for '{}'!" .format (keyword ))
229+ update .effective_message .reply_text ("Aggiunto filtro di ammonimento per '{}'!" .format (keyword ))
230230 raise DispatcherHandlerStop
231231
232232
@@ -250,16 +250,16 @@ def remove_warn_filter(bot: Bot, update: Update):
250250 chat_filters = sql .get_chat_warn_triggers (chat .id )
251251
252252 if not chat_filters :
253- msg .reply_text ("No warning filters are active here !" )
253+ msg .reply_text ("Nessun filtro di ammonimento attivo !" )
254254 return
255255
256256 for filt in chat_filters :
257257 if filt == to_remove :
258258 sql .remove_warn_filter (chat .id , to_remove )
259- msg .reply_text ("Yep, I'll stop warning people for that ." )
259+ msg .reply_text ("Si, smetterò di ammonire la gente per questo ." )
260260 raise DispatcherHandlerStop
261261
262- msg .reply_text ("That's not a current warning filter - run /warnlist for all active warning filters ." )
262+ msg .reply_text ("Questo attualmente non è un filtro di ammonimento - esegui /warnlist per la lista di tutti i filtri attivi ." )
263263
264264
265265@run_async
@@ -268,7 +268,7 @@ def list_warn_filters(bot: Bot, update: Update):
268268 all_handlers = sql .get_chat_warn_triggers (chat .id )
269269
270270 if not all_handlers :
271- update .effective_message .reply_text ("No warning filters are active here !" )
271+ update .effective_message .reply_text ("Nessun filtro di ammonimento attivo !" )
272272 return
273273
274274 filter_list = CURRENT_WARNING_FILTER_STRING
@@ -315,21 +315,21 @@ def set_warn_limit(bot: Bot, update: Update, args: List[str]) -> str:
315315 if args :
316316 if args [0 ].isdigit ():
317317 if int (args [0 ]) < 3 :
318- msg .reply_text ("The minimum warn limit is 3!" )
318+ msg .reply_text ("Il limite di ammonimenti minimo è 3!" )
319319 else :
320320 sql .set_warn_limit (chat .id , int (args [0 ]))
321- msg .reply_text ("Updated the warn limit to {}" .format (args [0 ]))
321+ msg .reply_text ("Aggiornato il limite di ammonimenti a {}" .format (args [0 ]))
322322 return "<b>{}:</b>" \
323323 "\n #SET_WARN_LIMIT" \
324324 "\n <b>Admin:</b> {}" \
325- "\n Set the warn limit to <code>{}</code>" .format (html .escape (chat .title ),
325+ "\n Impostato il limite di ammonimenti a <code>{}</code>" .format (html .escape (chat .title ),
326326 mention_html (user .id , user .first_name ), args [0 ])
327327 else :
328- msg .reply_text ("Give me a number as an arg !" )
328+ msg .reply_text ("Dammi un numero come argomento !" )
329329 else :
330330 limit , soft_warn = sql .get_warn_setting (chat .id )
331331
332- msg .reply_text ("The current warn limit is {}" .format (limit ))
332+ msg .reply_text ("Il limite di ammonimenti attuale è {}" .format (limit ))
333333 return ""
334334
335335
@@ -343,37 +343,37 @@ def set_warn_strength(bot: Bot, update: Update, args: List[str]):
343343 if args :
344344 if args [0 ].lower () in ("on" , "yes" ):
345345 sql .set_warn_strength (chat .id , False )
346- msg .reply_text ("Too many warns will now result in a ban! " )
346+ msg .reply_text ("Troppi ammonimenti comporteranno l'espulsione permanente ( ban). " )
347347 return "<b>{}:</b>\n " \
348348 "<b>Admin:</b> {}\n " \
349- "Has enabled strong warns. Users will be banned ." .format (html .escape (chat .title ),
349+ "Ha abilitato gli ammonimenti rigidi. Gli utenti saranno banditi ." .format (html .escape (chat .title ),
350350 mention_html (user .id , user .first_name ))
351351
352352 elif args [0 ].lower () in ("off" , "no" ):
353353 sql .set_warn_strength (chat .id , True )
354- msg .reply_text ("Too many warns will now result in a kick! Users will be able to join again after ." )
354+ msg .reply_text ("Troppi ammonimenti comporteranno l'uscita forzata. Gli utenti potranno unirsi nuovamente ." )
355355 return "<b>{}:</b>\n " \
356356 "<b>Admin:</b> {}\n " \
357- "Has disabled strong warns. Users will only be kicked ." .format (html .escape (chat .title ),
357+ "Ha disabilitato gli ammonimenti rigidi. Gli utenti saranno solo cacciati ." .format (html .escape (chat .title ),
358358 mention_html (user .id ,
359359 user .first_name ))
360360
361361 else :
362- msg .reply_text ("I only understand on/yes/no/off!" )
362+ msg .reply_text ("Capisco solo on/yes/no/off!" )
363363 else :
364364 limit , soft_warn = sql .get_warn_setting (chat .id )
365365 if soft_warn :
366- msg .reply_text ("Warns are currently set to *kick* users when they exceed the limits ." ,
366+ msg .reply_text ("Gli ammonimenti sono impostati per *cacciare* (kick) gli utenti quando superano il limite ." ,
367367 parse_mode = ParseMode .MARKDOWN )
368368 else :
369- msg .reply_text ("Warns are currently set to *ban* users when they exceed the limits ." ,
369+ msg .reply_text ("Gli ammonimenti sono impostati per *bandire* (ban) gli utenti quando superano il limite ." ,
370370 parse_mode = ParseMode .MARKDOWN )
371371 return ""
372372
373373
374374def __stats__ ():
375- return "{} overall warns, across {} chats .\n " \
376- "{} warn filters, across {} chats ." .format (sql .num_warns (), sql .num_warn_chats (),
375+ return "{} ammonimenti complessivi, in {} chat .\n " \
376+ "{} filtri di ammonimento, in {} chat ." .format (sql .num_warns (), sql .num_warn_chats (),
377377 sql .num_warn_filters (), sql .num_warn_filter_chats ())
378378
379379
@@ -390,22 +390,23 @@ def __migrate__(old_chat_id, new_chat_id):
390390def __chat_settings__ (chat_id , user_id ):
391391 num_warn_filters = sql .num_warn_chat_filters (chat_id )
392392 limit , soft_warn = sql .get_warn_setting (chat_id )
393- return "This chat has `{}` warn filters. It takes `{}` warns " \
394- "before the user gets *{}*." .format (num_warn_filters , limit , "kicked " if soft_warn else "banned " )
393+ return "Questa chat ha `{}` filtri di ammonimento. Ci vogliono `{}` ammonimenti " \
394+ "prima che l'utente venga *{}*." .format (num_warn_filters , limit , "cacciato " if soft_warn else "bandito " )
395395
396396
397397__help__ = """
398- - /warns <userhandle>: get a user's number, and reason, of warnings.
399- - /warnlist: list of all current warning filters
400-
401- *Admin only:*
402- - /warn <userhandle>: warn a user. After 3 warns, the user will be banned from the group. Can also be used as a reply.
403- - /resetwarn <userhandle>: reset the warnings for a user. Can also be used as a reply.
404- - /addwarn <keyword> <reply message>: set a warning filter on a certain keyword. If you want your keyword to \
405- be a sentence, encompass it with quotes, as such: `/addwarn "very angry" This is an angry user`.
406- - /nowarn <keyword>: stop a warning filter
407- - /warnlimit <num>: set the warning limit
408- - /strongwarn <on/yes/off/no>: If set to on, exceeding the warn limit will result in a ban. Else, will just kick.
398+ - /warns <userhandle>: ritorna il numero e la ragione degli ammonimenti dell'utente.
399+ - /warnlist: mostra la lista di tutti i filtri attuali
400+
401+ *Solo admin:*
402+ - /warn <userhandle>: ammonisce un utente. Dopo 3 ammonimenti, l'utente verrà bandito dal gruppo. Può anche essere usato tramite una risposta.
403+ - /resetwarn <userhandle>: resetta gli ammonimenti per un utente. Può anche essere usato tramite una risposta.
404+ - /addwarn <keyword> <reply message>: imposta un filtro di ammonimento per una certa parola chiave. Se si vuole che la parola chiave \
405+ sia una frase basta includerla tra virgolette in questo modo: `/addwarn "molto arrabbiato" Questo è un utente arrabbiato`.
406+ - /nowarn <keyword>: rimuove il filtro di ammonimento.
407+ - /warnlimit <num>: imposta il limite di ammonimenti.
408+ - /strongwarn <on/yes/off/no>: Se impostato su on, superare il limite di ammonimenti comporterà l'espulsione permanente (ban) \
409+ altrimenti l'utente verrà solo buttato fuori.
409410"""
410411
411412__mod_name__ = "Warnings"
0 commit comments