コード例 #1
0
class ApplicationLogic(object):
    def __init__(self):
        self.factory = CommandFactory()

    def command_execute_func(self):
        while True:
            line = input('==> ')
            self.factory.get_command(line).execute()

    def run_app(self):
        print('Вас приветсвует вирутальный помощник\n')
        self.command_execute_func()
コード例 #2
0
ファイル: bt.py プロジェクト: zikasak/ReadOnlyBot
def proceed_message(update, context):
    bot = context.bot
    if not proceed_non_text_message(update, context):
        return

    cmd, txt = Command.parse_command(update.message.text)
    logger.info(f"chat_id: {update.message.chat_id} user_id: {update.message.from_user.id} cmd: {cmd}")
    if cmd == "":
        delete_blocked_phrases(update, context)
        return
    command_to_exec = CommandFactory.get_command_handler(cmd, dataWorker)
    if command_to_exec.is_admin_rights_needed and not is_user_admin(bot, update):
        if can_delete_messages(bot, update):
            API.delete_message(bot,
                               chat_id=update.message.chat_id,
                               message_id=update.message.message_id)
    else:
        command_to_exec.execute(bot, update, txt)
コード例 #3
0
ファイル: main.py プロジェクト: ukolovka/RA_Pyhton
import argparse

from Commands.CommandFactory import AbstractCommand
from Commands.CommandFactory import CommandFactory

if __name__ == '__main__':
    factory = CommandFactory()

    parser = argparse.ArgumentParser(
        description='Console app with sub-commands.')

    subparsers = parser.add_subparsers(title='commands', dest='command')

    for command in factory.commands:
        command_parser = subparsers.add_parser(command.name, help=command.help)

        for argument in command.arguments:
            command_parser.add_argument(argument)

    options = vars(parser.parse_args())

    command: AbstractCommand = factory.get_command(options['command'])
    command.execute(options)
コード例 #4
0
ファイル: main.py プロジェクト: ukolovka/RA_Pyhton
from Commands.AbstractCommand import AbstractCommand
from Commands.CommandFactory import CommandFactory

if __name__ == '__main__':
    factory = CommandFactory()

    while True:
        line = input('==> ')
        command: AbstractCommand = factory.get_command(line)
        command.execute()
コード例 #5
0
ファイル: main.py プロジェクト: medvesekg/laradock-cli
from Parsers.ConfigParser import ConfigParser
from Parsers.ArgParser import ArgParser
from Commands.CommandFactory import CommandFactory

config = ConfigParser("config.txt")
args = ArgParser().parse_args()

command = CommandFactory.create(args, config)
command.execute()
"""
import os
import sys
import shutil
from Site import Site
from Hosts import Hosts
from Folder import Folder

projects_path = "C:\\Koda\\laravel"
nginx_path = "C:\\Koda\\laravel\\laradock\\nginx\\sites"
hosts_path = "C:\\Windows\\System32\\drivers\\etc\\hosts"
name = "newsite"

if(len(sys.argv) == 1):
    os.chdir("c:\\Koda\\laravel\\laradock")
    os.system("docker-compose up -d nginx workspace mysql redis phpmyadmin")
    exit()
if(len(sys.argv) == 2):
    os.chdir("c:\\Koda\\laravel\\laradock")
    os.system("docker-compose down")
    exit()
コード例 #6
0
 def __init__(self):
     self.factory = CommandFactory()
コード例 #7
0
# bot.py
import cfg
import re
import time
from connection import Connection
from Commands.CommandFactory import CommandFactory
from Commands.abstract.MessageCommand import MessageCommand


con = Connection(cfg.HOST, cfg.PORT,cfg.PASS,cfg.NICK,cfg.CHAN)
s = con.connect()

CHAT_MSG=re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :")

while True:
    response = s.recv(1024).decode("utf-8")
    print(response)
    if response == "PING :tmi.twitch.tv\r\n":
        s.send("PONG :tmi.twitch.tv\r\n".encode("utf-8"))
    else:
        username = re.search(r"\w+", response).group(0) # return the entire match
        message = CHAT_MSG.sub("", response).rstrip()
        command = CommandFactory.create(message,username)

        if(command and isinstance(command, MessageCommand)):
            con.chat(command.getMessage(username))

    time.sleep(1 / cfg.RATE)