|
|
@ -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,11 +31,10 @@ 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)
|
|
|
|
def write_db():
|
|
|
|
return db
|
|
|
|
global db
|
|
|
|
def write_db(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)
|
|
|
@ -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:
|
|
|
|