57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
import re
|
||
|
||
path = "/opt/trueconf_bot/instruct/handlers.py"
|
||
with open(path, "r") as f:
|
||
content = f.read()
|
||
|
||
old = ''' description = (
|
||
f"Пользователь {cn} ({user_id}) запросил инструкцию по Trueconf, "
|
||
f"но не имеет группы 2FA. Требуется выдача доступа."
|
||
)'''
|
||
|
||
new = ''' description = (
|
||
f"Пользователь {cn} ({user_id}) отсутствует группа 2FA."
|
||
)'''
|
||
|
||
if old in content:
|
||
content = content.replace(old, new)
|
||
with open(path, "w") as f:
|
||
f.write(content)
|
||
print("OK 1 replaced")
|
||
else:
|
||
print("OLD 1 NOT FOUND")
|
||
|
||
old2 = ''' description = (
|
||
f"Пользователь {cn} ({user_id}) найден в Active Directory, но у него не указан email. "
|
||
f"Требуется ручная проверка и выдача доступа к Trueconf."
|
||
)'''
|
||
|
||
new2 = ''' description = (
|
||
f"Пользователь {cn} ({user_id}) отсутствует группа 2FA."
|
||
)'''
|
||
|
||
if old2 in content:
|
||
content = content.replace(old2, new2)
|
||
with open(path, "w") as f:
|
||
f.write(content)
|
||
print("OK 2 replaced")
|
||
else:
|
||
print("OLD 2 NOT FOUND")
|
||
|
||
old3 = ''' description = (
|
||
f"Пользователь {cn} ({user_id}) не найден в Active Directory. "
|
||
f"Требуется ручная проверка и выдача доступа к Trueconf."
|
||
)'''
|
||
|
||
new3 = ''' description = (
|
||
f"Пользователь {cn} ({user_id}) отсутствует группа 2FA."
|
||
)'''
|
||
|
||
if old3 in content:
|
||
content = content.replace(old3, new3)
|
||
with open(path, "w") as f:
|
||
f.write(content)
|
||
print("OK 3 replaced")
|
||
else:
|
||
print("OLD 3 NOT FOUND")
|