|
|
@ -4,7 +4,7 @@ import json
|
|
|
|
|
|
|
|
|
|
|
|
from telebot import types,util
|
|
|
|
from telebot import types,util
|
|
|
|
|
|
|
|
|
|
|
|
global db, users, la
|
|
|
|
global users, la
|
|
|
|
|
|
|
|
|
|
|
|
####### CREATE DB IF NOT EXIST
|
|
|
|
####### CREATE DB IF NOT EXIST
|
|
|
|
|
|
|
|
|
|
|
@ -31,25 +31,24 @@ if not os.path.exists('la.json'):
|
|
|
|
############WORK WITH DBs##########
|
|
|
|
############WORK WITH DBs##########
|
|
|
|
|
|
|
|
|
|
|
|
def read_db():
|
|
|
|
def read_db():
|
|
|
|
global db
|
|
|
|
with open('db.json', 'r') as openfile:
|
|
|
|
with open('db.json', 'r') as openfile:
|
|
|
|
db = json.load(openfile)
|
|
|
|
db = json.load(openfile)
|
|
|
|
return db
|
|
|
|
def write_db():
|
|
|
|
def write_db(db):
|
|
|
|
global db
|
|
|
|
js = json.dumps(db, indent=2)
|
|
|
|
js = json.dumps(db, indent=2)
|
|
|
|
with open('db.json', 'w') as outfile:
|
|
|
|
with open('db.json', 'w') as outfile:
|
|
|
|
outfile.write(js)
|
|
|
|
outfile.write(js)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read_users():
|
|
|
|
def read_users():
|
|
|
|
global users
|
|
|
|
global users
|
|
|
|
with open('users.json', 'r') as openfile:
|
|
|
|
with open('users.json', 'r') as openfile:
|
|
|
|
users = json.load(openfile)
|
|
|
|
users = json.load(openfile)
|
|
|
|
def write_users():
|
|
|
|
def write_users():
|
|
|
|
global users
|
|
|
|
global users
|
|
|
|
js = json.dumps(users, indent=2)
|
|
|
|
js = json.dumps(users, indent=2)
|
|
|
|
with open('users.json', 'w') as outfile:
|
|
|
|
with open('users.json', 'w') as outfile:
|
|
|
|
outfile.write(js)
|
|
|
|
outfile.write(js)
|
|
|
|
|
|
|
|
|
|
|
|
# LA - Low Admin.
|
|
|
|
# LA - Low Admin.
|
|
|
|
# Admin permissions in bot without admin rights.
|
|
|
|
# Admin permissions in bot without admin rights.
|
|
|
@ -189,7 +188,7 @@ def analytic(message):
|
|
|
|
#############TOKEN INIT#####
|
|
|
|
#############TOKEN INIT#####
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
read_db()
|
|
|
|
db = read_db()
|
|
|
|
read_users()
|
|
|
|
read_users()
|
|
|
|
bot = telebot.TeleBot(db['token'])
|
|
|
|
bot = telebot.TeleBot(db['token'])
|
|
|
|
|
|
|
|
|
|
|
@ -320,20 +319,19 @@ def unban(message):
|
|
|
|
def setwelcome(message):
|
|
|
|
def setwelcome(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if have_rights(message):
|
|
|
|
if have_rights(message):
|
|
|
|
global db
|
|
|
|
db = read_db()
|
|
|
|
db[str(message.chat.id)] = message.html_text[ message.text.find(' ') + 1 :]
|
|
|
|
db[str(message.chat.id)] = message.html_text[ message.text.find(' ') + 1 :]
|
|
|
|
|
|
|
|
|
|
|
|
bot.reply_to(message, f'''Установлено новое приветственное сообщение:
|
|
|
|
bot.reply_to(message, f'''Установлено новое приветственное сообщение:
|
|
|
|
\n{db[str(message.chat.id)]}''', parse_mode='HTML')
|
|
|
|
\n{db[str(message.chat.id)]}''', parse_mode='HTML')
|
|
|
|
write_db()
|
|
|
|
write_db(db)
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
catch_error(message, e)
|
|
|
|
catch_error(message, e)
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['welcome'])
|
|
|
|
@bot.message_handler(commands=['welcome'])
|
|
|
|
def welcome(message):
|
|
|
|
def welcome(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
global db
|
|
|
|
db = read_db()
|
|
|
|
read_db()
|
|
|
|
|
|
|
|
bot.reply_to(message, f'''Приветственное сообщение:
|
|
|
|
bot.reply_to(message, f'''Приветственное сообщение:
|
|
|
|
\n{db[str(message.chat.id)]}''', parse_mode='HTML')
|
|
|
|
\n{db[str(message.chat.id)]}''', parse_mode='HTML')
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
@ -377,6 +375,22 @@ def delete(message):
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
catch_error(message, e)
|
|
|
|
catch_error(message, e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['pin'])
|
|
|
|
|
|
|
|
def pin(message):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
if have_rights(message):
|
|
|
|
|
|
|
|
bot.pin_chat_message(message.chat.id, message.reply_to_message.id)
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
catch_error(message, e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['unpin'])
|
|
|
|
|
|
|
|
def unpin(message):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
if have_rights(message):
|
|
|
|
|
|
|
|
bot.unpin_chat_message(message.chat.id, message.reply_to_message.id)
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
catch_error(message, e)
|
|
|
|
|
|
|
|
|
|
|
|
### EXPEREMENTAL
|
|
|
|
### EXPEREMENTAL
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['secret'])
|
|
|
|
@bot.message_handler(commands=['secret'])
|
|
|
@ -438,7 +452,7 @@ def la_list(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if have_rights(message, set_la=True):
|
|
|
|
if have_rights(message, set_la=True):
|
|
|
|
la = read_la()
|
|
|
|
la = read_la()
|
|
|
|
if have_la(str(message.chat.id)):
|
|
|
|
if have_la(message):
|
|
|
|
s = 'Список администраторов в режиме low-admin:\n'
|
|
|
|
s = 'Список администраторов в режиме low-admin:\n'
|
|
|
|
for i in la[str(message.chat.id)]:
|
|
|
|
for i in la[str(message.chat.id)]:
|
|
|
|
s = s + '\n@' + i
|
|
|
|
s = s + '\n@' + i
|
|
|
@ -451,7 +465,7 @@ def la_add(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if have_rights(message, set_la=True):
|
|
|
|
if have_rights(message, set_la=True):
|
|
|
|
la = read_la()
|
|
|
|
la = read_la()
|
|
|
|
if have_la(message.chat.id):
|
|
|
|
if have_la(message):
|
|
|
|
nick = message.text.split()[1][1:]
|
|
|
|
nick = message.text.split()[1][1:]
|
|
|
|
print(la)
|
|
|
|
print(la)
|
|
|
|
la[str(message.chat.id)].append(nick)
|
|
|
|
la[str(message.chat.id)].append(nick)
|
|
|
@ -466,7 +480,7 @@ def la_del(message, set_la=True):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if have_rights(message, set_la=True):
|
|
|
|
if have_rights(message, set_la=True):
|
|
|
|
la = read_la()
|
|
|
|
la = read_la()
|
|
|
|
if have_la(message.chat.id):
|
|
|
|
if have_la(message):
|
|
|
|
nick = message.text.split()[1][1:]
|
|
|
|
nick = message.text.split()[1][1:]
|
|
|
|
|
|
|
|
|
|
|
|
if nick in la[str(message.chat.id)]:
|
|
|
|
if nick in la[str(message.chat.id)]:
|
|
|
@ -514,8 +528,12 @@ def support(message):
|
|
|
|
@bot.message_handler(content_types=['new_chat_members'])
|
|
|
|
@bot.message_handler(content_types=['new_chat_members'])
|
|
|
|
def handler_new_member(message):
|
|
|
|
def handler_new_member(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
global db
|
|
|
|
db = read_db()
|
|
|
|
read_db()
|
|
|
|
if str(message.chat.id) not in db:
|
|
|
|
|
|
|
|
db[str(message.chat.id)] = 'Приветственное сообщение не задано.\n Задайте его с помощью /setwelcome ...'
|
|
|
|
|
|
|
|
la = read_la()
|
|
|
|
|
|
|
|
la[str(message.chat.id)] = []
|
|
|
|
|
|
|
|
write_la(la)
|
|
|
|
bot.reply_to(message, db[str(message.chat.id)], parse_mode='HTML')
|
|
|
|
bot.reply_to(message, db[str(message.chat.id)], parse_mode='HTML')
|
|
|
|
analytic(message)
|
|
|
|
analytic(message)
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|