diff --git a/.gitignore b/.gitignore
index 07a6cb4..fe38234 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,5 @@ tg_bot/scripts/__pycache__
.vscode
tg_bot/scripts/config1.py
tg_bot/tmp scripts
+tg_bot/brainstorm.txt
+chess_shit.py
diff --git a/tg_bot/scripts/add.py b/tg_bot/scripts/add.py
new file mode 100644
index 0000000..e69de29
diff --git a/tg_bot/scripts/main.py b/tg_bot/scripts/main.py
index 24533f3..9fa6823 100644
--- a/tg_bot/scripts/main.py
+++ b/tg_bot/scripts/main.py
@@ -1,14 +1,29 @@
-from modules import *
-from modules.core import *
+
+#from modules import *
+#from modules.core import *
from config import *
+
+import modules.core.database as database
+import modules.core.mute as mute
+import modules.core.welcome as welcome
+#import modules.core.extract as extract
+
+import modules.core.filter as filter
+
+import modules.core.unparse as unparse
+
+import modules.delete as delete
+
+import modules.core.note as note
+
+
from telegram import Message, Chat, Update, Bot, User, ChatMember
from telegram import ParseMode, InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardMarkup
from telegram.error import Unauthorized, BadRequest, TimedOut, NetworkError, ChatMigrated, TelegramError
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackQueryHandler, CallbackContext
from telegram.utils.helpers import escape_markdown
-
import logging
from mysql import connector
@@ -18,6 +33,8 @@
import sys
import os
+import threading
+
"""
import concurrent.futures
from concurrent.futures import ProcessPoolExecutor
@@ -69,8 +86,12 @@ def write(self, data):
updater = Updater(bot_token, use_context=True)
dp = updater.dispatcher
+
# Initialize Database & Cursor
+botdb = None
+
def load():
+ global botdb
db = connector.connect(
host=database_host,
user=database_user,
@@ -87,17 +108,19 @@ def load():
database=database_name)
cursor = db.cursor(buffered=True)
- database_create = database.database_create(cursor, db)
- database_create.create_base()
+ create_db = database.create_db().create_base()
+ #del create_db
+
+ botdb = database.bot_db()
load()
print("database loaded")
-def unparse(update, context): # Unparse Incoming Responses
- start = time.process_time()
+def unparse_func(update, context): # Unparse Incoming Responses
+ start = time.process_time()
+
msg = update.message
- # print("\n", msg)
user = msg['from_user']
chat = msg['chat']
@@ -109,24 +132,24 @@ def unparse(update, context): # Unparse Incoming Responses
tag_user = tagmsg['from_user']
- database.add_user(user=tag_user)
+ botdb.add_user(user=tag_user)
except:
pass
- database.add_user(user=user)
- database.add_chat(chat=chat)
- database.add_link(chat=chat, user=user)
+ botdb.parse(chat=chat, user=user)
# user_status = context.bot.get_chat_member(chat['id'], user['id'])
# print(user_status['status'])
-
# print(chatmember)
# print(eval(str(context.bot.getChat(chat['id']).permissions)))
+
+ threading.Thread(target=filter.filter, args=(msg,chat,user,tag_user), daemon=True).start()
print("\n", time.process_time() - start, "\n")
+
def button(update: Update, context: CallbackContext):
start = time.process_time()
@@ -183,20 +206,49 @@ def but_veri(update: Update, context: CallbackContext):
def main(): # Main Function
+
print("started")
if deb == 0:
logger = writer()
sys.stdout = logger
sys.stderr = logger
+
+ dp.bot.send_message(chat_id=owner_id, text="Started Service !\n\nTime : " +
+ time.strftime("%Y-%m-%d (%H:%M:%S)") + "
", parse_mode="HTML")
+
+
+ delete_cmd = ("delete", "remove")
+
dp.add_handler(MessageHandler(
Filters.status_update.new_chat_members, welcome.gate))
+ dp.add_handler(MessageHandler(
+ Filters.status_update.left_chat_member, welcome.farewell))
+
- dp.add_handler(CallbackQueryHandler(button))
+ dp.add_handler(CommandHandler("delete", delete.tag_del_cls)) # delete.tag_del_cls
+ dp.add_handler(CommandHandler("purge", delete.mul_del_cls))
+ dp.add_handler(CommandHandler("sdel", delete.s_del_cls))
- dp.add_handler(MessageHandler(Filters.all, unparse))
+ #dp.add_handler(CommandHandler("admin", delete.lock))
+ dp.add_handler(CommandHandler("lock", filter.filter_router))
+ dp.add_handler(CommandHandler("unlock", filter.filter_router))
+ dp.add_handler(CommandHandler("filter", filter.filter_router))
+ dp.add_handler(CommandHandler("filteradd", filter.filter_router))
+ dp.add_handler(CommandHandler("filterdel", filter.filter_router))
+
+
+ dp.add_handler(CommandHandler("noteadd", note.note_router))
+ dp.add_handler(CommandHandler("notedel", note.note_router))
+ dp.add_handler(CommandHandler("notes", note.note_router))
+
+ #dp.add_handler(CallbackQueryHandler(button))
+
+ dp.add_handler(MessageHandler(Filters.all, unparse_func))
+ #dp.add_handler(MessageHandler(Filters.all, unparse.thread_unparse))
+
updater.start_polling()
updater.idle()
diff --git a/tg_bot/scripts/modules/core/database.py b/tg_bot/scripts/modules/core/database.py
index 63e7ef6..88bef86 100644
--- a/tg_bot/scripts/modules/core/database.py
+++ b/tg_bot/scripts/modules/core/database.py
@@ -1,306 +1,451 @@
-cursor = db = None
-user = chat = None
-
-
-class database_create:
-
- # Variable Initialisation
-
- def __init__(self, cursorr, dbr):
- global cursor
- global db
-
- cursor = cursorr
- db = dbr
-
- # Table Creation
-
- def chat_base(self):
-
- sql = (
- "CREATE TABLE IF NOT EXISTS chat_base ( chat_id VARCHAR(14) PRIMARY KEY, type VARCHAR(14), title VARCHAR(48), username VARCHAR(48), join_date TIMESTAMP)"
- ) # chat_base : chat_id | type | title | username | join_date
-
- cursor.execute(sql)
- db.commit()
-
- def user_base(self):
-
- sql = (
- "CREATE TABLE IF NOT EXISTS user_base ( user_id VARCHAR(14) PRIMARY KEY, first_name VARCHAR(48), last_name VARCHAR(48), username VARCHAR(48), is_bot BOOLEAN, date TIMESTAMP)"
- ) # user_base : user_id | first_name | lastname | username | is_bot | date
-
- cursor.execute(sql)
- db.commit()
-
- def settings_base(self):
-
- sql = (
- "CREATE TABLE IF NOT EXISTS settings_base ( chat_id VARCHAR(14) PRIMARY KEY, members TINYINT, warn_limit TINYINT DEFAULT 3, strike_action TINYINT DEFAULT 0, disabled_commands TINYINT DEFAULT 0, filter TINYINT DEFAULT 0, recent_pin TINYINT DEFAULT 5)"
- ) # settings_base : chat_id | members | warn_limit | strike_action | disabled_commands | filter | recent_pin
-
- cursor.execute(sql)
- db.commit()
-
- def notes_base(self):
-
- sql = (
- "CREATE TABLE IF NOT EXISTS notes_base ( id VARCHAR(14) PRIMARY KEY, chat_id VARCHAR(14), note_name VARCHAR(32), note_text TEXT, set_by VARCHAR(32), date TIMESTAMP)"
- ) # notes_base : id | chat_id | note_name | note_text | set_by | date
-
- cursor.execute(sql)
- db.commit()
-
- def warn_base(self):
-
- sql = (
- "CREATE TABLE IF NOT EXISTS warn_base ( id VARCHAR(14) PRIMARY KEY, chat_id VARCHAR(14), note_name VARCHAR(32), note_text TEXT, set_by VARCHAR(32), date TIMESTAMP)"
- ) # warn_base : id | chat_id | user_id | by_user_id | message_id | reason | date
-
- cursor.execute(sql)
- db.commit()
-
- def link_base(self):
-
- sql = (
- "CREATE TABLE IF NOT EXISTS link_base ( id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, chat_id VARCHAR(14), user_id VARCHAR(14), status VARCHAR(14) DEFAULT 'member', bio TEXT, join_date TIMESTAMP, last_active TIMESTAMP)"
- ) # link_base : id | chat_id | user_id | status | bio | join_date | last_active
-
- cursor.execute(sql)
- db.commit()
-
- def filter_base(self):
-
- sql = (
- "CREATE TABLE IF NOT EXISTS filter_base ( id VARCHAR(14) PRIMARY KEY, chat_id VARCHAR(14), user_id VARCHAR(14), word VARCHAR(32), reply_text TEXT, action VARCHAR(14))"
- ) # filter_base : id | chat_id | user_id | word | reply_text | action
+from os import system
+from re import L
+from time import sleep
+
+from config import *
+
+from mysql import connector
+
+
+def load():
+ db = connector.connect(
+ host=database_host,
+ user=database_user,
+ password=database_password,
+ database=database_name)
+ cursor = db.cursor(buffered=True)
+
+ bot_db(cursor,db)
+
+class create_db:
+ # Variable Initialisation
+ def __init__(self):
+ self.db = connector.connect(
+ host=database_host,
+ user=database_user,
+ password=database_password,
+ database=database_name)
+ self.cursor = self.db.cursor(buffered=True)
+
+ self.user = self.chat = None
+
+ # Table Creation
+ def chat_base(self):
+ sql = (
+ "CREATE TABLE IF NOT EXISTS chat_base ( chat_id VARCHAR(14) PRIMARY KEY, type VARCHAR(14), title VARCHAR(48), username VARCHAR(48), join_date TIMESTAMP)"
+ ) # chat_base : chat_id | type | title | username | join_date
+ self.cursor.execute(sql)
+ self.db.commit()
+
+ def user_base(self):
+ sql = (
+ "CREATE TABLE IF NOT EXISTS user_base ( user_id VARCHAR(14) PRIMARY KEY, first_name VARCHAR(48), last_name VARCHAR(48), username VARCHAR(48), is_bot BOOLEAN, date TIMESTAMP)"
+ ) # user_base : user_id | first_name | lastname | username | is_bot | date
+ self.cursor.execute(sql)
+ self.db.commit()
+
+ def settings_base(self):
+ sql = (
+ "CREATE TABLE IF NOT EXISTS settings_base ( chat_id VARCHAR(14) PRIMARY KEY, members TINYINT, warn_limit TINYINT DEFAULT 3, strike_action TINYINT DEFAULT 0, disabled_commands TINYINT DEFAULT 0, filter TINYINT DEFAULT 0, notes TINYINT DEFAULT 0, chat_lock TINYINT DEFAULT 0, recent_pin TINYINT)"
+ ) # settings_base : chat_id | members | warn_limit | strike_action | disabled_commands | filter | notes | lock | recent_pin
+ self.cursor.execute(sql)
+ self.db.commit()
+
+ def filter_base(self):
+ sql = (
+ "CREATE TABLE IF NOT EXISTS filter_base ( id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, chat_id VARCHAR(14), filter_word VARCHAR(32), filter_type TINYINT DEFAULT 0, response TEXT NULL, remove BOOLEAN DEFAULT 0)"
+ ) # filter_base : id | chat_id | filter_word | filter_type | response | remove
+ self.cursor.execute(sql)
+ self.db.commit()
+
+ def notes_base(self):
+ sql = (
+ "CREATE TABLE IF NOT EXISTS notes_base ( id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, chat_id VARCHAR(14), note_name VARCHAR(32), note_text TEXT, set_by VARCHAR(32), date TIMESTAMP)"
+ ) # notes_base : id | chat_id | note_name | note_text | set_by | date
+ self.cursor.execute(sql)
+ self.db.commit()
+
+ def warn_base(self):
+ sql = (
+ "CREATE TABLE IF NOT EXISTS warn_base ( id VARCHAR(14) PRIMARY KEY, chat_id VARCHAR(14), note_name VARCHAR(32), note_text TEXT, set_by VARCHAR(32), date TIMESTAMP)"
+ ) # warn_base : id | chat_id | user_id | by_user_id | message_id | reason | date
+ self.cursor.execute(sql)
+ self.db.commit()
+
+ def link_base(self):
+ sql = (
+ "CREATE TABLE IF NOT EXISTS link_base ( id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, chat_id VARCHAR(14), user_id VARCHAR(14), status VARCHAR(14) DEFAULT 'member', bio TEXT, join_date TIMESTAMP, last_active TIMESTAMP)"
+ ) # link_base : id | chat_id | user_id | status | bio | join_date | last_active
+ self.cursor.execute(sql)
+ self.db.commit()
+
+ def disabled_commands_base(self):
+ sql = (
+ "CREATE TABLE IF NOT EXISTS disabled_commands_base ( id VARCHAR(14) PRIMARY KEY, chat_id VARCHAR(14), user_id VARCHAR(14), command VARCHAR(32), set_by VARCHAR(14))"
+ ) # disabled_commands_base : id | chat_id | user_id | command | set_by
+ self.cursor.execute(sql)
+ self.db.commit()
+
+ def recent_base(self):
+ sql = (
+ "CREATE TABLE IF NOT EXISTS recent_base ( id VARCHAR(14) PRIMARY KEY, chat_id VARCHAR(14), pin_text TEXT, message_id VARCHAR(14), pin_by VARCHAR(32), date TIMESTAMP)"
+ ) # recent_base : id | chat_id | pin_text | message_id | pin_by | date
+ self.cursor.execute(sql)
+ self.db.commit()
+
+ def rules_base(self):
+ sql = (
+ "CREATE TABLE IF NOT EXISTS rules_base ( chat_id VARCHAR(14) PRIMARY KEY, rule_text TEXT, rule_type VARCHAR(14), message_id VARCHAR(14), set_by VARCHAR(32), date TIMESTAMP)"
+ ) # rules_base : chat_id | rule_text | rule_type | message_id | set_by | date
+ self.cursor.execute(sql)
+ self.db.commit()
+
+ def welcome_base(self):
+ sql = (
+ "CREATE TABLE IF NOT EXISTS welcome_base ( chat_id VARCHAR(14) PRIMARY KEY, welcome_text TEXT, verification BOOLEAN DEFAULT 0, fail_action TINYINT DEFAULT 1)"
+ ) # welcome_base : chat_id | welcome_text | verification | fail_action
+ self.cursor.execute(sql)
+ self.db.commit()
+
+ def create_base(self):
+ self.chat_base()
+ self.user_base()
+ self.link_base()
+ self.settings_base()
+ self.filter_base()
+ self.notes_base()
+ self.welcome_base()
+
+try:
+ class bot_db:
+ # Variable Initialisation
+ def __init__(self):
+ self.db = connector.connect(
+ host=database_host,
+ user=database_user,
+ password=database_password,
+ database=database_name)
+ self.cursor = self.db.cursor(buffered=True)
+
+ self.user = self.chat = None
+
+ def parse(self,chat,user):
+ self.add_user(user)
+ self.add_chat(chat)
+ self.add_link(chat, user)
+
+
+ def add_user(self,user):
+ username = user['username']
+ first_name = user['first_name']
+ last_name = user['last_name']
+
+ sql = (
+ "INSERT INTO user_base (user_id, username, first_name, last_name, is_bot, date) VALUE(%s, %s, %s, %s, %s, CURRENT_TIMESTAMP()) ON DUPLICATE KEY UPDATE username=%s, first_name=%s, last_name=%s")
+ data = (
+ user['id'],
+ username, first_name, last_name,
+ user['is_bot'],
+
+ username, first_name, last_name,
+ )
- cursor.execute(sql)
- db.commit()
+ self.cursor.execute(sql, data)
+ self.db.commit()
- def disabled_commands_base(self):
- sql = (
- "CREATE TABLE IF NOT EXISTS disabled_commands_base ( id VARCHAR(14) PRIMARY KEY, chat_id VARCHAR(14), user_id VARCHAR(14), command VARCHAR(32), set_by VARCHAR(14))"
- ) # disabled_commands_base : id | chat_id | user_id | command | set_by
+ def get_user(self,user_id):
+ sql = (
+ "SELECT * FROM user_base WHERE user_id=%s"
+ )
- cursor.execute(sql)
- db.commit()
+ data = (
+ user_id,
+ )
- def recent_base(self):
+ self.cursor.execute(sql, data)
- sql = (
- "CREATE TABLE IF NOT EXISTS recent_base ( id VARCHAR(14) PRIMARY KEY, chat_id VARCHAR(14), pin_text TEXT, message_id VARCHAR(14), pin_by VARCHAR(32), date TIMESTAMP)"
- ) # recent_base : id | chat_id | pin_text | message_id | pin_by | date
+ return self.cursor.fetchone()
- cursor.execute(sql)
- db.commit()
- def rules_base(self):
- sql = (
- "CREATE TABLE IF NOT EXISTS rules_base ( chat_id VARCHAR(14) PRIMARY KEY, rule_text TEXT, rule_type VARCHAR(14), message_id VARCHAR(14), set_by VARCHAR(32), date TIMESTAMP)"
- ) # rules_base : chat_id | rule_text | rule_type | message_id | set_by | date
+ def add_chat(self,chat):
+ title = chat['title']
+ username = chat['username']
- cursor.execute(sql)
- db.commit()
+ sql = (
+ "INSERT INTO chat_base (chat_id, type, title, username, join_date) VALUE(%s, %s, %s, %s, CURRENT_TIMESTAMP()) ON DUPLICATE KEY UPDATE title=%s, username=%s")
+ data = (
+ chat['id'], chat['type'],
+ title, username,
- def welcome_base(self):
+ title, username
+ )
+ # print(data)
- sql = (
- "CREATE TABLE IF NOT EXISTS welcome_base ( chat_id VARCHAR(14) PRIMARY KEY, welcome_text TEXT, verification BOOLEAN DEFAULT 0, fail_action TINYINT DEFAULT 1)"
- ) # welcome_base : chat_id | welcome_text | verification | fail_action
+ self.cursor.execute(sql, data)
+ self.db.commit()
- cursor.execute(sql)
- db.commit()
- def create_base(self):
- self.chat_base()
- self.user_base()
- self.link_base()
- self.settings_base()
- self.welcome_base()
+ def get_chat(self,chat_id):
+ sql = (
+ "SELECT * FROM chat_base WHERE chat_id=%s"
+ )
+ data = (
+ chat_id,
+ )
-def add_user(user):
- username = user['username']
- first_name = user['first_name']
- last_name = user['last_name']
+ self.cursor.execute(sql, data)
- sql = (
- "INSERT INTO user_base (user_id, username, first_name, last_name, is_bot, date) VALUE(%s, %s, %s, %s, %s, CURRENT_TIMESTAMP()) ON DUPLICATE KEY UPDATE username=%s, first_name=%s, last_name=%s")
- data = (
- user['id'],
- username, first_name, last_name,
- user['is_bot'],
+ return self.cursor.fetchone()
- username, first_name, last_name,
- )
- # print(data)
- cursor.execute(sql, data)
- db.commit()
+ def add_link(self,chat, user, status="member", replace=0):
+ chat_id = chat['id']
+ user_id = user['id']
-def get_user(user_id):
- sql = (
- "SELECT * FROM user_base WHERE user_id=%s"
- )
+ sql = (
+ "SELECT (1) FROM link_base WHERE chat_id=%s AND user_id=%s LIMIT 1"
+ )
+ data = (
+ chat_id,
- data = (
- user_id,
- )
+ user_id
+ )
- cursor.execute(sql, data)
+ self.cursor.execute(sql, data)
+
+ if self.cursor.fetchone():
+ if replace == 1:
+ sql1 = (
+ "UPDATE link_base SET status=%s, last_active=CURRENT_TIMESTAMP() WHERE chat_id=%s AND user_id= %s LIMIT 1"
+ )
+ data1 = (
+ status, chat_id, user_id
+ )
+ else:
+ sql1 = (
+ "UPDATE link_base SET last_active=CURRENT_TIMESTAMP() WHERE chat_id=%s AND user_id= %s LIMIT 1"
+ )
+ data1 = (
+ chat_id, user_id
+ )
+ else:
+ sql1 = (
+ "INSERT INTO link_base (chat_id, user_id, status, join_date, last_active) VALUE(%s, %s, %s, CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP())"
+ )
+ data1 = (
+ chat_id, user_id, status
+ )
+
+ self.cursor.execute(sql1, data1)
+ self.db.commit()
+
+
+ def get_link(self,chat_id, user_id):
+ sql = (
+ "SELECT * FROM link_base WHERE chat_id=%s AND user_id=%s"
+ )
- return cursor.fetchone()
+ data = (
+ chat_id, user_id,
+ )
+ self.cursor.execute(sql, data)
+
+ return self.cursor.fetchone()
+
+
+ def add_settings(self, chat_id, members=None,lock=None,filter=None,notes=None):
+ if lock != None:
+ sql = (
+ "INSERT INTO settings_base (chat_id, chat_lock) VALUE(%s, %s) ON DUPLICATE KEY UPDATE chat_lock=%s"
+ )
+ data = (
+ chat_id, lock,
+ lock,
+ )
+ elif filter != None:
+ sql = (
+ "INSERT INTO settings_base (chat_id, filter) VALUE(%s, %s) ON DUPLICATE KEY UPDATE filter=%s"
+ )
+ data = (
+ chat_id, filter,
+ filter,
+ )
+ elif notes != None:
+ sql = (
+ "INSERT INTO settings_base (chat_id, notes) VALUE(%s, %s) ON DUPLICATE KEY UPDATE notes=%s"
+ )
+ data = (
+ chat_id, notes,
+ notes,
+ )
+ elif members != None:
+ sql = (
+ "INSERT INTO settings_base (chat_id, members) VALUE(%s, %s) ON DUPLICATE KEY UPDATE members=%s"
+ )
+ data = (
+ chat_id, members,
+ members,
+ )
+
+ self.cursor.execute(sql, data)
+ self.db.commit()
+
+
+ def get_settings(self,chat_id):
+ sql = (
+ "SELECT * FROM settings_base WHERE chat_id=%s"
+ )
+ data = (
+ chat_id,
+ )
-def add_chat(chat):
- title = chat['title']
- username = chat['username']
+ self.cursor.execute(sql, data)
- sql = (
- "INSERT INTO chat_base (chat_id, type, title, username, join_date) VALUE(%s, %s, %s, %s, CURRENT_TIMESTAMP()) ON DUPLICATE KEY UPDATE title=%s, username=%s")
- data = (
- chat['id'], chat['type'],
- title, username,
+ return self.cursor.fetchone()
- title, username
- )
- # print(data)
- cursor.execute(sql, data)
- db.commit()
+ def add_note(self, chat_id, note_name, note_text, set_by):
+ sql = (
+ "REPLACE INTO notes_base (chat_id, note_name, note_text, set_by, date) VALUE(%s, %s, %s, %s, CURRENT_TIMESTAMP())"
+ )
+ data = (
+ chat_id, note_name, note_text, set_by,
+ )
-def get_chat(chat_id):
- sql = (
- "SELECT * FROM chat_base WHERE chat_id=%s"
- )
+ self.cursor.execute(sql, data)
+ self.db.commit()
- data = (
- chat_id,
- )
- cursor.execute(sql, data)
+ def get_note(self,chat_id):
+ sql = (
+ "SELECT * FROM notes_base WHERE chat_id=%s"
+ )
- return cursor.fetchone()
+ data = (
+ chat_id,
+ )
+ self.cursor.execute(sql, data)
+ return self.cursor.fetchall()
-def add_link(chat, user, status="member", replace=0):
- chat_id = chat['id']
- user_id = user['id']
+ def get_note_text(self,chat_id,note_name=None):
+ sql = (
+ "SELECT * FROM notes_base WHERE chat_id=%s AND note_name=%s LIMIT 1"
+ )
- sql = (
- "SELECT (1) FROM link_base WHERE chat_id=%s AND user_id=%s LIMIT 1"
- )
- data = (
- chat_id,
+ data = (
+ chat_id,note_name,
+ )
- user_id
- )
- # print(data)
+ self.cursor.execute(sql, data)
- cursor.execute(sql, data)
+ return self.cursor.fetchone()
- if cursor.fetchone():
- if replace == 1:
- sql1 = (
- "UPDATE link_base SET status=%s, last_active=CURRENT_TIMESTAMP() WHERE chat_id=%s AND user_id= %s LIMIT 1"
+ def remove_note(self,chat_id,note_name=None):
+ if note_name == '*':
+ sql = (
+ "DELETE FROM notes_base WHERE chat_id=%s"
)
- data1 = (
- status, chat_id, user_id
+ data = (
+ chat_id,
)
- else:
- sql1 = (
- "UPDATE link_base SET last_active=CURRENT_TIMESTAMP() WHERE chat_id=%s AND user_id= %s LIMIT 1"
+
+ else:
+ sql = (
+ "DELETE FROM notes_base WHERE chat_id=%s AND note_name=%s ORDER BY id DESC LIMIT 1"
)
- data1 = (
- chat_id, user_id
+ data = (
+ chat_id,note_name,
)
- else:
- sql1 = (
- "INSERT INTO link_base (chat_id, user_id, status, join_date, last_active) VALUE(%s, %s, %s, CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP())"
- )
- data1 = (
- chat_id, user_id, status
- )
-
- cursor.execute(sql1, data1)
- db.commit()
+ self.cursor.execute(sql, data)
+ self.db.commit()
-def get_link(chat_id, user_id):
- sql = (
- "SELECT * FROM link_base WHERE chat_id=%s AND user_id=%s"
- )
- data = (
- chat_id, user_id,
- )
-
- cursor.execute(sql, data)
+ def add_filter(self,chat_id, word, type=0, response=None, delete=1):
+ sql = (
+ "REPLACE INTO filter_base (chat_id, filter_word, filter_type, response, remove) VALUE(%s, %s, %s, %s, %s)"
+ )
+ data = (
+ chat_id, word, type, response, delete,
+ )
- return cursor.fetchone()
+ self.cursor.execute(sql, data)
+ self.db.commit()
-def add_settings(chat_id, members):
+ def get_filter(self,chat_id):
+ sql = (
+ "SELECT * FROM filter_base WHERE chat_id=%s"
+ )
- sql = (
- "INSERT INTO settings_base (chat_id, members) VALUE(%s, %s) ON DUPLICATE KEY UPDATE members=%s"
- )
- data = (
- chat_id, members,
- members
- )
+ data = (
+ chat_id,
+ )
- # print(data)
+ self.cursor.execute(sql, data)
- cursor.execute(sql, data)
- db.commit()
+ return self.cursor.fetchall()
-def get_settings(chat_id):
- sql = (
- "SELECT * FROM settings_base WHERE chat_id=%s"
- )
+ def remove_filter(self,chat_id,word):
+ if word == '*':
+ sql = (
+ "DELETE FROM filter_base WHERE chat_id=%s"
+ )
+ data = (
+ chat_id,
+ )
+ else:
+ sql = (
+ "DELETE FROM filter_base WHERE chat_id=%s AND filter_word=%s ORDER BY id DESC LIMIT 1"
+ )
+ data = (
+ chat_id, word,
+ )
- data = (
- chat_id,
- )
+ self.cursor.execute(sql, data)
+ self.db.commit()
- cursor.execute(sql, data)
- return cursor.fetchone()
+ def add_welcome(self,chat_id, welcome_text="Hello {first_name}, \nWelcome to {group_name} !"):
+ sql = (
+ "REPLACE INTO welcome_base (chat_id, welcome_text) VALUE(%s, %s)"
+ )
+ data = (
+ chat_id, welcome_text
+ )
-def add_welcome(chat_id, welcome_text="Hello {first_name}, \nWelcome to {group_name} !"):
+ # print(data)
- sql = (
- "REPLACE INTO welcome_base (chat_id, welcome_text) VALUE(%s, %s)"
- )
- data = (
- chat_id, welcome_text
- )
+ self.cursor.execute(sql, data)
+ self.db.commit()
- # print(data)
- cursor.execute(sql, data)
- db.commit()
+ def get_welcome(self,chat_id):
+ sql = (
+ "SELECT * FROM welcome_base WHERE chat_id=%s"
+ )
+ data = (
+ chat_id,
+ )
-def get_welcome(chat_id):
- sql = (
- "SELECT * FROM welcome_base WHERE chat_id=%s"
- )
+ self.cursor.execute(sql, data)
- data = (
- chat_id,
- )
+ return self.cursor.fetchone()
- cursor.execute(sql, data)
+
+except Exception as ex:
+ print(ex)
+ load()
- return cursor.fetchone()
diff --git a/tg_bot/scripts/modules/core/extract.py b/tg_bot/scripts/modules/core/extract.py
new file mode 100644
index 0000000..a09920d
--- /dev/null
+++ b/tg_bot/scripts/modules/core/extract.py
@@ -0,0 +1,82 @@
+import config as config
+import sys
+sys.path.append('./')
+
+import modules.core.database as database
+
+def sudocheck(update, context, objective=1, admin_del=0, udel=1):
+ msg = user_id = None
+
+ if objective == 1:
+ msg = update.message
+ user_id = msg.from_user.id
+ if user_id == config.owner_id:
+ return 777
+ else:
+ msg = update.message.reply_to_message
+ user_id = msg.from_user.id
+
+ chat_id = update.effective_chat.id
+ status = context.bot.get_chat_member(chat_id, user_id)
+
+ if status['status'] == "creator":
+ return 0
+ elif status['status'] == "administrator":
+ if admin_del == 1:
+ msg.delete()
+ return 1
+ else:
+ if udel == 1:
+ msg.delete()
+ return 2
+
+
+def sudo_check_2(msg, user_id=None, chat_id=None,
+ db=None, del_lvl=0, stat_check=0, context=None, status=None):
+ #1-del members
+ #3-del admin
+ #5-del creator
+ #7-del sudo
+ #4-del all
+
+ if stat_check == 1:
+ user_id = msg.from_user.id
+ chat_id = msg.chat.id
+ status = context.bot.get_chat_member(chat_id, user_id)
+
+ elif stat_check == 0:
+ status = db.get_link(chat_id,user_id)[3]
+
+
+ if user_id == config.owner_id:
+ if del_lvl == 4 or del_lvl == 7:
+ msg.delete()
+ return 7
+
+
+ if status['status'] == "creator":
+ if del_lvl == 5 or del_lvl == 4:
+ msg.delete()
+ return 3
+ elif status['status'] == "administrator":
+ if del_lvl == 3 or del_lvl == 2 or del_lvl == 4:
+ msg.delete()
+ return 2
+ else:
+ if del_lvl == 1 or del_lvl == 2 or del_lvl == 4:
+ msg.delete()
+ return 1
+
+
+def admin_sync(update, context,db):
+ chat = update.effective_chat
+ administrators = chat.get_administrators()
+
+ for admin in administrators:
+ status = admin.status
+ user = admin.user
+
+ status = admin.status
+
+ db.add_user(user)
+ db.add_link(chat,user,status,1)
\ No newline at end of file
diff --git a/tg_bot/scripts/modules/core/filter.py b/tg_bot/scripts/modules/core/filter.py
new file mode 100644
index 0000000..91ab988
--- /dev/null
+++ b/tg_bot/scripts/modules/core/filter.py
@@ -0,0 +1,236 @@
+import modules.core.database as database
+#import modules.core.extract as extract
+import modules.core.extract as extract
+
+import time
+
+import threading
+
+import json
+
+
+class filter_switch():
+
+ def __init__(self,update,context) -> None:
+
+ self.update = update
+ self.context = context
+
+ self.msg = None
+ self.user = None
+ self.tag_msg = None
+ self.tag_user = None
+
+ self.msg = update.message
+
+ self.user = user = self.msg['from_user']
+ self.chat = chat = self.msg['chat']
+
+ self.db = database.bot_db()
+
+ try:
+ self.tag_msg = tag_msg = update.message.reply_to_message
+
+ self.tag_user = tag_user = tag_msg['from_user']
+
+ self.db.add_user(user=tag_user)
+ except:
+ pass
+
+ self.db.parse(chat=chat, user=user)
+
+ self.chat_id = self.chat["id"]
+ self.msg_string = self.msg.text
+
+
+ def lock(self):
+ extract.admin_sync(self.update,self.context,db=self.db)
+
+ self.db.add_settings(self.chat_id,lock=1)
+
+ self.msg.reply_text("Chat Locked !")
+
+
+ def unlock(self):
+ extract.admin_sync(self.update,self.context,self.db)
+
+ self.db.add_settings(self.chat_id,lock=0)
+
+ self.msg.reply_text("Chat Unlocked !")
+
+
+ def filter_remove(self,word,tell=0):
+ self.db.remove_filter(self.chat_id,word)
+ if tell==1:
+ if word == '*':
+ self.msg.reply_text("Cleared filter !")
+ else:
+ self.msg.reply_text(word + " removed from filter !")
+
+ def filter_add(self,res):
+ word=None
+ response=None
+ delete=0
+ type=0
+
+
+
+ try:
+ ress = res.split(None, 2)
+ if ress[1] == "reply":
+ type=1
+ elif ress[1] == "replydel":
+ type=1
+ delete=1
+ elif ress[1] == "warn":
+ type=2
+ elif ress[1] == "warndel":
+ type=2
+ delete=1
+ else:
+ return
+
+ word=ress[0]
+ response=ress[2]
+
+ except:
+ if type==2:
+ self.msg.reply_text("Give a response message for warn..")
+ return
+
+ word = res
+ delete=1 #type=0
+
+ chat_id = self.chat_id
+
+ filter_list = self.db.get_filter(chat_id)
+
+ for i in filter_list:
+ if word == i[2]:
+ #database.remove_filter(chat_id,word)
+ self.filter_remove(word)
+ break
+
+ self.db.add_filter(chat_id=chat_id,word=word,type=type,response=response,delete=delete)
+ self.msg.reply_text(word + " added to filter !")
+
+
+ def filter_stat(self,res):
+ if res == "on":
+ self.db.add_settings(self.chat_id,filter=1)
+ self.msg.reply_text("Chat filter active !")
+
+ elif res == "off":
+ self.db.add_settings(self.chat_id,filter=0)
+ self.msg.reply_text("Chat filter deactivated !")
+
+ elif res == "list":
+ fi_li = self.db.get_filter(self.chat_id)
+ self.msg.reply_text(fi_li)
+
+ elif res == "stat":
+ x = 0
+
+ for x,y in enumerate(self.db.get_filter(self.chat_id)):
+ pass
+
+ z = self.db.get_settings(self.chat_id)
+
+ if z[5] != 0:
+ z="active"
+ else:
+ z="Off"
+
+ self.msg.reply_text("Filter currently " + z + " with " + str(x) + " active filters in this chat..")
+
+
+
+ def router(self):
+ res = self.msg_string.split(None,1)
+
+ if res[0] == "/lock":
+ self.lock()
+
+ elif res[0] == "/unlock":
+ self.unlock()
+
+ elif res[0] == "/filter":
+ self.filter_stat(res[1])
+
+ elif res[0] == "/filteradd":
+ self.filter_add(res[1])
+
+ elif res[0] == "/filterdel":
+ self.filter_remove(res[1],1)
+
+
+def filter_router(update,context):
+ threading.Thread(target=filter_switch(update,context).router, args=(), daemon=True).start()
+
+
+def filter(msg, chat, user, tag_user):
+
+ db = database.bot_db()
+
+ chat_id = chat["id"]
+ user_id = user["id"]
+
+ sett = db.get_settings(chat_id)
+ filter_bool = sett[5]
+ note_bool = sett[6]
+ lock_bool = sett[7]
+
+ #msg_string = None
+
+ def filter_del(): #use extractor | sudo check
+ link = db.get_link(chat_id,user_id)[3]
+ if not (link == "administrator" or link == "creator"):
+ msg.delete()
+
+ def filter_filt():
+ msg_string = msg.text
+
+ if note_bool == 1:
+ if msg_string.startswith("#") == True:
+ note_check(msg_string[1:])
+ return
+
+ for x,y in enumerate(db.get_filter(chat_id)):
+ if y[2].casefold() in msg_string.casefold():
+ if y[3] == 0:
+ msg.delete()
+ return
+ elif y[3] == 1:
+ msg.reply_text(y[4])
+ if y[5] == 1:
+ msg.delete()
+ elif y[3] == 2:
+ msg.reply_text("You have been warn striked !\nreason : "+y[4])
+ if y[5] == 1:
+ msg.delete()
+ return
+
+ def note_check(note_name):
+ note = db.get_note_text(chat_id=chat_id, note_name=note_name)
+
+ try:
+ text = str(note[3])
+ msg.reply_text(text, disable_web_page_preview=True)
+ return
+ except:
+ #msg.reply_text("Note not found !")
+ return
+
+ if lock_bool == 1:
+ filter_del()
+ return
+ elif filter_bool == 1:
+ filter_filt()
+ elif note_bool == 1 and filter_bool == 0:
+ msg_string = msg.text
+ if msg_string.startswith("#") == True:
+ note_check(msg_string[1:])
+ return
+
+
+
\ No newline at end of file
diff --git a/tg_bot/scripts/modules/core/note.py b/tg_bot/scripts/modules/core/note.py
new file mode 100644
index 0000000..98a7f6d
--- /dev/null
+++ b/tg_bot/scripts/modules/core/note.py
@@ -0,0 +1,167 @@
+import modules.core.database as database
+
+import threading
+
+import json
+
+
+class notes_switch():
+
+ def __init__(self,update,context) -> None:
+
+ self.update = update
+ self.context = context
+
+ self.msg = None
+ self.user = None
+ self.tag_msg = None
+ self.tag_user = None
+
+ self.msg = update.message
+
+ self.user = user = self.msg['from_user']
+ self.chat = chat = self.msg['chat']
+
+ self.db = database.bot_db()
+
+ try:
+ self.tag_msg = tag_msg = update.message.reply_to_message
+
+ self.tag_user = tag_user = tag_msg['from_user']
+
+ self.db.add_user(user=tag_user)
+ except:
+ pass
+
+ self.db.parse(chat=chat, user=user)
+
+ self.chat_id = self.chat["id"]
+ self.msg_string = self.msg.text
+
+
+ def note_remove(self,note_name,tell=0):
+ self.db.remove_note(self.chat_id,note_name)
+
+ if tell==1:
+ if note_name == '*':
+ self.msg.reply_text("Cleared chat notes !")
+
+ else:
+ self.msg.reply_text("\'" + note_name + "\' note removed !")
+
+
+ def note_add(self,res):
+ note_name=None
+ note_text=None
+ type=0
+
+ try:
+ ress = res.split(None, 2)
+
+ if ress[1] == "text":
+ type=0
+ elif ress[1] == "button":
+ type=1
+ elif ress[1] == "link":
+ type=2
+ elif ress[1] == "poll":
+ type=3
+ elif ress[1] == "tag":
+ type=4
+ elif ress[1] == "pay":
+ type=5
+ else:
+ return
+
+ note_name=ress[0]
+ note_text=ress[2]
+
+ except:
+ if type==0:
+ self.msg.reply_text("Give a text to add..")
+ return
+
+ chat_id = self.chat_id
+
+ note_list = self.db.get_note(chat_id)
+
+ for i in note_list:
+ if note_name == i[2]:
+ self.note_remove(note_name)
+ break
+
+ user_id = self.user["id"]
+
+ self.db.add_note(chat_id=chat_id,note_name=note_name,note_text=note_text,set_by=user_id)
+ self.msg.reply_text("\'" + note_name + "\' added to chat notes !")
+
+
+ def note_stat(self,res):
+ if res == "on":
+ self.db.add_settings(self.chat_id,notes=1) #add notes field to settings table
+ self.msg.reply_text("Chat note active !")
+
+ elif res == "off":
+ self.db.add_settings(self.chat_id,notes=0)
+ self.msg.reply_text("Chat note deactivated !")
+
+ elif res == "list":
+ no_li = self.db.get_note(self.chat_id)
+ self.msg.reply_text(json.dumps(no_li, indent=4, sort_keys=True, default=str))
+
+ elif res == "stat":
+ x = 0
+
+ dn = self.db.get_note(self.chat_id)
+
+ for i in dn:
+ x=x+1
+
+ z = self.db.get_settings(self.chat_id)[6]
+
+ if z == 0:
+ z="in-active"
+ else:
+ z="active"
+
+ self.msg.reply_text("Notes currently " + z + " with " + str(x) + " active notes in this chat..")
+
+
+ def note_disply(self):
+ no_li = self.db.get_note(self.chat_id)
+
+ text = None
+
+ if not no_li:
+ text = "Notes not available in this chat.."
+
+ else:
+ text="Available notes -\n"
+ for i in no_li:
+ text += "\nā¢ " + i[2] + "
"
+ text += "\n\nUse #notename to view the note"
+
+ self.msg.reply_text(text=text, parse_mode="HTML", disable_web_page_preview=True)
+
+
+ def router(self):
+ res = self.msg_string.split(None,1)
+
+ if res[0][:6] == "/notes":
+ try: #find a better method/algorith to do this
+ r = res[1]
+ self.note_stat(r)
+ return
+
+ except:
+ self.note_disply()
+
+ elif res[0] == "/noteadd":
+ self.note_add(res[1])
+
+ elif res[0] == "/notedel":
+ self.note_remove(res[1],1)
+
+
+def note_router(update,context):
+ threading.Thread(target=notes_switch(update,context).router, args=(), daemon=True).start()
\ No newline at end of file
diff --git a/tg_bot/scripts/modules/core/unparse.py b/tg_bot/scripts/modules/core/unparse.py
new file mode 100644
index 0000000..0488ee6
--- /dev/null
+++ b/tg_bot/scripts/modules/core/unparse.py
@@ -0,0 +1,82 @@
+from mysql.connector import connection
+from modules.core import extract
+import time
+import threading
+import itertools
+from multiprocessing.pool import ThreadPool
+
+import modules.core.database as database
+
+chat_lock = []
+chat_lock_bool = 0
+
+class unparse_cls():
+ next_id = 0
+
+ def __init__(self, update, context) -> None:
+
+ #threading.Thread.__init__(self)
+ #threading.Thread.start(self)
+ #print(threading.Thread.getName,threading.current_thread().ident)
+
+ #print(object(),self.id,threading.Thread.getName,threading.current_thread().ident)
+
+ #time.sleep(3)
+
+ self.update = update
+ self.context = context
+
+ self.msg = None
+ self.user = None
+ self.tag_msg = None
+ self.tag_user = None
+
+ self.msg = update.message
+
+ self.user = user = self.msg['from_user']
+ self.chat = chat = self.msg['chat']
+
+
+ try:
+ self.tag_msg = tag_msg = update.message.reply_to_message
+
+ self.tag_user = tag_user = tag_msg['from_user']
+
+ database.add_user(user=tag_user)
+ except:
+ pass
+
+ database.parse(chat=chat, user=user)
+ self.dele()
+ #self.lock_del
+ #del self
+ #del(self)
+
+
+ def dele(self):
+ link = database.get_link(self.chat['id'],self.user['id'])[3]
+ if not (link == "administrator" or link == "creator"):
+ self.msg.delete()
+
+
+
+ def lock_del(self):
+ global chat_lock
+
+ chat_id = self.chat.id
+
+ if chat_id not in chat_lock:
+ return
+
+ user_id = self.user.id
+
+ link = database.get_link(chat_id,user_id)[3]
+
+ if link != "administrator" or link != "creator":
+ self.msg.delete()
+ self.msg.delete()
+
+
+
+def thread_unparse(update, context):
+ threading.Thread(target=unparse_cls(update,context).lock_del, args=(), daemon=True).start()
\ No newline at end of file
diff --git a/tg_bot/scripts/modules/core/welcome.py b/tg_bot/scripts/modules/core/welcome.py
index 4e635aa..767f5c3 100644
--- a/tg_bot/scripts/modules/core/welcome.py
+++ b/tg_bot/scripts/modules/core/welcome.py
@@ -1,8 +1,13 @@
import config as config
-from . import database
+#from . import database
+
+import modules.core.database as database
from . import mute
+
import time
+from mysql import connector
+
from telegram import ParseMode, InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardMarkup, ChatMember
@@ -34,6 +39,8 @@ def cut_str_to_bytes(s, max_bytes):
def gate(update, context):
+ db = database.bot_db()
+
start = time.process_time()
text = None
@@ -54,21 +61,21 @@ def gate(update, context):
for admin in administrators:
user = admin.user
- database.add_user(user=user)
- database.add_link(chat, user=user, status=admin.status)
+ db.add_user(user=user)
+ db.add_link(chat, user=user, status=admin.status)
bot = context.bot.get_chat_member(
chat_id, config.bot_id)
- database.add_link(
+ db.add_link(
chat=chat, user=bot['user'], status=bot['status'])
members = chat.get_members_count()
- database.add_settings(chat_id=chat_id, members=members)
- database.add_chat(chat=chat)
+ db.add_settings(chat_id=chat_id, members=members)
+ db.add_chat(chat=chat)
- database.add_welcome(chat_id=chat_id)
+ db.add_welcome(chat_id=chat_id)
# blacklistcheck
@@ -80,14 +87,14 @@ def gate(update, context):
else:
reply_markup = None
- database.add_user(user=user)
+ db.add_user(user=user)
user_status = context.bot.get_chat_member(chat_id, user_id).status
members = chat.get_member_count() #previously "get_members_count"
- database.add_settings(chat_id=chat_id, members=members)
+ db.add_settings(chat_id=chat_id, members=members)
- wel = database.get_welcome(chat_id=chat_id)
+ wel = db.get_welcome(chat_id=chat_id)
first_name = user['first_name']
@@ -108,7 +115,7 @@ def gate(update, context):
mute.mute(context, chat_id=chat_id, user_id=user_id)
- database.add_link(chat=chat, user=user,
+ db.add_link(chat=chat, user=user,
status="restricted", replace=1)
# print(context.bot.getChat(chat_id))
@@ -130,7 +137,7 @@ def gate(update, context):
", you have been muted... \n\nClick on the human verification button within the next 2min to unmute yourself !" # else, you will be kicked !"
else:
- database.add_link(chat=chat, user=user, status=user_status)
+ db.add_link(chat=chat, user=user, status=user_status)
update.message.reply_text(
text, reply_markup=reply_markup, parse_mode="HTML")
@@ -138,20 +145,22 @@ def gate(update, context):
print("\n", time.process_time() - start, "\n")
-def farewell(update, context, mycursor, mydb):
+def farewell(update, context):
+ db = database.bot_db()
+
msg = update.message
chat = msg['chat']
user = update.effective_message.left_chat_member
- database.add_user(user=user)
+ db.add_user(user=user)
user_status = context.bot.get_chat_member(chat['id'], user['id'])
- database.add_link(chat=chat, user=user,
+ db.add_link(chat=chat, user=user,
status=user_status['status'])
members = chat.get_members_count()
- database.add_settings(chat_id=chat['id'], members=members)
+ db.add_settings(chat_id=chat['id'], members=members)
text = "Bye bye šš¼"
update.effective_message.reply_text(text)
diff --git a/tg_bot/scripts/modules/delete.py b/tg_bot/scripts/modules/delete.py
new file mode 100644
index 0000000..daf22c1
--- /dev/null
+++ b/tg_bot/scripts/modules/delete.py
@@ -0,0 +1,156 @@
+#import modules.extract as extract
+
+from modules.core import extract
+import time
+import modules.core.database as database
+import threading
+
+del_thread_lock = threading.Lock()
+
+class delete():
+
+ def __init__(self,update,context) -> None:
+
+ self.update = update
+ self.context = context
+
+ self.msg = None
+ self.user = None
+ self.tag_msg = None
+ self.tag_user = None
+
+ self.msg = update.message
+
+ self.user = user = self.msg['from_user']
+ self.chat = chat = self.msg['chat']
+
+ bot_db = database.bot_db()
+
+ try:
+ self.tag_msg = tag_msg = update.message.reply_to_message
+
+ self.tag_user = tag_user = tag_msg['from_user']
+
+ bot_db.add_user(user=tag_user)
+ except:
+ pass
+
+ bot_db.parse(chat=chat, user=user)
+
+
+ def delete(self):
+ self.tag_msg.delete()
+
+ msg_frm = self.msg
+
+ del_msg = msg_frm.reply_text("Deleted !")
+
+ time.sleep(1)
+
+ msg_frm.delete()
+ del_msg.delete()
+
+
+ def silent_delete(self):
+ self.tag_msg.delete()
+ self.msg.delete()
+
+
+ def clean(self):
+ del_msg = self.msg.reply_text("Purging started...")
+
+ #del_thread_lock.acquire()
+
+ context = self.context
+
+ del_msg_id = int(del_msg.message_id)
+ msg_id = int(self.tag_msg.message_id)
+ chat_id = self.update.effective_chat.id # try wit self.chat
+
+ t = 1
+
+ while t == 1:
+ if msg_id == del_msg_id:
+ t = 0
+
+ try:
+ context.bot.deleteMessage(chat_id, del_msg_id)
+ except:
+ pass
+
+ del_msg_id = del_msg_id-1
+
+ #del_thread_lock.release()
+
+ cln = context.bot.send_message(chat_id, "Purge Complete !")
+
+ time.sleep(2)
+
+ cln.delete()
+
+
+def tag_del_cls(update,context):
+ threading.Thread(target=delete(update,context).delete, args=(), daemon=True).start()
+
+def s_del_cls(update,context):
+ threading.Thread(target=delete(update,context).silent_delete, args=(), daemon=True).start()
+
+def mul_del_cls(update,context):
+ threading.Thread(target=delete(update,context).clean, args=(), daemon=True).start()
+
+
+
+
+"""
+def admin_load(update):
+ global lock
+
+ chat = update.effective_chat
+ chat_id = str(chat.id)
+ administrators = chat.get_administrators()
+
+ l = {}
+ u_dic = []
+
+ for admin in administrators:
+ user = admin.user
+ u_dic.append(user.id)
+
+ l[chat_id] = u_dic
+"""
+
+chat_lock = []
+
+def lock(update, context):
+ global chat_lock
+
+ extract.admin_sync(update,context)
+ #admin_load(update)
+
+ chat = update.effective_chat
+ chat_id = str(chat.id)
+
+ chat_lock.append(chat_id)
+
+ update.message.reply_text("Chat Locked !")
+
+
+def ldel(update,context):
+ global chat_lock
+
+ chat = update.effective_chat
+ chat_id = str(chat.id)
+
+ if chat_id in chat_lock:
+ pass
+ else:
+ return
+
+ user_id = update.message.from_user.id
+
+ link = database.get_link(chat_id,user_id)[3]
+
+ if link == "administrator" or link == "creator":
+ pass
+ else:
+ update.message.delete()
\ No newline at end of file
diff --git a/tg_bot/windows/bin/Jesvi Bot.cpp b/tg_bot/windows/bin/Jesvi Bot.cpp
index c290399..f3e7681 100644
--- a/tg_bot/windows/bin/Jesvi Bot.cpp
+++ b/tg_bot/windows/bin/Jesvi Bot.cpp
@@ -878,7 +878,7 @@ int menu()
Sleep(250);
printf("\n By Jesvi Jonathan");
Sleep(500);
- exit(10);
+ exit(1);
break;
case 9:
diff --git a/tg_bot/windows/bin/Jesvi Bot.exe b/tg_bot/windows/bin/Jesvi Bot.exe
index b6018c6..27d8968 100644
Binary files a/tg_bot/windows/bin/Jesvi Bot.exe and b/tg_bot/windows/bin/Jesvi Bot.exe differ