예제 #1
0
 def __init__(self):
     self.l = logger.logs("messageFilter")
     fileIO.checkFolder("config{0}messageFilter{0}".format(os.sep),
                        "messageFilter", self.l)
     fileIO.checkFile(
         "config-example{0}messageFilter{0}config.json".format(os.sep),
         "config{0}messageFilter{0}config.json".format(os.sep),
         "config.json", self.l)
     self.filter = fileIO.loadConf(
         "config{0}messageFilter{0}config.json")["Message Filter"]
     pass
예제 #2
0
 def __init__(self):
     self.l = logger.logs("ledyBotChat")  #creates the logger
     self.l.logger.info("Starting")
     loop = asyncio.get_event_loop()
     loop.create_task(self.ledyCommands())  #creates the add commands task
     self.ledyPipeObj = pipeClient.pipeClient(
         r"\\.\pipe\Demo")  #loads the command pipe client
     self.ledyPipeReaderObj = pipeClient.pipeClient(
         r"\\.\pipe\Demo1")  #loads the reader pipe client
     loop.create_task(self.ledyReader())
     self.l.logger.info("Started")
예제 #3
0
    def __init__(self):
        self.messagepattern = re.compile(r"^:(.{1,50})!")
        self.l = logger.logs("IRC")
        self.l.logger.info("Starting")
        self.serviceStarted = {}
        for sKey, sVal in config.irc["Servers"].items():
            if sVal["Enabled"] == True:
                self.serviceStarted.update({sKey:False})
        self.writer = {}
        self.reader = {}

        self.msgHandlerTasks = {}
예제 #4
0
 def __init__(self):
     self.l = logger.logs("ChatLog")
     self.l.logger.info("Starting")
     config.events.onMessage += self.logMessage
     self.l.logger.info("Started")
     fileIO.checkFolder("config{0}chatLog{0}".format(os.sep), "logRules",
                        self.l)
     fileIO.checkFile(
         "config-example{0}chatLog{0}logRules.json".format(os.sep),
         "config{0}chatLog{0}logRules.json".format(os.sep), "logRules.json",
         self.l)
     self.chatLogRules = fileIO.loadConf("config{0}chatLog{0}logRules.json")
예제 #5
0
    def __init__(self):
        self.l = logger.logs("Console")
        fileIO.checkFolder("config{0}console{0}".format(os.sep), "console",
                           self.l)
        fileIO.checkFile(
            "config-example{0}console{0}console.json".format(os.sep),
            "config{0}console{0}console.json".format(os.sep), "console.json",
            self.l)
        file = fileIO.loadConf("config{0}console{0}console.json")

        self.consoleOutputs = file["Consoles"]

        super().__init__()
예제 #6
0
 def __init__(self):
     self.l = logger.logs("Commands")
     self.l.logger.info("Starting")
     config.events.onMessage += self.commandCheckExist
     config.events.addCommandType = EventHook()
     config.events.addCommandType += self.addCommandTypes
     self.commands = []
     self.commandTypeList = {}
     self.commandsDir = '.{0}config{0}command'.format(os.sep)
     self.checkCommandFolder()
     self.loadCommands()
     loop = asyncio.get_event_loop()
     loop.create_task(self.addBasicCommands())
     self.l.logger.info("Started")
예제 #7
0
    def __init__(self):
        self.l = logger.logs("Chatbot")
        self.l.logger.info("Starting")
        config.events.onMessage += self.sortMessage
        self.l.logger.info("Started")
        fileIO.checkFolder("config{0}chatbot{0}".format(os.sep), "chatbot",
                           self.l)
        fileIO.checkFile(
            "config-example{0}chatbot{0}chatbot.json".format(os.sep),
            "config{0}chatbot{0}chatbot.json".format(os.sep), "chatbot.json",
            self.l)
        self.chatbot = fileIO.loadConf("config{0}chatbot{0}chatbot.json")

        self.legacyConverts()
예제 #8
0
파일: irc.py 프로젝트: popcorn9499/chatBot
    def __init__(self):
        self.messagepattern = re.compile(r"^:(.{1,50})!")
        #variables.config = __main__.variables.config
        self.l = logger.logs("IRC")
        fileIO.checkFolder("config{0}auth{0}".format(os.sep), "auth", self.l)
        fileIO.checkFile("config-example{0}auth{0}irc.json".format(os.sep),
                         "config{0}auth{0}irc.json".format(os.sep), "irc.json",
                         self.l)
        config.c.irc = fileIO.loadConf("config{0}auth{0}irc.json")

        self.l.logger.info("Starting")
        self.serviceStarted = {}
        config.events.onMessageSend += self.sendMSG
        self.writer = {}
        self.reader = {}
        self.emoteObjects = []  #this should be just plain emote objects
        self.msgHandlerTasks = {}
        self.hostNicknames = {}  #{host: nickname}
예제 #9
0
    def __init__(self):
        self.pageToken = ""
        self.youtube = ""
        self.serviceStarted = False
        self.secretsFilePath = "config{0}auth{0}client_secrets.json".format(os.sep)
        self.oauthFilePath = "config{0}auth{0}oauth.json".format(os.sep)
        self.l = logger.logs("Youtube")
        fileIO.checkFolder("config{0}auth{0}".format(os.sep),"auth",self.l)
        fileIO.checkFile("config-example{0}auth{0}youtube.json".format(os.sep),"config{0}auth{0}youtube.json".format(os.sep),"youtube.json",self.l)
        self.enabled = fileIO.loadConf("config{0}auth{0}youtube.json")["Enabled"]
        self.pageToken = fileIO.loadConf("config{0}auth{0}youtube.json")["pageToken"]
        self.oldMessageList = [] #keeps track of old messages to filter out
        self.messageFrequency = 0

        if (self.enabled):
            secretsExist = self.checkFile(self.secretsFilePath,"client_secrets.json",self.l)
            self.msgCheckList = fileIO.loadConf("config{0}auth{0}youtube.json")["selfMsgFilter"]
            if (secretsExist):
                self.l.logger.info("Starting")
                self.initAuth()
                config.events.onMessageSend += self.sendLiveChat
            else:
                self.l.logger.info("Please make sure the oauth and client secret files exist")
예제 #10
0
    def inner(self):
        """ inner catalog """

        while True:

            if self.flag == 'stop':
                logger.logs(self.log, "break task")
                break

            names = glob.glob(self.task.path_in + self.task.maska)
            for file in names:
                if os.path.isfile(file):
                    logger.logs(self.log,
                                "name: " + self.task.name + " file: " + file)
                    run(file, self.task, self.log, 'in')  # to command

            logger.logs(self.log, "finish task")
            time.sleep(int(self.task.period))
예제 #11
0
    async def sendMessage(self, message, objDeliveryDetails,
                          formattingSettings):  #sends the message
        formatType = "MutedOther"
        FormattingOptions = {"%message%": "message"}

        objSendMsg = Object.ObjectLayout.sendMsgDeliveryDetails(
            Message=message,
            DeliveryDetails=objDeliveryDetails,
            FormattingOptions=FormattingOptions,
            formattingSettings=formattingSettings,
            formatType=formatType,
            messageUnchanged=message
        )  #prepares the delivery object and sends the message send event
        config.events.onMessageSend(sndMessage=objSendMsg)


l = logger.logs("Console")
fileIO.checkFolder("config{0}console{0}".format(os.sep), "console", l)
fileIO.checkFile("config-example{0}console{0}console.json".format(os.sep),
                 "config{0}console{0}console.json".format(os.sep),
                 "console.json", l)
file = fileIO.loadConf("config{0}console{0}console.json")

if (not 'Enabled' in file):
    file.update({"Enabled": False})
    fileIO.fileSave("config{0}console{0}console.json".format(os.sep), file)

if file["Enabled"] == True:
    logger.loggerHandlers.add_Logging_Handler(console())
    print("Attaching console")
예제 #12
0
import time
import datetime
from utils import logger
from utils import messageFormatter
from utils import fileIO
import os
import aiohttp
import re

client = discord.Client(
)  #sets this to just client for reasons cuz y not? (didnt have to be done like this honestly could of been just running discord.Client().)
clientID = "IDK"

discordStarted = False

l = logger.logs("Discord")
l.logger.info("Starting")


class Discord:
    def __init__(self):
        fileIO.checkFolder("config{0}auth{0}".format(os.sep), "auth", l)
        fileIO.checkFile("config-example{0}auth{0}discord.json".format(os.sep),
                         "config{0}auth{0}discord.json".format(os.sep),
                         "discord.json", l)
        config.c.discordToken = fileIO.loadConf(
            "config{0}auth{0}discord.json")["Token"]
        config.c.discordEnabled = fileIO.loadConf(
            "config{0}auth{0}discord.json")["Enabled"]
        config.events.onMessageSend += self.discordSendMsg
        config.events.deleteMessage += self.delete_message
예제 #13
0
 def __init__(self):
     self.l = logger.logs("Delete Service")
     self.l.logger.info("Starting")
     config.events.onMessage += self.addMessage
     config.events.onMessage += self.delMessageCmd
     self.msgLibrary = []
예제 #14
0
import os
from utils import logger
import asyncio
from utils import fileIO

l = logger.logs("Messages")

async def formatter(unformatMsg,formattingOptions="default.json",formatType="File"):
    return await _formatter(unformatMsg.Message.Contents, unformatMsg.FormattingOptions,formattingOptions,formatType)
    
async def _formatter(message,formattingOptionsItems,formattingOptions="default.json",formatType="File"):   
    if (formatType == "File"):
        formatting = fileIO.loadConf("config{0}ChatFormatting{0}"+formattingOptions)["Format"]
    elif (formatType == "Other") or (formatType == "MutedOther"):
        formatting = formattingOptions
    if formattingOptions == None:
        return None
    for items in formatting.split(" "): #cycles through all the items and replaces the code name with the contents the message should have
        items = await removeChar("[",items)
        items = await removeChar("]",items)
        items = await removeChar(":",items)
        try:
            if items == "%message%":
                formatting = formatting.replace(items,message)
            elif items == "%roles%":
                role = await findRole(formattingOptionsItems[items])
                formatting = formatting.replace(items,role[0])
            else:
                formatting = formatting.replace(items,formattingOptionsItems[items])
        except KeyError: #prevents format stryings that dont exist from crashing the formatter
            pass
예제 #15
0
def run(file, task, log, direction):
    """ run method interpretator """

    if direction == 'in':
        line = task.command_in
    elif direction == 'out':
        line = task.command_out

    lineList = line.split(';')
    for command in lineList:

        #
        # verba
        #

        if command == 'LOADKEY_1':
            wrapperVerba('LOADKEY_1')
        elif command == 'LOADKEY_2':
            wrapperVerba('LOADKEY_2')
        elif command == 'SIGN_1':
            wrapperVerba('file,NUM_KEY1,SERIA1')  # !!!
        elif command == 'SIGN_2':
            wrapperVerba('')
        elif command == 'DELSIGN':
            wrapperVerba('DELSIGN')
        elif command == 'RESETKEY_1':
            wrapperVerba('RESETKEY_1 NUM_KEY1 + SERIA1')  # !!!
        elif command == 'RESETKEY_2':
            wrapperVerba('RESETKEY_2 NUM_KEY2 + SERIA2')  # !!!
        elif command == 'CRYPT_1(KLIKO)':
            wrapperVerba('CRYPT_1(KLIKO) file NUM_KEY1,SERIA1,kliko')  # !!!
        elif command == 'CRYPT_2(FTS)':
            wrapperVerba('CRYPT_2(FTS) file, NUM_KEY2,SERIA2,fts')  # !!!
        elif command == 'DECRYPT':
            wrapperVerba('DECRYPT fl,NUM_KEY2)')
        elif command == 'DECRYPT1':
            wrapperVerba('DECRYPT1 fl,NUM_KEY1)')

        #
        # os
        #

        elif not command.find('MOVE_IN', 0) == -1:

            shutil.move(file, task.target)
            logger.logs(log, "MOVE_IN: " + file + " " + task.target)

        elif not command.find('MOVE_OUT', 0) == -1:

            shutil.move(file, task.path_out)
            logger.logs(log, "MOVE_OUT: " + file + " " + task.path_out)

        elif not command.find('ARCHIVE_IN', 0) == -1:

            shutil.copy(file, os.path.join(task.archive, 'in'))
            logger.logs(
                log,
                "ARCHIVE_IN: " + file + " " + os.path.join(task.archive, 'in'))

        elif not command.find('ARCHIVE_OUT', 0) == -1:

            shutil.copy(file, os.path.join(task.archive, 'out'))
            logger.logs(
                log, "ARCHIVE_OUT: " + file + " " +
                os.path.join(task.archive, 'out'))

        elif not command.find('SCRIPT', 0) == -1:
            pass

            # ShellExecute(script_name)
예제 #16
0
def main():
    """  main """

    try:

        def stop():
            """ stop """
            for pr in procList:
                pr.flag = 'stop'
                logger.logs(LOG, "stop proc task id:" + str(id(pr.task)))
                print("stop proc task id:" + str(id(pr.task)))

        def out():
            pass

        """
		settings.json parse

		"""
        conf = open('settings.json', 'r')
        param = conf.read()
        js_param = json.loads(param)

        LOG = js_param['log']
        SETT = js_param['settings']

        logger.logs(LOG, "start programm")

        global procList
        """
		tkinter

		"""
        root = Tk()
        menubar = Menu(root)
        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label="Выход", command=stop)
        menubar.add_cascade(label="Файл", menu=filemenu)

        editmenu = Menu(menubar, tearoff=0)
        editmenu.add_separator()
        menubar.add_cascade(label="Отправка", menu=editmenu)

        servicemenu = Menu(menubar, tearoff=0)
        servicemenu.add_command(label="Проверить ключи", command=donothing)
        servicemenu.add_command(label="asrkeyw", command=donothing)
        servicemenu.add_command(label="Остановить обработку", command=stop)
        menubar.add_cascade(label="Сервис", menu=servicemenu)

        helpmenu = Menu(menubar, tearoff=0)
        helpmenu.add_command(label="О программе", command=donothing)
        menubar.add_cascade(label="Справка", menu=helpmenu)

        for element in SETT:

            sheduleTask = task.Task(element['name'], element['path_in'],
                                    element['maska'], element['archive'],
                                    element['target'], element['period'],
                                    element['command_in'],
                                    element['command_out'],
                                    element['path_out'])

            if not os.path.exists(sheduleTask.path_in):
                os.makedirs(sheduleTask.path_in)

            if not os.path.exists(os.path.join(sheduleTask.archive, 'in')):
                os.makedirs(os.path.join(sheduleTask.archive, 'in'))

            if not os.path.exists(os.path.join(sheduleTask.archive, 'out')):
                os.makedirs(os.path.join(sheduleTask.archive, 'out'))

            if not os.path.exists(sheduleTask.target):
                os.makedirs(sheduleTask.target)

            if not os.path.exists(sheduleTask.path_out):
                os.makedirs(sheduleTask.path_out)

            editmenu.add_command(label=sheduleTask.name,
                                 command=donothing)  #add menu
            editmenu.add_separator()

            proc = ProcessObr(sheduleTask, LOG)
            procList.append(proc)

            thread = threading.Thread(target=proc.inner)
            thread.start()

        root.title("Обработка отчетности")
        root.config(menu=menubar)
        root.geometry('1121x443')
        root.resizable(False, False)
        root.mainloop()

    except Exception as e:
        logger.logs(LOG, "error: {0}".format(e))
예제 #17
0
 def stop():
     """ stop """
     for pr in procList:
         pr.flag = 'stop'
         logger.logs(LOG, "stop proc task id:" + str(id(pr.task)))
         print("stop proc task id:" + str(id(pr.task)))
예제 #18
0
 def __init__(self, task, log):
     self.task = task
     self.log = log
     self.flag = 'start'
     print("create proc task id:" + str(id(self.task)))
     logger.logs(self.log, "create proc task id:" + str(id(self.task)))