Skip to main content

chat-message

Streamlit component that allows you to style chat messages into chat bubbles. Uses daisyUI.

Installation instructions

pip install chat-message

Usage instructions

import streamlit as st
from chat_message import chat_message

user = {
  "id": 1,
  "name": "user1",
  "socket": "",
  "admin": False,
}

# simulated database data
rows = [
  {
    'message_id': 1,
    'message_msg': 'This is a test.',
    'message_roomId': 1,
    'message_time': datetime.datetime(2024, 7, 10, 6, 55, 59),
    'author_id': 1,
    'author_name': 'user1',
    'author_email': 'user1@example.com',
    'author_socket': ''
  },
  {
    'message_id': 2,
    'message_msg': 'This is only a test.',
    'message_roomId': 1,
    'message_time': datetime.datetime(2024, 7, 10, 6, 55, 59),
    'author_id': 2,
    'author_name': 'user2',
    'author_email': 'user2@example.com',
    'author_socket': ''
  }
]

result = []
for row in rows:
  obj = {
    "id": row["message_id"],
    "message": row["message_msg"],
    "room": row["message_roomId"],
    "time": row["message_time"].isoformat(),
    "author": {
      "id": row["author_id"],
      "name": row["author_name"],
      "socket": row["author_socket"]
    }
  }
  result.append(obj)

i = 0
for row in result:
  prev = None
  next = None

  if len(result) > 1:
    prev = result[i-1]

  if len(result) > i+1:
    next = result[i+1]

  appendTime = True
  appendUser = True

  if prev:
    if prev["author"]["id"] == row["author"]["id"]:
      diff = timeDiffInSecs(row["time"], prev["time"])
      if diff < 60:
        appendUser = False

  if next:
    if next["author"]["id"] == row["author"]["id"]:
      diff = timeDiffInSecs(next["time"], row["time"])
      if diff < 60:
        appendTime = False

  click = st_chat_message(row, user, appendUser, appendTime)
  print(click)

  i = i+1

Metadata

Release files for chat-message 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chat-message 1.0.0
File Size Uploaded Provenance Actions
chat-message-1.0.0.tar.gz 423.8 kB Without provenance Details for chat-message-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chat-message 1.0.0
File Interpreter ABI Platform Actions
chat_message-1.0.0-py3-none-any.whl Python 3 none any Details for chat_message-1.0.0-py3-none-any.whl

Total release size: 852.4 kB

Release files / chat-message-1.0.0.tar.gz

Download URL chat-message-1.0.0.tar.gz
Size 423.8 kB
Tags Source
SHA-256 checksum
How to use checksums
33a2c0c3420980a384e71309b4d83333a2027a4c46d2724c2abd70699af56295
BLAKE2b-256 checksum
How to use checksums
2fd2532079ad798c7e57ec4bdb1ec0d54ff0140c3036e2e68f1be1286d21281d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.2

Release files / chat_message-1.0.0-py3-none-any.whl

Download URL chat_message-1.0.0-py3-none-any.whl
Size 428.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c7380a1f5731369515e8d598547a3641bdfdffa813d760d2bf51245891543ba
BLAKE2b-256 checksum
How to use checksums
ac24e908c123739cdce7889574019e88c6dffd58b958f7b2d4b634e1845f4b73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.2

Security for chat-message 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page