當前位置: 首頁>>代碼示例>>Python>>正文


Python message.Message方法代碼示例

本文整理匯總了Python中message.Message方法的典型用法代碼示例。如果您正苦於以下問題:Python message.Message方法的具體用法?Python message.Message怎麽用?Python message.Message使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在message的用法示例。


在下文中一共展示了message.Message方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: parse

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def parse(self):
        list_of_messages = []
        set_of_senders = set()
        for l in self.raw_messages:
            content = l["message"].encode("utf-8")
            sender = l["from"].encode("utf-8")
            datetime_str = l["datetime"].encode("utf-8")
            date, time = datetime_str.split("T")
            time = time.replace("+0000", "")
            msg_date = date + " " + time
            datetime_obj = datetime.strptime(msg_date, "%Y-%m-%d %H:%M:%S")

            set_of_senders.add(sender)
            list_of_messages.append(message.Message(sender, content, date, time, datetime_obj))

        return list(set_of_senders), list_of_messages 
開發者ID:nmoya,項目名稱:whatsapp-parser,代碼行數:18,代碼來源:facebook.py

示例2: _get_pose

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def _get_pose(self):
        msg = Message()
        msg.id = CommunicationProtocolIDs.GET_POSE
        response = self._send_command(msg)
        self.x = struct.unpack_from('f', response.params, 0)[0]
        self.y = struct.unpack_from('f', response.params, 4)[0]
        self.z = struct.unpack_from('f', response.params, 8)[0]
        self.r = struct.unpack_from('f', response.params, 12)[0]
        self.j1 = struct.unpack_from('f', response.params, 16)[0]
        self.j2 = struct.unpack_from('f', response.params, 20)[0]
        self.j3 = struct.unpack_from('f', response.params, 24)[0]
        self.j4 = struct.unpack_from('f', response.params, 28)[0]

        if self.verbose:
            print("pydobot: x:%03.1f \
                            y:%03.1f \
                            z:%03.1f \
                            r:%03.1f \
                            j1:%03.1f \
                            j2:%03.1f \
                            j3:%03.1f \
                            j4:%03.1f" %
                  (self.x, self.y, self.z, self.r, self.j1, self.j2, self.j3, self.j4))
        return response 
開發者ID:luismesas,項目名稱:pydobot,代碼行數:26,代碼來源:dobot.py

示例3: update_share

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def update_share(self, team_id, user_id):
        """
        Update onboarding welcome message after recieving a "message" event
        with an "is_share" attachment from Slack. Update timestamp for
        welcome message.

        Parameters
        ----------
        team_id : str
            id of the Slack team associated with the incoming event
        user_id : str
            id of the Slack user associated with the incoming event

        """
        # These updated attachments use markdown and emoji to mark the
        # onboarding task as complete
        completed_attachments = {"text": ":white_check_mark: "
                                         "~*Share this Message*~ "
                                         ":mailbox_with_mail:",
                                 "color": "#439FE0"}
        # Grab the message object we want to update by team id and user id
        message_obj = self.messages[team_id].get(user_id)
        # Update the message's attachments by switching in incomplete
        # attachment with the completed one above.
        message_obj.share_attachment.update(completed_attachments)
        # Update the message in Slack
        post_message = self.client.api_call("chat.update",
                                            channel=message_obj.channel,
                                            ts=message_obj.timestamp,
                                            text=message_obj.text,
                                            attachments=message_obj.attachments
                                            )
        # Update the timestamp saved on the message object
        message_obj.timestamp = post_message["ts"] 
開發者ID:slackapi,項目名稱:Slack-Python-Onboarding-Tutorial,代碼行數:36,代碼來源:bot.py

示例4: route

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def route(self, msg: Message) -> None:
        return await self.router.route(msg) 
開發者ID:hyperledger-archives,項目名稱:indy-agent,代碼行數:4,代碼來源:protocol_discovery.py

示例5: send_query

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def send_query(self, msg: Message) -> None:
        query_msg = Message({
            '@type': ProtocolDiscovery.QUERY,
            'query': msg['query']
        })

        await self.agent.send_message_to_agent(msg['did'], query_msg)

        await self.agent.send_admin_message(
            Message({
                '@type': AdminProtocolDiscovery.QUERY_SENT,
                'from': msg['did']
            })
        ) 
開發者ID:hyperledger-archives,項目名稱:indy-agent,代碼行數:16,代碼來源:protocol_discovery.py

示例6: query_received

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def query_received(self, msg: Message) -> None:
        await self.agent.send_admin_message(
            Message({
                '@type': AdminProtocolDiscovery.QUERY_RECEIVED,
                'from': msg.context['from_did']
            })
        )

        matching_modules = []
        def map_query(char):
            if char == '*':
                return '.*'
            return char

        query = ''.join(list(map(map_query, msg['query'])))
        for module in self.agent.modules.keys():
            matches = re.match(query, module)
            if matches:
                matching_modules.append(module)

        disclose_msg = Message({
            '@type': ProtocolDiscovery.DISCLOSE,
            '~thread': {'thid': msg.id},
            'protocols': list(map(lambda mod: {'pid': mod}, matching_modules)),
        })

        await self.agent.send_message_to_agent(msg.context['from_did'], disclose_msg)

        await self.agent.send_admin_message(
            Message({
                '@type': AdminProtocolDiscovery.DISCLOSE_SENT,
                'from': msg.context['from_did']
            })
        ) 
開發者ID:hyperledger-archives,項目名稱:indy-agent,代碼行數:36,代碼來源:protocol_discovery.py

示例7: disclose_received

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def disclose_received(self, msg: Message) -> None:
        await self.agent.send_admin_message(
            Message({
                '@type': AdminProtocolDiscovery.DISCLOSE_RECEIVED,
                'from': msg.context['from_did'],
                'protocols': msg['protocols']
            })
        ) 
開發者ID:hyperledger-archives,項目名稱:indy-agent,代碼行數:10,代碼來源:protocol_discovery.py

示例8: validate

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def validate(query):
            validate_message(
                [
                    ('@type', ProtocolDiscovery.Message.QUERY),
                    '@id',
                    'query'
                ],
                query
            ) 
開發者ID:hyperledger-archives,項目名稱:indy-agent,代碼行數:11,代碼來源:__init__.py

示例9: build

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def build(thid: str, supported_families: [str]):
            return Message({
                '@type': ProtocolDiscovery.Message.DISCLOSE,
                '~thread': {'thid': thid},
                'protocols': list(map(lambda mod: {'pid': mod}, supported_families))
            }) 
開發者ID:hyperledger-archives,項目名稱:indy-agent,代碼行數:8,代碼來源:__init__.py

示例10: worker

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def worker(self):
    try:
      while True:
        queue = self.work.get()
        frame = queue.get()
        channel = self.channel(frame.channel)
        if frame.method_type.content:
          content = read_content(queue)
        else:
          content = None

        self.delegate(channel, Message(channel, frame, content))
    except QueueClosed, e:
      self.closed(str(e) or "worker closed") 
開發者ID:apache,項目名稱:qpid-python,代碼行數:16,代碼來源:peer.py

示例11: invoke_reliable

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def invoke_reliable(self, frame, content = None):
    if not self.synchronous:
      future = Future()
      self.request(frame, future.put_response, content)
      if not frame.method.responses: return None
      else: return future

    self.request(frame, self.queue_response, content)
    if not frame.method.responses:
      if self.use_execution_layer and frame.method_type.is_l4_command():
        self.execution_sync()
        self.completion.wait()
        if self._closed:
          raise Closed(self.reason)
      return None
    try:
      resp = self.responses.get()
      if resp.method_type.content:
        return Message(self, resp, read_content(self.responses))
      else:
        return Message(self, resp)
    except QueueClosed, e:
      if self._closed:
        raise Closed(self.reason)
      else:
        raise e

  # used for 0-8 and 0-10 
開發者ID:apache,項目名稱:qpid-python,代碼行數:30,代碼來源:peer.py

示例12: parse

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def parse(self):
        list_of_messages = []
        set_of_senders = set()
        for l in self.raw_messages:
            msg_date, sep, msg = l.partition(": ")
            raw_date, sep, time = msg_date.partition(" ")
            sender, sep, content = msg.partition(": ")
            raw_date = raw_date.replace(",", "")
            year = raw_date.split(" ")[0].split("/")[-1]
            # The following lines treats:
            # 3/24/14 1:59:59 PM
            # 24/3/14 13:59:59 PM
            # Couldn't we use msg_date instead of chatTimeString here?

            # colonIndex = [x.start() for x in re.finditer(':', l)]
            # print l, colonIndex
            # chatTimeString = l[0:colonIndex[2]]
            # This ignores a minority of bad formatted lines using try/except block. 
            # an execption is raised when the datetime_obj is not created due to date parsing error
            try:
                if "AM" in msg_date or "PM" in msg_date:
                    datetime_obj = datetime.strptime(
                        msg_date, "%m/%d/%y, %I:%M:%S %p")
                else:
                    if len(year) == 2:
                        datetime_obj = datetime.strptime(msg_date, "%m/%d/%y %H:%M:%S")
                    else:
                        datetime_obj = datetime.strptime(msg_date, "%m/%d/%Y %H:%M:%S")
            except ValueError: 
                continue
                
            set_of_senders.add(sender)
            list_of_messages.append(message.Message(sender, content, raw_date, time, datetime_obj))

        return list(set_of_senders), list_of_messages 
開發者ID:nmoya,項目名稱:whatsapp-parser,代碼行數:37,代碼來源:whatsapp.py

示例13: _get_queued_cmd_current_index

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def _get_queued_cmd_current_index(self):
        msg = Message()
        msg.id = CommunicationProtocolIDs.GET_QUEUED_CMD_CURRENT_INDEX
        response = self._send_command(msg)
        idx = struct.unpack_from('L', response.params, 0)[0]
        return idx 
開發者ID:luismesas,項目名稱:pydobot,代碼行數:8,代碼來源:dobot.py

示例14: _read_message

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def _read_message(self):
        time.sleep(0.1)
        b = self.ser.read_all()
        if len(b) > 0:
            msg = Message(b)
            if self.verbose:
                print('pydobot: <<', msg)
            return msg
        return 
開發者ID:luismesas,項目名稱:pydobot,代碼行數:11,代碼來源:dobot.py

示例15: _set_cp_cmd

# 需要導入模塊: import message [as 別名]
# 或者: from message import Message [as 別名]
def _set_cp_cmd(self, x, y, z):
        msg = Message()
        msg.id = CommunicationProtocolIDs.SET_CP_CMD
        msg.ctrl = ControlValues.THREE
        msg.params = bytearray(bytes([0x01]))
        msg.params.extend(bytearray(struct.pack('f', x)))
        msg.params.extend(bytearray(struct.pack('f', y)))
        msg.params.extend(bytearray(struct.pack('f', z)))
        msg.params.append(0x00)
        return self._send_command(msg) 
開發者ID:luismesas,項目名稱:pydobot,代碼行數:12,代碼來源:dobot.py


注:本文中的message.Message方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。