コード例 #1
0
def logHandler(update, context):
    herokuHelper = HerokuHelper(Config.HEROKU_APP_NAME, Config.HEROKU_API_KEY)
    log = herokuHelper.getLog()
    if len(log) > Config.TG_CHARACTER_LIMIT:
        file = BytesIO(bytes(log, "utf-8"))
        file.name = "log.txt"
        update.message.reply_document(file)
    else:
        update.message.reply_text(log)
コード例 #2
0
def restartHandler(update, context):
    sudo = Config.SUDO_USERS
    message = update.effective_message
    user_id = message.from_user.id
    if int(user_id) in sudo:
        herokuHelper = HerokuHelper(Config.HEROKU_APP_NAME,
                                    Config.HEROKU_API_KEY)
        herokuHelper.restart()
        update.message.reply_text("Restarted.")
    else:
        message.reply_text(non_admin, parse_mode=ParseMode.HTML)
コード例 #3
0
def logHandler(update,context):
    sudo = list(Config.SUDO_USERS) + list(Config.SUPPORT_USERS) 
    message = update.effective_message
    user_id = message.from_user.id
    if int(user_id) in sudo:
        herokuHelper = HerokuHelper(Config.HEROKU_APP_NAME,Config.HEROKU_API_KEY)
        log = herokuHelper.getLog()
        if len(log) > Config.TG_CHARACTER_LIMIT:
            file = BytesIO(bytes(log,"utf-8"))
            file.name = "log.txt"
            update.message.reply_document(file)
        else:
            update.message.reply_text(log)
    else:
        message.reply_text(non_admin,parse_mode=ParseMode.HTML)
コード例 #4
0
def addAuthUserHandler(update, context):
    message = update.effective_message
    args = message.text.split(" ", 1)
    if message.reply_to_message:
        user_id = message.reply_to_message.from_user.id
    elif len(args) > 1:
        try:
            user_id = int(args[1])
        except:
            message.reply_text("Bad UserId Provided.")
            return
    else:
        message.reply_text("Provide Proper UserId.")
        return
    herokuHelper = HerokuHelper(Config.HEROKU_APP_NAME, Config.HEROKU_API_KEY)
    Config.AUTHORIZED_USERS.append(user_id)
    herokuHelper.addEnvVar("AUTHORIZED_USERS",
                           " ".join(Config.AUTHORIZED_USERS))

    message.reply_text("Authorized User.")
コード例 #5
0
def restartHandler(update,context):
    bot = context.bot
    sudo = Config.SUDO_USERS 
    message = update.effective_message
    user = update.effective_user
    user_id = message.from_user.id
    datetime_fmt = "%Y-%m-%d // %H:%M"
    current_time = datetime.utcnow().strftime(datetime_fmt)
    if int(user_id) in sudo:
        herokuHelper = HerokuHelper(Config.HEROKU_APP_NAME,Config.HEROKU_API_KEY)
        herokuHelper.restart()
        update.message.reply_text("Restarted.")
        if Config.LOGS:
            bot.send_message(Config.LOGS,
                "<b>[Restarted]</b>\n\n"
                f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                f"<b>Event Stamp:</b> <code>{current_time}</code>",
                 parse_mode=ParseMode.HTML
            )
    else:
        message.reply_text(non_admin,parse_mode=ParseMode.HTML)
コード例 #6
0
def restartHandler(update, context):
    herokuHelper = HerokuHelper(Config.HEROKU_APP_NAME, Config.HEROKU_API_KEY)
    herokuHelper.restart()
    update.message.reply_text("Restarted.")