Esempio n. 1
0
def processFileType(update, context):
    from initFunctions import getStatus, getUserData
    message = update.message
    id = message.from_user.id
    if getStatus(id) > 0:
        document = message.document
        from publicBotHeader import messageLang
        if document.file_size < 20971520:
            from publicBotHeader import downloadFile, telegramSettings
            file_name = document.file_name
            file_ext = fileExtention(file_name)
            path = downloadFile(context.bot, document, file_name)
            if file_ext == "stl":
                from driveFunctions import fileToDrive
                print("STL file from", id)
                if fileToDrive(path, getUserData(id, "folder_id")):
                    context.bot.forward_message(telegramSettings("manager"),
                                                message.chat.id,
                                                message.message_id)
                    message.reply_text(
                        messageLang("to_drive", update).format(file_name))
                    print("File Loaded on GoogleDrive")
                else:
                    message.reply_text(messageLang("stl_failed"))
                    print("ERROR: impossible to upload STL file")
            elif file_ext == "gcode":
                from driveFunctions import fileToSpreadsheets
                print("GCode file from", id)
                done = fileToSpreadsheets(update, path)
                if not done:
                    message.reply_text(messageLang("unknown_flavor", update))
                    context.bot.forward_message(telegramSettings("master"),
                                                message.chat.id,
                                                message.message_id)
                    print("Unknown flavor")
                else:
                    message.reply_text(
                        messageLang("to_spreadsheets",
                                    update).format(file_name))
                    context.bot.forward_message(telegramSettings("manager"),
                                                message.chat.id,
                                                message.message_id)
                    print("Sheet filled with print data")
            elif file_ext == "curaprofile" and id == telegramSettings(
                    "manager"):
                from driveFunctions import fileToDrive
                print("Curaprofile file")
                if fileToDrive(path, getDriveInfo("profiles")):
                    message.reply_text(messageLang("profile_loaded"))
                    print("Profile loaded")
                else:
                    message.reply_text(messageLang("profile_failed"))
                    print("ERROR: impossible to upload Curaprofile")
        else:
            message.reply_text(messageLang("too_big", update))
    pass
Esempio n. 2
0
def getip(update, context):
    from publicBotHeader import telegramSettings
    if update.message.from_user.id == telegramSettings("master"):
        import os
        command = os.popen("curl -s ipinfo.io/ip").read()
        update.message.reply_text(command)
        return True
    pass
Esempio n. 3
0
def cd(update, context):
    from publicBotHeader import telegramSettings
    if update.message.from_user.id == telegramSettings("master"):
        import os
        dir = update.message.text[4:]
        os.chdir(dir)
        return True
    pass
Esempio n. 4
0
def sudo(update, context):
    from publicBotHeader import telegramSettings
    if update.message.from_user.id == telegramSettings("master"):
        from var import systemOS
        if systemOS == "linux":
            command = update.message.text[1:]
        else:
            command = update.message.text[6:]
        import os
        update.message.reply_text(os.popen(command).read())
        return True
    else:
        context.bot.send_message(telegramSettings("master"), "Illegal access:")
        context.bot.forward_message(telegramSettings("master"),
                                    update.message.chat.id,
                                    update.message.message_id)
        return False
    pass
Esempio n. 5
0
def start(update, context):
    user = update.message.from_user
    id = user.id
    first_name = user.first_name
    last_name = user.last_name
    username = user.username
    language_code = user.language_code
    from publicBotHeader import addUser, messageLang, telegramSettings
    # if not
    addUser(id, first_name, last_name, username, language_code)
    #    message = update.message
    #    context.bot.forward_message(
    #        telegramSettings("master"),
    #        message.chat.id,
    #        message.message_id
    #    )
    update.message.reply_text(
        messageLang("start",
                    update).format(first_name,
                                   telegramSettings("master_username")))
    pass