Beispiel #1
0
def rsudo(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    user_id = extract_user(message, args)
    
    if not user_id:
        message.reply_text("Refer the user first.")
        return ""

    if int(user_id) == OWNER_ID:
        message.reply_text("The specified user is my owner! I won't remove him from SUDO_USERS list!")
        return ""
    
    if user_id not in SUDO_USERS:
        message.reply_text("{} is not a sudo user".format(user_id))
        return ""

    users = [line.rstrip('\n') for line in open("sudo_users.txt")]

    with open("sudo_users.txt","w") as file:
        for user in users:
            if not int(user) == user_id:
                file.write(str(user) + "\n")

    SUDO_USERS.remove(user_id)
    message.reply_text("Yep Succefully removed from SUDO List!")
    
    return ""
Beispiel #2
0
def sudopromote(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    banner = update.effective_user
    user_id = extract_user(message, args)

    if not user_id:
        message.reply_text("Refer a user first....")
        return ""

    if int(user_id) == OWNER_ID:
        message.reply_text(
            "The specified user is my owner! No need add him to SUDO_USERS list!"
        )
        return ""

    if int(user_id) in SUDO_USERS:
        message.reply_text("Buddy this user is already a sudo user.")
        return ""

    with open("sudo_users.txt", "a") as file:
        file.write(str(user_id) + "\n")

    SUDO_USERS.append(user_id)
    message.reply_text("Succefully Added To SUDO List!")

    return ""
Beispiel #3
0
def add_to_sudo(user_id, bot):
    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return
    sql.gpromote_user(user_id, user_chat.username or user_chat.first_name)
    SUDO_USERS.append(user_id)
Beispiel #4
0
def ungpromote(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    user_id = extract_user(message, args)
    user_chat = bot.get_chat(user_id)
    if not user_id:
        message.reply_text("No user refered")
        return
    if user_chat.type != 'private':
        message.reply_text("That's not a user!")
        return
    if user_id not in SUDO_USERS:
        message.reply_text("{} is not a sudo user".format(user_chat.username))
        return
    sql.ungpromote_user(user_id)
    SUDO_USERS.remove(user_id)
    message.reply_text("Succefully removed from SUDO user list!")
Beispiel #5
0
import html
from typing import Optional, List
from telegram import Message, Chat, Update, Bot, User
from telegram import ParseMode
from telegram.error import BadRequest
from telegram.ext import CommandHandler, Filters
from telegram.ext.dispatcher import run_async
from telegram.utils.helpers import escape_markdown, mention_html
from haruka.modules.helper_funcs.filters import CustomFilters
from haruka.modules.helper_funcs.extraction import extract_user
from haruka import dispatcher, SUDO_USERS, OWNER_USERNAME, OWNER_ID
import haruka.modules.sql.gpromote_sql as sql

sudo_list = sql.get_sudo_list()
for i in sudo_list:
    SUDO_USERS.append(i)


def add_to_sudo(user_id, bot):
    try:
        user_chat = bot.get_chat(user_id)
    except BadRequest as excp:
        message.reply_text(excp.message)
        return
    sql.gpromote_user(user_id, user_chat.username or user_chat.first_name)
    SUDO_USERS.append(user_id)


@run_async
def gpromote(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
Beispiel #6
0
 - /sudodemote: demotes the user from SUDO USER
"""

__mod_name__ = "Sudo"

SUDOPROMOTE_HANDLER = CommandHandler("sudopromote", sudopromote, pass_args=True, filters=Filters.user(OWNER_ID))
SUDODEMOTE_HANDLER = CommandHandler("sudodemote", sudodemote, pass_args=True, filters=Filters.user(OWNER_ID))

dispatcher.add_handler(SUDOPROMOTE_HANDLER)
dispatcher.add_handler(SUDODEMOTE_HANDLER)
 won't remove him from SUDO_USERS list!")
        return ""
    
    if user_id not in SUDO_USERS:
        message.reply_text("{} is not a sudo user".format(user_id))
        return ""

    users = [line.rstrip('\n') for line in open("sudo_users.txt")]

    with open("sudo_users.txt","w") as file:
        for user in users:
            if not int(user) == user_id:
                file.write(str(user) + "\n")

    SUDO_USERS.remove(user_id)
    message.reply_text("Yep Successfully removed from SUDO List!")
    
    return ""


__help__