Get message and author name from content. May contain multiple messages in the content.
555977
def _parseMessage(self, content):
        """"""
        self._seq = content.get("seq", "0")

        if "lb_info" in content:
            self._sticky = content["lb_info"]["sticky"]
            self._pool = content["lb_info"]["pool"]

        if "batches" in content:
            for batch in content["batches"]:
                self._parseMessage(batch)

        if "ms" not in content:
            return

        for m in content["ms"]:
            mtype = m.get("type")
            try:
                # Things that directly change chat
                if mtype == "delta":
                    self._parseDelta(m)
                # Inbox
                elif mtype == "inbox":
                    self.onInbox(
                        unseen=m["unseen"],
                        unread=m["unread"],
                        recent_unread=m["recent_unread"],
                        msg=m,
                    )

                # Typing
                elif mtype == "typ" or mtype == "ttyp":
                    author_id = str(m.get("from"))
                    thread_id = m.get("thread_fbid")
                    if thread_id:
                        thread_type = ThreadType.GROUP
                        thread_id = str(thread_id)
                    else:
                        thread_type = ThreadType.USER
                        if author_id == self._uid:
                            thread_id = m.get("to")
                        else:
                            thread_id = author_id
                    typing_status = TypingStatus(m.get("st"))
                    self.onTyping(
                        author_id=author_id,
                        status=typing_status,
                        thread_id=thread_id,
                        thread_type=thread_type,
                        msg=m,
                    )

                # Delivered

                # Seen
                # elif mtype == "m_read_receipt":
                #
                #     self.onSeen(m.get('realtime_viewer_fbid'), m.get('reader'), m.get('time'))

                elif mtype in ["jewel_requests_add"]:
                    from_id = m["from"]
                    self.onFriendRequest(from_id=from_id, msg=m)

                # Happens on every login
                elif mtype == "qprimer":
                    self.onQprimer(ts=m.get("made"), msg=m)

                # Is sent before any other message
                elif mtype == "deltaflow":
                    pass

                # Chat timestamp
                elif mtype == "chatproxy-presence":
                    statuses = dict()
                    for id_, data in m.get("buddyList", {}).items():
                        statuses[id_] = ActiveStatus._from_chatproxy_presence(id_, data)
                        self._buddylist[id_] = statuses[id_]

                    self.onChatTimestamp(buddylist=statuses, msg=m)

                # Buddylist overlay
                elif mtype == "buddylist_overlay":
                    statuses = dict()
                    for id_, data in m.get("overlay", {}).items():
                        old_in_game = None
                        if id_ in self._buddylist:
                            old_in_game = self._buddylist[id_].in_game

                        statuses[id_] = ActiveStatus._from_buddylist_overlay(
                            data, old_in_game
                        )
                        self._buddylist[id_] = statuses[id_]

                    self.onBuddylistOverlay(statuses=statuses, msg=m)

                # Unknown message type
                else:
                    self.onUnknownMesssageType(msg=m)

            except Exception as e:
                self.onMessageError(exception=e, msg=m)
136740
def list_authors():
    """"""
    authors = Author.query.all()
    content = '<p>Authors:</p>'
    for author in authors:
        content += '<p>%s</p>' % author.name
    return content
239488
def to_array(self):
        
        array = super(Message, self).to_array()
        array['message_id'] = int(self.message_id)  # type int
        array['date'] = int(self.date)  # type int
        array['chat'] = self.chat.to_array()  # type Chat
        if self.from_peer is not None:
            array['from'] = self.from_peer.to_array()  # type User
        if self.forward_from is not None:
            array['forward_from'] = self.forward_from.to_array()  # type User
        if self.forward_from_chat is not None:
            array['forward_from_chat'] = self.forward_from_chat.to_array()  # type Chat
        if self.forward_from_message_id is not None:
            array['forward_from_message_id'] = int(self.forward_from_message_id)  # type int
        if self.forward_signature is not None:
            array['forward_signature'] = u(self.forward_signature)  # py2: type unicode, py3: type str
        if self.forward_date is not None:
            array['forward_date'] = int(self.forward_date)  # type int
        if self.reply_to_message is not None:
            array['reply_to_message'] = self.reply_to_message.to_array()  # type Message
        if self.edit_date is not None:
            array['edit_date'] = int(self.edit_date)  # type int
        if self.media_group_id is not None:
            array['media_group_id'] = u(self.media_group_id)  # py2: type unicode, py3: type str
        if self.author_signature is not None:
            array['author_signature'] = u(self.author_signature)  # py2: type unicode, py3: type str
        if self.text is not None:
            array['text'] = u(self.text)  # py2: type unicode, py3: type str
        if self.entities is not None:
            array['entities'] = self._as_array(self.entities)  # type list of MessageEntity
        if self.caption_entities is not None:
            array['caption_entities'] = self._as_array(self.caption_entities)  # type list of MessageEntity
        if self.audio is not None:
            array['audio'] = self.audio.to_array()  # type Audio
        if self.document is not None:
            array['document'] = self.document.to_array()  # type Document
        if self.animation is not None:
            array['animation'] = self.animation.to_array()  # type Animation
        if self.game is not None:
            array['game'] = self.game.to_array()  # type Game
        if self.photo is not None:
            array['photo'] = self._as_array(self.photo)  # type list of PhotoSize
        if self.sticker is not None:
            array['sticker'] = self.sticker.to_array()  # type Sticker
        if self.video is not None:
            array['video'] = self.video.to_array()  # type Video
        if self.voice is not None:
            array['voice'] = self.voice.to_array()  # type Voice
        if self.video_note is not None:
            array['video_note'] = self.video_note.to_array()  # type VideoNote
        if self.caption is not None:
            array['caption'] = u(self.caption)  # py2: type unicode, py3: type str
        if self.contact is not None:
            array['contact'] = self.contact.to_array()  # type Contact
        if self.location is not None:
            array['location'] = self.location.to_array()  # type Location
        if self.venue is not None:
            array['venue'] = self.venue.to_array()  # type Venue
        if self.new_chat_members is not None:
            array['new_chat_members'] = self._as_array(self.new_chat_members)  # type list of User
        if self.left_chat_member is not None:
            array['left_chat_member'] = self.left_chat_member.to_array()  # type User
        if self.new_chat_title is not None:
            array['new_chat_title'] = u(self.new_chat_title)  # py2: type unicode, py3: type str
        if self.new_chat_photo is not None:
            array['new_chat_photo'] = self._as_array(self.new_chat_photo)  # type list of PhotoSize
        if self.delete_chat_photo is not None:
            array['delete_chat_photo'] = bool(self.delete_chat_photo)  # type bool
        if self.group_chat_created is not None:
            array['group_chat_created'] = bool(self.group_chat_created)  # type bool
        if self.supergroup_chat_created is not None:
            array['supergroup_chat_created'] = bool(self.supergroup_chat_created)  # type bool
        if self.channel_chat_created is not None:
            array['channel_chat_created'] = bool(self.channel_chat_created)  # type bool
        if self.migrate_to_chat_id is not None:
            array['migrate_to_chat_id'] = int(self.migrate_to_chat_id)  # type int
        if self.migrate_from_chat_id is not None:
            array['migrate_from_chat_id'] = int(self.migrate_from_chat_id)  # type int
        if self.pinned_message is not None:
            array['pinned_message'] = self.pinned_message.to_array()  # type Message
        if self.invoice is not None:
            array['invoice'] = self.invoice.to_array()  # type Invoice
        if self.successful_payment is not None:
            array['successful_payment'] = self.successful_payment.to_array()  # type SuccessfulPayment
        if self.connected_website is not None:
            array['connected_website'] = u(self.connected_website)  # py2: type unicode, py3: type str
        if self.passport_data is not None:
            array['passport_data'] = self.passport_data.to_array()  # type PassportData
        return array
614627
def _get_tags_and_content(self, content: str) -> typing.Tuple[str, str]:
        """"""
        content_lines = content.split('\n')
        tag_lines = []

        if content_lines[0] != '---':
            return '', content

        content_lines.pop(0)
        for line in content_lines:  # type: str
            if line in ('---', '...'):
                content_starts_at = content_lines.index(line) + 1
                content_lines = content_lines[content_starts_at:]
                break

            tag_lines.append(line)

        return '\n'.join(tag_lines), '\n'.join(content_lines)
134371
def _get_request_content(self, message=None):
        '''
        '''
        message = self._cast_message(message=message)
        return message.json()
570997
def author_mail_from_system(self):
        
        self.author_mail = getpass.getuser() + '@' + socket.gethostname()
        return self.author_mail
511590
def extract_message_value(self, name):
        '''  '''
        name += ":"
        assert(self._message)
        _start = self._message.find(name)
        if _start >= 0:
            _start += len(name) + 1
            _end = self._message.find("\n", _start)
            _value = self._message[_start:_end]
            return _value.strip()

        return None
308908
def FindFieldByName(self, full_name):
    
    full_name = _NormalizeFullyQualifiedName(full_name)
    message_name, _, field_name = full_name.rpartition('.')
    message_descriptor = self.FindMessageTypeByName(message_name)
    return message_descriptor.fields_by_name[field_name]
13364
def RECEIVE_MESSAGE(op):
    '''
        
    '''
    msg = op.message
    
    text = msg.text
    msg_id = msg.id
    receiver = msg.to
    sender = msg._from
    
    try:
        # Check content only text message
        if msg.contentType == 0:
            # Check only group chat
            if msg.toType == 2:
                # Chat checked request
                line.sendChatChecked(receiver, msg_id)
                # Get sender contact
                contact = line.getContact(sender)
                # Command list
                if text.lower() == 'hi':
                    line.log('[%s] %s' % (contact.displayName, text))
                    line.sendMessage(receiver, 'Hi too! How are you?')
                elif text.lower() == '/author':
                    line.log('[%s] %s' % (contact.displayName, text))
                    line.sendMessage(receiver, 'My author is linepy')
    except Exception as e:
        line.log("[RECEIVE_MESSAGE] ERROR : " + str(e))
1171489
def _parse_authors(element):
    

    authors = []
    items = element.findall("./{%s}author" % WP_NAMESPACE)

    for item in items:
        login = item.find("./{%s}author_login" % WP_NAMESPACE).text
        email = item.find("./{%s}author_email" % WP_NAMESPACE).text
        first_name = item.find("./{%s}author_first_name" % WP_NAMESPACE).text
        last_name = item.find("./{%s}author_last_name" % WP_NAMESPACE).text
        display_name = item.find(
            "./{%s}author_display_name" % WP_NAMESPACE).text

        authors.append({
            "login": login,
            "email": email,
            "display_name": display_name,
            "first_name": first_name,
            "last_name": last_name
        })

    return authors
745389
def _extract_author(self):
        

        if bool(self.author):
            return

        for pattern in self.config.author:

            items = self.parsed_tree.xpath(pattern)

            if isinstance(items, basestring):
                # In case xpath returns only one element.
                items = [items]

            for item in items:

                if isinstance(item, basestring):
                    # '_ElementStringResult' object has no attribute 'text'
                    stripped_author = unicode(item).strip()

                else:
                    try:
                        stripped_author = item.text.strip()

                    except AttributeError:
                        # We got a <div>…
                        stripped_author = etree.tostring(item)

                if stripped_author:
                    self.author.add(stripped_author)
                    LOGGER.info(u'Author extracted: %s.', stripped_author,
                                extra={'siteconfig': self.config.host})
747336
def message(self):
        """"""
        if self.type == 'cleartext':
            return self.bytes_to_text(self._message)

        if self.type == 'literal':
            return self._message.contents

        if self.type == 'encrypted':
            return self._message
1131844
def get_text(self, node):
        """"""
        try:
            return node.children[0].content or ""
        except (AttributeError, IndexError):
            return node.content or ""
1049125
private void getContent(Query query, Message message, int row) throws MessagingException, IOException {
	StringBuffer body = new StringBuffer();
	Struct cids = new StructImpl();
	query.setAtEL(CIDS, row, cids);
	if (message.isMimeType("text/plain")) {
	    String content = getConent(message);
	    query.setAtEL(TEXT_BODY, row, content);
	    body.append(content);
	}
	else if (message.isMimeType("text/html")) {
	    String content = getConent(message);
	    query.setAtEL(HTML_BODY, row, content);
	    body.append(content);
	}
	else {
	    Object content = message.getContent();
	    if (content instanceof MimeMultipart) {
		Array attachments = new ArrayImpl();
		Array attachmentFiles = new ArrayImpl();
		getMultiPart(query, row, attachments, attachmentFiles, cids, (MimeMultipart) content, body);

		if (attachments.size() > 0) {
		    try {
			query.setAtEL(ATTACHMENTS, row, ListUtil.arrayToList(attachments, "\t"));
		    }
		    catch (PageException pageexception) {}
		}
		if (attachmentFiles.size() > 0) {
		    try {
			query.setAtEL(ATTACHMENT_FILES, row, ListUtil.arrayToList(attachmentFiles, "\t"));
		    }
		    catch (PageException pageexception1) {}
		}

	    }
	}
	query.setAtEL(BODY, row, body.toString());
    }
491211
async def on_message(message):
    

    # Simplify message info
    server = message.server
    author = message.author
    channel = message.channel
    content = message.content

    data = datatools.get_data()

    if not data["discord"]["servers"][server.id][_data.modulename]["activated"]:
        return

    # Only reply to server messages and don't reply to myself
    if server is not None and author != channel.server.me:
        # Commands section
        prefix = data["discord"]["servers"][server.id]["prefix"]
        if content.startswith(prefix):
            # Parse message
            package = content.split(" ")
            command = package[0][len(prefix):]
            args = package[1:]

            alias_steam = ["steam", "pc"]
            alias_ps = ["ps", "psn", "playstation", "ps4", "playstation 4"]
            alias_xbox = ["xbox", "xb", "xb1", "xbone", "xbox one", "xbox one"]

            platform = "steam"
            if len(args) > 0:
                player_name = args[0]
            else:
                return

            if len(args) > 1:
                platform = ' '.join(args[1:]).lower()

            if platform in alias_steam:
                platform = "steam"
            elif platform in alias_ps:
                platform = "ps"
            elif platform in alias_xbox:
                platform = "xbox"

            # Commands
            if command == 'rlstats':
                await client.send_typing(channel)

                # Get Rocket League stats from stats API
                success, rldata = api_rocketleaguestats.check_rank(player_name, platform)
                # Create embed UI
                if success:
                    embed = ui_embed.success(channel, rldata[0], rldata[1], rldata[2], rldata[3])
                else:
                    embed = ui_embed.fail_api(channel)

                await embed.send()
1271075
def author_tokenize(name):
    """"""
    phrases = scan_author_string_for_phrases(name)
    res = {'lastnames': [], 'nonlastnames': []}
    for key, tokens in phrases.items():
        lst = res.get(key)
        if lst is None:
            continue
        for token in tokens:
            if len(token) == 1:
                lst.append(NameInitial(token))
            else:
                lst.append(NameToken(token))
    return res
824159
function parseProducerInfo(name, content) {
  const info = utils.splitString(content, ',', 5);
  const ret = {
    name,
    startedAt: Number(info[0]),
    msgTotal: Number(info[1]),
    msgSuccess: Number(info[2]),
    msgError: Number(info[3]),
    msgExpired: Number(info[4]),
  };
  return ret;
}