Git Product home page Git Product logo

chat-linker's Introduction

chat-linker's People

Contributors

albjeremias avatar bannerets avatar dependabot[bot] avatar fornever avatar jt3k avatar newlifer avatar vitalyster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chat-linker's Issues

Possibility of sending stickers.

Since there is no easy way to transfer stickers from telegram to jabber, I suggest sending emoji bound to this sticker.

example:
In jabber-side sticker can look like here

<@vasya> sends sticker: 🍷🍻🎶

npm run prod doesn't work

$ npm run prod
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info lifecycle [email protected]~preprod: [email protected]
npm info lifecycle [email protected]~prod: [email protected]

> [email protected] prod /usr/app/src
> NODE_ENV=prod app.js

sh: 1: app.js: not found

It seems like you're missing node in your script definition: "prod": "NODE_ENV=prod app.js" should be "prod": "NODE_ENV=prod node app.js".

XMPP message editing support

XMPP supports message editing (see XEP-0308) just as Telegram do (see #18).

This is a dual issue for #18: we need to get some insight on bots' ability to edit their own messages in Telegram and implement proper support for edited XMPP messages in the bot. So, when a user edits his/her message in XMPP, the edit should be transparently translated to Telegram.

Currently I doubt that Telegram bots can edit their messages; I'll ask the experts.

Some messages break the template

When any XMPP user posts a message like that:

<user> $`

It gets wrongly translated to Telegram, because it's a meta-character for String.prototype.replace.

Resend failed XMPP messages

Consider this scenario:

  1. XMPP gets implicitly disconnected, but the client is still not aware of it.
  2. Bot receives a Telegram message.
  3. Bot tries to send it to XMPP and realizes it's disconnected. XMPP throws an error.
  4. Bot reconnects to XMPP and everything is alright, except that the message it tried to send at p. 3 is now lost.

Bot should buffer the message if an error has been occured on send and resend the message after the reconnect.

Add readme

  • summary
  • funny image
  • installation
    • config info
  • usage
  • contribution info
    • husky

Option to make Telegram messages more compact

Currently Telegram messages aren't very compact: they look like

username
Message body.

I suggest to add an option to change the format to more compact, such as

<username> Message body.

Remove /me from XMPP side

Some guys are complains about /me on XMPP side. Probably it'll be better to remove that (and send the messages as is, without and prefixes).

better XMPP integration

Current implementation uses single account to send all messages.
I propose changing this behaviour by using multiple connections into a single conference in XMPP with resources matching telegram user names. (e.g. [email protected]/username)

So if you have a chat of user1, user2, user3 you should join [email protected] three times with nicknames (and from resources) of /user1, /user2, /user3 and send messages from appropriate resource.

On a nick collision add some prefix or suffix.

Later this may be reworked to create a service when the bot can link two chatroom of different networks by a user command.

Followed instructions but can't run

> [email protected] dev /home/artur/chat-linker
> cross-env NODE_ENV=dev node --inspect dist/app.js

Debugger listening on ws://127.0.0.1:9229/4a43126a-1307-419e-be0b-ad24ddb37d82
For help, see: https://nodejs.org/en/docs/inspector
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '../../../app-config'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/joker/chat-linker/dist/bots/jabber/index.js:7:18)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `cross-env NODE_ENV=dev node --inspect dist/app.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/artur/.npm/_logs/2021-07-10T00_40_02_145Z-debug.log

Config

const chat = config[process.env.NODE_ENV];

ain't good, we should make getting of config external passing it as args to entry point, bots should know anything about Node or any other env they're running on

Add plugin support

It would be great if the chat-linker could support the plug-ins.

This would make it easier to add functionality, for example anti-spam or anti-obscene-swearing.

At the first stage, I would like to see a synchronous or asynchronous middleware.
For example, as it is done in axios interceptors or babel-plugin

plugin example:

module.exports = ({
 interceptors: [
  {
   from: 'telegram', // or from: '*'
   to: 'xmpp',
   interceptor({ network, name, message, room }) {
    // message processing here
    return { network, name, message, room }
   }
  }
 ]
})

multilink support

support linking for more than one chat room

python_jabber <--> python_telegram
js_jabber <--> js_telegram
...

bugs stickers: the forward-message not displayed on jabber side

if you forward a message with a sticker then it is not visible on the jabber side

in console i see

  TypeError: Cannot read property 'replace' of undefined
      at ForwardedMessage.toString (/Users/jt3k/tmp/chat-linker/bots/telegram/client.js:74:29)
      at prepareMessage (/Users/jt3k/tmp/chat-linker/bots/telegram/client.js:123:33)
      at prepareEmittingMessageDetails (/Users/jt3k/tmp/chat-linker/bots/telegram/client.js:135:15)
      at client.on (/Users/jt3k/tmp/chat-linker/bots/telegram/client.js:149:15)
      at Promise.resolve.then (/Users/jt3k/tmp/chat-linker/node_modules/telegraf/lib/core/composer.js:81:56)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

Add quote limit

Currently, if someone quotes the big message in Telegram, the whole message gets copied into XMPP room.

Probably we should add a configurable limit for quoting (line count, character count)? Cut the quotes that exceeds the configured limit with ellipsis.

Deal with configuration files 🎱

  • throw exception if app-config.json is not exist
  • rename app-config.json to sample-config.json
  • add app-config.json to .gitignore
  • maybe someday make a script to create the configs

Make Heroku prevent-sleep optional

For example, I'm hosting chat-linker on my own server and I don't need any prevent-sleep.js functionality. It should be possible to completely disable that module through the configuration.

Setup environment with cross-env

Windows users are reporting that they are unable to execute npm run prod because prod script if defined as NODE_ENV=prod node app.js in our package.json.

We need to use cross-env to set the environment variable uniformly across the platforms.

add ci

  • tests
    • xo
    • units
  • deploy

Telegram -> XMPP loses messages when they're posted frequently

Consider the following situation: three Telegram users post some messages in one second, e.g.

(TELEGRAM SIDE)
[12:34:56] <@telegram1> msg1
[12:34:56] <@telegram2> msg2
[12:34:56] <@telegram3> msg3

These messages should be translated by bot without any problems:

(JABBER SIDE, EXPECTED)
[12:34:57] <tg> <@telegram1> msg1
[12:34:57] <tg> <@telegram2> msg2
[12:34:57] <tg> <@telegram3> msg3

But actually some messages will definitely be lost:

(JABBER SIDE, ACTUAL)
[12:34:57] <tg> <@telegram1> msg1
[12:34:57] <tg> <@telegram3> msg3

Images from Telegram are not translated to XMPP

Try to post image to Telegram. It won't cause any measure effect on XMPP room. That's inappropriate.

At least show something like [Image posted], but better repost the image to some server (probably keep it on your own Heroku instance) and post the link to XMPP.

Change the display of forward messages.

in telegram forwarded message looks like this:
image

now in xmpp we see:

8:35 @jt3k проветка
8:35 +tg <@iyntx> прошла успешно
8:35 +tg <@iyntx> >> <robotron3000bot> jt3k
>> проветка

I would like, on the xmpp side, to see a more consistent visual look:

8:35 +tg <@iyntx> прошла успешно
>> Forwarded from [email protected]<@robotron3000bot>
>> <jt3k> проветка

or like this:

8:35 +tg <@iyntx> прошла успешно
8:35 +tg  >> Forwarded from [email protected]<@robotron3000bot>
>> <jt3k> проветка

8:35 and +tg is only displayed in the xmpp client

Not all types of messages are translated from Telegram

  • text
  • forwarded message
  • reply
  • photo [partially]
  • document [partially]
  • sticker [partially]
  • audio
  • video
  • video_note
  • voice
  • contact
  • location
  • venue
  • game
  • new_chat_participant
  • left_chat_participant
  • new_chat_photo
  • delete_chat_photo (service message)
  • new_chat_title
  • invoice
  • successful_payment (service message)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.