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

vklive-message-client

v3.2.0

Published

TypeScript implementation of vkplay live stream chat client

Downloads

39

Readme

VKplay live chat API client

Это пре-альфа версия, здесь не реализован механизм обновления токена, и не протестировано на продолжительном подключении к вебсокету. Возможны вылеты и ошибки. Баги присылать сюда https://github.com/thearturca/vkplay-live-message-client/issues

Описание

Эта библиотека поможет вам подключиться к чату канала стримера на стриминговой площадке live.vkplay.ru, и получать/отправлять сообщения с парсингом смайлов, создавать чат-ботов или клиенты для чатов. Чаты работают даже когда стримера нет в сети.

Авторизация

Для отправки сообщений нужно указать токен live.vkplay.ru, либо авторизационные данные для входа (логин и пароль). Так как ещё нет легального удобного способа получить токен, его нужно взять из localStorage вашего браузера, если вы уже залогинены. Находиться в поле auth. Лучше всего создать новый аккаунт для бота. Если вы знаете, как достать токен, сообщите мне в discord.

Discord для вопросов: thearturca

Поддержи проект на бусти!

Установка

npm i vklive-message-client

Пример использования

Токен

const authToken: string = process.env.VKPL_OAUTH ?? "";

const client = new VKPLMessageClient({ auth: { token: authToken }, channels: [target], debugLog: true });
await client.connect();
await client.sendMessage("Connected to chat!", target);

client.on("message", async (context) => {
      if (context.message.text.startsWith("!command"))
            await context.sendMessage("Hello World");
});

Логин и Пароль

const login: string = process.env.VKPL_LOGIN ?? "";
const password: string = process.env.VKPL_PASSWORD ?? "";

const client = new VKPLMessageClient({ auth: { login, password }, channels: [target], debugLog: true });
await client.connect();
await client.sendMessage("Connected to chat!", target);

client.on("message", async (context) => {
      if (context.message.text.startsWith("!command"))
            await context.sendMessage("Hello World");
});

Фичи

Readonly режим

В режиме readonly нельзя отправлять сообщения, но можно получать их. Для активации этого режима нужно в поле auth написать "readonly" или не передавать параметр auth вообще.

const client = new VKPLMessageClient({ auth: "readonly", channels: [target], debugLog: true });
await client.connect(); // После подключения все сообщения будут выводится в консоль

Вставка ссылок

В боте есть возможность вставки ссылок в текст сообщения. Доступно 2 формата ссылок:

  • Прямая ссылка. Пример: https://github.com/thearturca/vkplay-live-message-client
  • Ссылка в стиле markdown. Пример: [Ссылка](https://github.com/thearturca/vkplay-live-message-client)

Ссылка в стиле markdown будет выглядеть следующим образом:

Ссылка

Пример вставки ссылки

const client = new VKPLMessageClient({ auth: { token: authToken }, channels: [target], debugLog: true });
await client.connect();

// отправки прямой ссылки
await client.sendMessage("Ссылка на мой гитхаб: https://github.com/thearturca/vkplay-live-message-client", target);

// отправки ссылки в стиле markdown
await client.sendMessage("[Ссылка на мой гитхаб](https://github.com/thearturca/vkplay-live-message-client)", target);