예제 #1
0
 def listen(self):
     p = re.compile(r"^:(?P<USER>\w+)!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :")
     while True:
         self.channel.s.setblocking(0)
         ready = select.select([self.channel.s], [], [], 0.2)
         if ready[0]:
             response_raw = self.channel.s.recv(4096).decode("utf-8")
             responses = response_raw.replace("\r","").split("\n")
             for response in responses:
                 response = response.rstrip()
                 if (response != ""):
                     if (response == "PING :tmi.twitch.tv"):
                         print(response)
                         self.channel.s.send("PONG :tmi.twitch.tv\r\n".encode("utf-8"))
                         print("PONG sent")
                     elif ("PRIVMSG" in response):
                         user_name = p.search(response).group('USER')
                         user = User(user_name)
                         message = p.sub("", response).rstrip()
                         t = time.strftime("%H:%M:%S")
                         #print("[" + t + "] " + user.name + ": " + message)
                         if message.startswith("!"):
                             print("[" + t + "] " + user.name + ": " + message)
                         commands.do(message, user)
                     else:
                         print(response)
         commands.cycle()
         self.channel.do_queue()
         time.sleep(0.1)
예제 #2
0
def exec_command(command):
    try:
        action, *args = command
        args = context.apply(args)
        commands.do(action, args)
    except commands.CommandNotFoundError:
        print(f"\"{action}\" command not found.")
    except TypeError:
        print(f"Wrong arguments for \"{action}\" command.")
        traceback.print_exc()
예제 #3
0
파일: chatbot.py 프로젝트: Radmirkus/MelBo
def chatting():
    logging.info("Получение сообщения...")
    userMsg = get_input_message()
    if userMsg:
        pass
    else:
        return

    logging.info("Сообщение получено: " + userMsg)
    if userMsg.strip().find('/') == 0:
        commands.do(userMsg.strip())
        return
    msg_result = send_output_message(
        botmemory.prefix +
        getResponse(userMsg))  # Результат отправления сообщения
    logging.info("Ответ отправлен") if len(msg_result) == 0 else logging.info(
        "Ответ не отправлен - " + msg_result)
    print(msg_result)  # если сообщение не отправлено, выводит причину
예제 #4
0
 def setBossVersion(self, s="7.0.3"):
     self._bossVersion = s
     CMTPATH = do('echo $CMTPATH')
     if len(CMTPATH.split()) == 0:
         print("warning: please set the BOSS first!!!")
     if "7.0.3" in CMTPATH:
         print("The current BOSS version is 7.0.3")
     if "6.6.4" in CMTPATH:
         print("The current BOSS version is 6.6.4")
     if not s in CMTPATH:
         print("warning: what the BOSS version you set is: ", s, "!!!")
예제 #5
0
    if '.bosslog'==os.path.splitext(i)[1]:
        logCol.append(i)
    if '.txt'==os.path.splitext(i)[1]:
        jobCol.append(i)

IDList = []

for i in jobCol:
    if "jobid" in i:
        continue
    if not i + ".bosslog" in logCol:
        job = os.path.split(i)[1]
        pth = os.path.split(i)[0]
        #print "jobs ", job
        #print "path", pth
        sublog= do("cd "+pth+'&& boss.condor '+job)
        IDList.append(sublog.split()[-1]+'\n')
errorList=[]
for i in logList:
    f=open(i,'r')
    lines =f.readlines()
    AMFS = False
    for l in lines[-5:]:
        if 'Finalized successfully' in l:
            AMFS = True
            break
    f.close()
    if not AMFS:
        errorList.append(i[:-8])

from SubJob import hep