npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chat-logger

v0.11.1

Published

A logger for Telegram messages

Downloads

35

Readme

chat-logger

A system to log chat messages.

npm version Dependency Status devDependency Status

How it works

The system is composed of 3 main parts/applications:

  1. Chat relays
  • the bots/daemons that connects to chat networks (such as Telegram) or message queues (such as rabbitMQ)
  1. Persistent storage
  • the local storage/database that keeps all logged messages from the chats
  1. Web UI
  • the web app that displays the logged messages with a nice interface

To run an instance of the chat logger, you will have to setup your chat relays, choose a local storage and optionally launch the web UI. This documentation and the project itself is still under heavy development, which means that the guides below can break between updates.

Getting Started

Cloning this repository

First step is to clone this repository. If you just want to use the latest version, you can clone it with a depth 1 to save bandwidth since the code history is not important. If you plan to contribute or want to have the full history, just clone the whole thing:

# For regular users
git clone --depth 1 https://github.com/calamar-io/chat-logger.git

# For devs over HTTPS:
git clone https://github.com/calamar-io/chat-logger.git

# For devs over SSH:
git clone [email protected]:calamar-io/chat-logger.git

Installing/Updating the development dependencies

Since this project is still under heavy development, I advise you to just install all the dev dependencies in orther to be able to run most of the build tasks (npm-scripts). To do that, you will need to have a machinne with a recent version of Node.js installed.

Then, inside the root of the cloned repository folder do:

npm install

Dev tasks

A list of all available tasks can be obtained by running

npm run

The most important ones for now are the building tasks for generating the web UI and the starting tasks to launch the main daemons.

Building the web UI

To generate the web UI run:

npm run build:webapp

Configuring the servers

To configure the different parts of the system, there are a set of expected environment variables you can set. To do that, make a copy of the .env-sample file, change the desired variables and run it:

cp .env-sample .env
nano .env
source .env

Launching the servers

The tasks with the prefix start:something are the ones that launch the individual parts of the system (Chat Relays, Storages and UIs).

For example: you can launch a telegram bot that listen to messages sent to it and outputs the state of a flux store to the screen (the code under examples/telegram.js) with:

npm run start:telegram

(Type Ctrl+C to exit it)

To launch multiple deamons and manage them you can install pm2 and run the tasks with the prefix start:pm2:something.

The default setup

Currently the default choice of daemons for chat relay, datastore and ui uses:

  • rethinkDB for the database
  • http-server for the webserver
  • telegram-bot-api for the chat relay

If you have rethinkdb installed, you can create the database and required tables with:

npm run reset:db

If you have pm2 globally installed on your system, you can launch the default choice of daemons with:

npm start

The web UI will be launched on localhost port 8081 and the rethinkDB admin UI on port 8080.

Manually querying the RethinkDB data explorer

open localhost:8080/#dataexplorer

Gett all messages

r.db('chat_logger').table('messages').orderBy(r.desc('date'))

Add messages to a chat session

r.db('chat_logger').table('messages').insert([{
  text: "Hello World 7",
  chatId: "414aca94-349a-40fa-a388-1034fa2426bd",
  userId: "a0e3eb3b-c478-434d-93f2-c021361f3cd7",
  id: new Date().getTime(),
  date: new Date().getTime(),
  loggerId: null,
  provider: null
}], {returnChanges: true})

License