示例#1
0
 def getCommentData(self) -> None:
     foundVideo : Video = self.currentVideo
     commentCount : int = 0
     for comment in (foundVideo.comments):
         currentData : dict() = comment.data
         emoticonInfo : dict() = dict()
         emotes : bool = False
         Logger.print_info('Extracted ' + str(commentCount) + ' messages...', end='\r')
         for emoteIndex in range(len(currentData.get("message", None).get("emoticons", []))):
             emotes = True
             id = (currentData.get("message", None).get("emoticons", [])[emoteIndex]['_id'])
             emoticonInfo[id] = self.commentData.cached(id)
             if(not emoticonInfo[id]):
                 start = currentData.get("message", None).get("emoticons", [])[emoteIndex]['begin']
                 end = currentData.get("message", None).get("emoticons", [])[emoteIndex]['end']
                 emoticonInfo[id] = currentData.get("message", None).get("body", None)[start:end+1]
         if(emotes):
             self.commentData.add(
                 Message(
                 currentData['commenter']['name'], 
                 currentData['created_at'], 
                 currentData['message']['body'],
                 emoticonInfo
                 )
             )
         commentCount+=1
     Logger.exit_line()
     Logger.print_pass("Completed...")
     return
示例#2
0
 def run(self):
   while self.client.alive:
     try:
       content = input()
       message = Message(self.sender, content)
       self.client.pipeline.push(message)
     except KeyboardInterrupt:
       self.client.kill()
       return
示例#3
0
    def on_message(self, data):
        message = Message(sender=self.name, data=json.loads(data))

        #将消息发送给每个在群组里的人
        for key in self.application.groupChats[self.topic].people.keys():
            if key != self.id:
                self.application.groupChats[self.topic].people[key](
                    message.response())

        #将消息存入消息记录
        if len(self.application.groupChats[
                self.topic].records) > GROUP_CHAT_RECORD_SIZE:
            self.application.groupChats[self.topic].records.pop()
        self.application.groupChats[self.topic].records.insert(
            0, message.response())
示例#4
0
 def searchExternalEmote(self, emoteName : str) -> None:
     foundVideo : Video = self.currentVideo
     commentCount : int = 0
     for comment in (foundVideo.comments):
         currentData : dict() = comment.data
         if(StringUtil.stringSearch(currentData['message']['body'], emoteName, __defaultBase__)):
             self.commentData.addExternal(
                 Message(
                     currentData['commenter']['name'], 
                     currentData['created_at'], 
                     currentData['message']['body'],
                     {"Ext": emoteName}
                 )
             )
         Logger.print_info('Seeked ' + str(commentCount) + ' messages...', end='\r')
         commentCount+=1
     Logger.exit_line()
     Logger.print_pass("Completed...")
     return