|
|
|
@ -54,14 +54,13 @@ def write_users():
|
|
|
|
|
# LA - Low Admin.
|
|
|
|
|
# Admin permissions in bot without admin rights.
|
|
|
|
|
def read_la():
|
|
|
|
|
global la
|
|
|
|
|
with open('la.json', 'r') as openfile:
|
|
|
|
|
la = json.load(openfile)
|
|
|
|
|
def write_la():
|
|
|
|
|
global la
|
|
|
|
|
js = json.dumps(la, indent=2)
|
|
|
|
|
with open("la.json", "w") as outfile:
|
|
|
|
|
outfile.write(js)
|
|
|
|
|
with open('la.json', 'r') as openfile:
|
|
|
|
|
la = json.load(openfile)
|
|
|
|
|
return la
|
|
|
|
|
def write_la(la):
|
|
|
|
|
js = json.dumps(la, indent=2)
|
|
|
|
|
with open("la.json", "w") as outfile:
|
|
|
|
|
outfile.write(js)
|
|
|
|
|
|
|
|
|
|
####################FAST HASH#################
|
|
|
|
|
from xxhash import xxh32
|
|
|
|
@ -147,7 +146,6 @@ def get_time(message):
|
|
|
|
|
if time:
|
|
|
|
|
break
|
|
|
|
|
for f in list(formats.keys()):
|
|
|
|
|
# print(i, ' ', f)
|
|
|
|
|
if f in i:
|
|
|
|
|
try:
|
|
|
|
|
time = [i[:-1], int(i[:-1]) * formats[i[-1]][0] , formats[i[-1]][1] ]
|
|
|
|
@ -158,7 +156,7 @@ def get_time(message):
|
|
|
|
|
return time
|
|
|
|
|
|
|
|
|
|
def have_rights(message, set_la = False):
|
|
|
|
|
global la ; read_la()
|
|
|
|
|
la = read_la()
|
|
|
|
|
if message.from_user.id in get_admins(message):
|
|
|
|
|
return True
|
|
|
|
|
elif is_anon(message):
|
|
|
|
@ -225,6 +223,8 @@ def help(message):
|
|
|
|
|
/chatid ⇁ Айди чата
|
|
|
|
|
/del ⇁ Удаление сообщения
|
|
|
|
|
|
|
|
|
|
/la - всё о режиме 'low admin'
|
|
|
|
|
|
|
|
|
|
/secret ⇁ Функция для получения ссылки html на пользователя в лс.
|
|
|
|
|
/html <code> ⇁ Отправка текста сообщения в режиме формата html.
|
|
|
|
|
|
|
|
|
@ -411,21 +411,30 @@ def chatid(message):
|
|
|
|
|
|
|
|
|
|
def have_la(id):
|
|
|
|
|
try:
|
|
|
|
|
global la ; read_la()
|
|
|
|
|
la = read_la()
|
|
|
|
|
if id in la:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
la[id] = []
|
|
|
|
|
write_la()
|
|
|
|
|
write_la(la)
|
|
|
|
|
return True
|
|
|
|
|
except Exception as e:
|
|
|
|
|
catch_error(message, e)
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['la'])
|
|
|
|
|
def la(message):
|
|
|
|
|
bot.reply_to(message, f'''Доступные команды:
|
|
|
|
|
|
|
|
|
|
{telebot.formatting.hcode("/la-list")} - список администраторов в режиме low-admin
|
|
|
|
|
{telebot.formatting.hcode("/la-add @nick")} - добавить в администраторы
|
|
|
|
|
{telebot.formatting.hcode("/la-del @nick")} - удалить из администраторов
|
|
|
|
|
''', parse_mode = 'HTML')
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['la-list'])
|
|
|
|
|
def la_list(message):
|
|
|
|
|
try:
|
|
|
|
|
if have_rights(message, set_la=True):
|
|
|
|
|
global la ; read_la()
|
|
|
|
|
la = read_la()
|
|
|
|
|
if have_la(str(message.chat.id)):
|
|
|
|
|
s = "Список администраторов в режиме low-admin:\n"
|
|
|
|
|
for i in la[str(message.chat.id)]:
|
|
|
|
@ -438,11 +447,13 @@ def la_list(message):
|
|
|
|
|
def la_add(message):
|
|
|
|
|
try:
|
|
|
|
|
if have_rights(message, set_la=True):
|
|
|
|
|
global la ; read_la()
|
|
|
|
|
la = read_la()
|
|
|
|
|
if have_la(message.chat.id):
|
|
|
|
|
nick = message.text.split()[1][1:]
|
|
|
|
|
la[message.chat.id].append(nick)
|
|
|
|
|
write_la()
|
|
|
|
|
print(la)
|
|
|
|
|
la[str(message.chat.id)].append(nick)
|
|
|
|
|
print(la)
|
|
|
|
|
write_la(la)
|
|
|
|
|
bot.reply_to(message, f"Пользователь @{nick} успешно добавлен в список администраторов.")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
catch_error(message, e)
|
|
|
|
@ -451,13 +462,13 @@ def la_add(message):
|
|
|
|
|
def la_del(message, set_la=True):
|
|
|
|
|
try:
|
|
|
|
|
if have_rights(message, set_la=True):
|
|
|
|
|
global la ; read_la()
|
|
|
|
|
la = read_la()
|
|
|
|
|
if have_la(message.chat.id):
|
|
|
|
|
nick = message.text.split()[1][1:]
|
|
|
|
|
|
|
|
|
|
if nick in la[message.chat.id]:
|
|
|
|
|
del la[message.chat.id]
|
|
|
|
|
write_la()
|
|
|
|
|
if nick in la[str(message.chat.id)]:
|
|
|
|
|
la[str(message.chat.id)].remove(nick)
|
|
|
|
|
write_la(la)
|
|
|
|
|
bot.reply_to(message, f"Пользователь @{nick} был исключён из списка администраторов.")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
catch_error(message, e)
|
|
|
|
@ -557,7 +568,7 @@ def catch_error(message, e, err_type = None):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##################MAIN THREAD#####
|
|
|
|
|
#'''
|
|
|
|
|
'''
|
|
|
|
|
while True:
|
|
|
|
|
try:
|
|
|
|
|
bot.polling()
|
|
|
|
@ -565,6 +576,6 @@ while True:
|
|
|
|
|
exit()
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
#'''
|
|
|
|
|
'''
|
|
|
|
|
bot.polling()
|
|
|
|
|
#'''
|
|
|
|
|