示例#1
0
def handler(message, user_id):
    global pid
    message = message.split(" ")
    if message[0] == 'break' and pid != 0:
        sub.Popen(("kill", str(pid)))
        return
    if message[0] == 'send':
        try:
            Respond.send_document(user_id, message[1])
        except Exception:
            Respond.send_text_respond('File not found', user_id)
    else:

        p1 = threading.Thread(target=process_worker, args=[message, user_id])
        p1.start()
def handler(message, user_id):
    global pid
    message = message.split(" ")
    if message[0] == "break" and pid != 0:
        sub.Popen(("kill", str(pid)))
        return
    if message[0] == "send":
        try:
            Respond.send_document(user_id, message[1])
        except Exception:
            Respond.send_text_respond("File not found", user_id)
    else:

        p1 = threading.Thread(target=process_worker, args=[message, user_id])
        p1.start()
def process_worker(message, user_id):
    global pid, path
    try:

        process = sub.Popen(message, stdout=sub.PIPE, stdin=sub.PIPE, stderr=sub.PIPE)
        pid = process.pid
        for row in process.stdout:

            Respond.send_text_respond(row, user_id)
        for row in process.stderr:
            Respond.send_text_respond(row, user_id)
    except Exception:
        Respond.send_text_respond("Не правильная комманда", user_id)
示例#4
0
def process_worker(message, user_id):
    global pid, path
    try:

        process = sub.Popen(message,
                            stdout=sub.PIPE,
                            stdin=sub.PIPE,
                            stderr=sub.PIPE)
        pid = process.pid
        for row in process.stdout:

            Respond.send_text_respond(row, user_id)
        for row in process.stderr:
            Respond.send_text_respond(row, user_id)
    except Exception:
        Respond.send_text_respond("Не правильная комманда", user_id)
示例#5
0
def handler(message, user_id):
    check_file()
    if (message == 'print'):
        f1 = open('notes.txt', 'r')
        for row in f1:
            Respond.send_text_respond(row, user_id)
        return
    if (message == 'delete'):
        os.remove('notes.txt')
        Respond.send_text_respond('Note removed', user_id)
        return
    f1 = open('notes.txt', 'a')
    f1.write(message)
    f1.write('\n END OF NOTE \n')

    Respond.send_text_respond('Note saved :)', user_id)
def handler (message, user_id):
    Respond.send_text_respond("Hi I am first module!Be free to change me - /ssh - controls "
                              "/downloader - download  files. Both modules can send your files usage - send filename", user_id )
示例#7
0
def handler(message, user_id):
    Respond.send_text_respond(
        "Hi I am first module!Be free to change me - /ssh - controls "
        "/downloader - download  files. Both modules can send your files usage - send filename",
        user_id)
def handler(message, user_id):  # функция которая принимает сообщение от главного модуля(Должна быть реализована обязательно)

    Respond.send_text_respond(message, user_id)  # отправляем обратно
def handler(message, user_id):

    message = message.split(" ")

    if message[0] == 'send':
        try:
            Respond.send_document(user_id, os.path.dirname(sys.argv[0]) + '/Downloads/' + " ".join(message[1:]))
            Respond.send_document(user_id, 'Downloads/' + " ".join(message[1:]))
            return
        except Exception:
            Respond.send_text_respond('File not found', user_id)
            return

    if message[0] == 'ls':
        lists = sub.Popen(('ls', os.path.dirname(sys.argv[0]) + '/Downloads/'), stdout=sub.PIPE, stdin=sub.PIPE, stderr=sub.PIPE)
        lists = sub.Popen(('ls', 'Downloads/'), stdout=sub.PIPE, stdin=sub.PIPE, stderr=sub.PIPE)
        for row in lists.stdout:
            Respond.send_text_respond(row, user_id)
        return

    try:
        path = message[0]
        name_of_file = os.path.dirname(sys.argv[0]) + '/Downloads/' + message[1]

        urllib.urlretrieve (path, name_of_file)

        Respond.send_text_respond("Downloaded", user_id)
    except Exception:
        Respond.send_text_respond("Usage - url filename")
def handler(message, user_id):

    message = message.split(" ")

    if message[0] == 'send':
        try:
            Respond.send_document(
                user_id,
                os.path.dirname(sys.argv[0]) + '/Downloads/' +
                " ".join(message[1:]))
            Respond.send_document(user_id,
                                  'Downloads/' + " ".join(message[1:]))
            return
        except Exception:
            Respond.send_text_respond('File not found', user_id)
            return

    if message[0] == 'ls':
        lists = sub.Popen(('ls', os.path.dirname(sys.argv[0]) + '/Downloads/'),
                          stdout=sub.PIPE,
                          stdin=sub.PIPE,
                          stderr=sub.PIPE)
        lists = sub.Popen(('ls', 'Downloads/'),
                          stdout=sub.PIPE,
                          stdin=sub.PIPE,
                          stderr=sub.PIPE)
        for row in lists.stdout:
            Respond.send_text_respond(row, user_id)
        return

    try:
        path = message[0]
        name_of_file = os.path.dirname(
            sys.argv[0]) + '/Downloads/' + message[1]

        urllib.urlretrieve(path, name_of_file)

        Respond.send_text_respond("Downloaded", user_id)
    except Exception:
        Respond.send_text_respond("Usage - url filename")