jt3k / chat-linker Goto Github PK
View Code? Open in Web Editor NEWthe bridge between jabber and telegram over chat-bots
License: MIT License
the bridge between jabber and telegram over chat-bots
License: MIT License
From XMPP room:
<tg> <@undefined> как реализовать работу 9 работ практических на одной странцы ?
At the same time in Telegram I can see the name of the man who wrote that, but he somehow has no nickname:
Use tips from this list https://github.com/matiassingers/awesome-readme
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
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"
.
for example with generator-nm
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.
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
.
Possible solution: resend to xmpp fixed message with citation.
type coverage of src/bots/jabber/client.js
file is only 55%.
Consider this scenario:
Bot should buffer the message if an error has been occured on send and resend the message after the reconnect.
maybe it related to #44
do not see the reply-message on the jabber side, (at the same time the smiley itself is displayed)
in linking mechanism in configuration
stop forwarding the message to jabber after rename the telegram-group
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.
Sometimes bot is disconnected from XMPP, and it restores the connection only after any message to Telegram. I suspect that something's wrong with client timeouts; please make it configurable.
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).
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.
For sending images to xmpp chat.
https://github.com/jt3k/chat-linker/blob/master/README.md states that
demo XMPP-side: [email protected] (RU)
but it doesn't seem to be present there.
with info about this repo and linked networks
> [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
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
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 }
}
}
]
})
support linking for more than one chat room
python_jabber <--> python_telegram
js_jabber <--> js_telegram
...
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)
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.
app-config.json
is not existapp-config.json
to sample-config.json
.gitignore
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.
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.
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
this leads to the fact that the bot must be restarted by hands every few days.
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.
in telegram forwarded message looks like this:
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.