Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import wraps
- from utils import controller
- import MySQLdb
- import config
- import time
- LIST_OF_ADMINS = [605363037,53451006,77582926,442991919,63346884,339380551,91141817]
- def restricted(func):
- @wraps(func)
- def wrapped(update, context):
- user_id = update.effective_user.id
- if user_id not in LIST_OF_ADMINS:
- print("Unauthorized access denied for {}.".format(user_id))
- return
- return func(update, context)
- return wrapped
- #CANCELLA COMANDI
- def cancellacomandi(func):
- @wraps(func)
- def wrapped(update, context):
- bot = context.bot
- if update.message.text is not None:
- if update.message.text.startswith("/"):
- bot.delete_message(update.message.chat_id, update.message.message_id)
- return func(update, context)
- return wrapped
- #OWNERBOT
- OWNER_LIST= [605363037]
- def ownerbot(func):
- @wraps(func)
- def wrapped(update, context):
- if update.effective_user is not None:
- user_id = update.effective_user.id
- if user_id not in OWNER_LIST:
- print("Unauthorized access denied for {}.".format(user_id))
- return
- else:
- return False
- return func(update, context)
- return wrapped
- #COMANDI PRIVATI
- def private(fn):
- def wrapper(*args,**kwargs):
- message = args[0].message
- if message.chat.type == 'private':
- return fn(*args,**kwargs)
- else:
- return False
- return wrapper
- #SALVATAGGIO UTENTI
- def register_user(func):
- @wraps(func)
- def wrapped(update, context):
- usersid = str(update.effective_user.id)
- db=MySQLdb.connect(
- config.database['server'],
- config.database['user'],
- config.database['password'],
- config.database['name'])
- db.autocommit(True)
- db.set_character_set('utf8mb4')
- cur=db.cursor()
- query = 'INSERT INTO utenti (user_id) VALUES (%s)'
- cur.execute(query, [usersid])
- cur.close()
- db.close()
- return func(update, context)
- return wrapped
- #SALVATAGGIO UTENTI GIVEWAY
- def register_giveway(func):
- @wraps(func)
- def wrapped(update, context):
- usersid = str(update.effective_user.username)
- db=MySQLdb.connect(
- config.database['server'],
- config.database['user'],
- config.database['password'],
- config.database['name'])
- db.autocommit(True)
- db.set_character_set('utf8mb4')
- cur=db.cursor()
- query = 'INSERT IGNORE INTO giveaway (user_id) VALUES (%s)'
- cur.execute(query,[usersid])
- cur.close()
- db.close()
- return func(update, context)
- return wrapped
- #DELETE A TEMPO
- def delete(func):
- @wraps(func)
- def wrapped(update, context, delay=10):
- try:
- bot = context.bot
- try:
- message_id = update.message.message_id
- chat_id = update.chat_id
- except AttributeError as e:
- message_id = update.message.message_id
- chat_id = update.message.chat_id
- if delay > 10:
- time.sleep(delay)
- return bot.delete_message(chat_id,message_id)
- except Exception as e:
- print(e)
- return func(update, context)
- return wrapped
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement