fruitiex / teleirc Goto Github PK
View Code? Open in Web Editor NEWA simple Telegram ↔ IRC gateway.
License: MIT License
A simple Telegram ↔ IRC gateway.
License: MIT License
In my config.js, I have the following:
config.ircPerformCmds = [
'/msg NickServ IDENTIFY TheBotIRCusername password'
];
But in the logs I'm getting this error, and it's not completing the command.
IRC ERROR:
{ prefix: 'tepper.freenode.net',
server: 'tepper.freenode.net',
command: 'err_unknowncommand',
rawCommand: '421',
commandType: 'error',
args: [ 'TelegramBot', '/msg', 'Unknown command' ] }
Now that #79 is merged, there are still some small things that could be improved upon concerning code structure and placement. For example, Telegram code still knows enough about IRC to choose which IRC channel to send messages to. In my opinion this should be handled on an above layer (in src/index.js), and Telegram code should not care at all what protocol the messages are going to be sent to.
If a user wants to use the same username on both Telegram and IRC, then teleirc will cause a IRC highlight for that user each time they say something on Telegram.
Not sure there's much we can do about this. Any ideas?
Pardon for a noobish question but if I registered my bot with "username" and "password" on Freenode then what would be value of ircPerformCmds in the config file?
Currently e.g. /names
breaks if capital letters are used in the IRC channel name.
If my nickname is Mikaela on IRC and Telegram, every time I write from IRC, Telegram alerts about @Mikaela being mentioned.
I think that
@
shouldn't be prepended to messages the user sends by themselves to avoid Telegram notification.@
to messages other people send including the Telegram username or not.
@
to ping Telegram, but self-pings are just annoying and I can imagine that some people might want to disable this and there shouldn't be any harm from customizatibility.At the moment I implement pretty much all the functionality here and then some using the vysheng telegram-cli (I'd be more than happy to contribute my code back to here if needed as I have done similar commands you have looked for such as a names list etc to show who is on irc).
One of the reasons I havent switched to the bot api is because people in my contact list have names that don't necessarily tie up to the name they have defined themselves. In my bot I am able to define the name of the person I wish the irc server to display. I often change their display name in my bot address book to be the same as the persons irc nick. This way everyone can recognise each other.
I have noticed the telegram bot api does not have this concept of its own address book and therefore using the Bot API you are at the mercy of the users on telegram having the same nick as their irc nick.
Based on what you have done so far in this bot can you think of a method that would solve this issue?
The only way I can think of is to hold some form of mapping between a user_id the bot knows in a chat and the nick. That way when a message is emitted to irc it does the look up for their defined irc name and then uses this to send the message instead of their display name on telegram
in 738ae5e#diff-a580c1ba0497b29ca59e113698fc745dR174 I can't see how to extract text of the message to which another participant replied.
After upgrading to supergroup teleirc can no longer send messages from IRC to Telegram.
The error is
Unhandled rejection Error: 400 {"ok":false,"error_code":400,"description":"[Error]: Bad Request: group chat is migrated to supergroup chat","parameters":{"migrate_to_chat_id":...
"migrate_to_chat_id" has the necessary id. Teleirc should instead of outputting error use that id to write it to chat_id and resend failed messages (if any).
Currently they are sent into IRC as full messages. It'd be nice to send them as actions ("/me" commands of the relay bot)
Hi,
I can't get messages from Telegram to IRC working. Messages from IRC to Telegram work fine.
At startup I get the following errors when running in debug mode
Unhandled message: { prefix: 'irc.nebula.fi',
server: 'irc.nebula.fi',
command: '020',
rawCommand: '020',
commandType: 'normal',
args: [ '*', 'Please wait while we process your connection.' ] }
Unhandled message: { prefix: 'irc.nebula.fi',
server: 'irc.nebula.fi',
command: '042',
rawCommand: '042',
commandType: 'normal',
args: [ 'tgBot', '<id>', 'your unique ID' ] }
After that I don't get any errors. Telegram messages simply disappear somewhere and never show up in IRC. The tgBot does connect to the IRC channel fine.
Any ideas? I have set the config.js and chat_ids, they should be fine.
Could it maybe be a privilege issue? I installed node and npm as a non-sudo user and I'm running teleirc as non-sudo as well. Can this have an effect? Anyway to check or fix it?
I'm not really happy with the structure here:
https://github.com/FruitieX/teleirc/blob/develop/teleirc.js#L7-L14
Find a better way of loading the modules even though they depend on each other.
Is there a method to retrieve a list of users that are currently in an IRC channel? say by manually typing in a command?
I'm currently using this for my active channel but i have i no idea if the user i'm talkign to us actually on IRC.
How to add color to IRC messages: http://www.mirc.com/colors.html
So when typing ^C5,12colored text and background
the result in Telegram is "5,12colored text and background".
They are sent to Telegram as "\u000312" etc. I think we should remove them.
On console:
~/.teleirc/chat_ids file not found!
Please add your Telegram bot to a Telegram group and have
someone send a message to that group.
teleirc will then automatically store your group chat_id.
On the Telegram group, after inviting bot as teleirc_si_bot
:
@teleirc_si_bot hi
hi @teleirc_si_bot
hi
/names@teleirc_si_bot
No response.
If I write on IRC:
>> relaying to TG: <leoboiko>: hi
>> relaying to IRC: ERROR: No chat_id set! Add me to a Telegram group and say hi so I can find your group's chat_id!
ERROR: No chat_id set! Add me to a Telegram group and say hi so I can find your group's chat_id!
I installed teleirc via npm for debian wheezy.
How can I debug it ?
Is there a way to make it do a perform on connect to irc? So it can login to chanserv etc?
Also possible to give it irc commands such as op etc by typing a command? Adding simple irc scripts would be very useful
Having TeleIRC as a foreground process causes the issues in the below issue I typed up before I figured out how to make things work. In the README, it should be noted that simply running teleirc
will only run the bridge while that terminal connection is open. To run teleirc as a background process (so you can close your terminal session, etc…), the command teleirc &
ought to be used.
ORIGINAL TITLE: TeleIRC not respecting nohup (at least under FreeBSD)
My TeleIRC bot keeps disconnecting whenever I close the terminal session that contains the output. This still happens when I start calling it with nohup teleirc
, which is supposed to force commands to run even when the user they're under logs out or closes the terminal.
Supybot-style is:
The current (running) version of this Supybot is 2016.03.21, running on Python 3.5.1 (default, Jan 6 2016, 10:18:06) [GCC 4.7.2]. The newest versions available online are 2016.04.02 (in testing), 2016.03.21 (in master).
but I think information on the running version of the bot (including commit) would be the most important and just optionally having the newest version available.
When the option to save images and host them on a webserver is set in the config file, teleirc interprets correctly and copy an image when it was sent by an user using the "Photo or Video" option, but not if the image was sent by the Telegram user as "File".
IRC users see links for both images
IRC users see the first link, but on the second one they see "(Document)"
Is rich text currently supported in any form? Which functions can enable it?
I mostly think of replacing ugly <username>
imported from IRC with something prettier.
When a message is sent on IRC and the bot is mentioned, the message is printed bu console.log() but 2 seconds after that this error shows up and the message never arrives in Telegram:
Possibly unhandled StatusCodeError: 400 - {"ok":false,"error_code":400,"description":"Error: PEER_ID_INVALID"}
at new StatusCodeError (/home/aaron/teleirc/node_modules/telegram-bot/node_modules/request-promise/lib/errors.js:26:15)
at Request.RP$callback [as _callback] (/home/aaron/teleirc/node_modules/telegram-bot/node_modules/request-promise/lib/rp.js:64:32)
at Request.self.callback (/home/aaron/teleirc/node_modules/telegram-bot/node_modules/request-promise/node_modules/request/request.js:198:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (/home/aaron/teleirc/node_modules/telegram-bot/node_modules/request-promise/node_modules/request/request.js:1073:14)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/aaron/teleirc/node_modules/telegram-bot/node_modules/request-promise/node_modules/request/request.js:1019:12)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
At IRC side I can see something like
<replier_user>
: @asker_user, here is my answer to you.
and what I showed as bold here is colored at IRC side.
Only asker_user
part should be colored instead.
Hej,
It is possible to send botcommand like "!bla" to send from Telegram to irc without "< Nick >"
relay all is true in config
With the way handleTgLine
is implemented now
if the username contains a ">>>"
the rest of the name is shown as part of the message.
A possible fix could be to use the --json
flag when starting the telegram-cli
and change handleTgLine
to parse json.
It should be possible to configure the format of relayed Telegram messages. Ideally a configurable string with placeholders.
This happens 1-5 times per week. Needs manual restart.
Possibly unhandled StatusCodeError: 504 -
<title>504 Gateway Time-out</title>at new StatusCodeError (/home/bysmyyr/teleirc/node_modules/telegram-bot/node_modules/request-promise/lib/errors.js:26:15)
at Request.RP$callback [as _callback] (/home/bysmyyr/teleirc/node_modules/telegram-bot/node_modules/request-promise/lib/rp.js:64:32)
at Request.self.callback (/home/bysmyyr/teleirc/node_modules/telegram-bot/node_modules/request-promise/node_modules/request/request.js:198:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (/home/bysmyyr/teleirc/node_modules/telegram-bot/node_modules/request-promise/node_modules/request/request.js:1073:14)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/bysmyyr/teleirc/node_modules/telegram-bot/node_modules/request-promise/node_modules/request/request.js:1019:12)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
Possibly unhandled StatusCodeError: 504 -
<title>504 Gateway Time-out</title>at new StatusCodeError (/home/bysmyyr/teleirc/node_modules/telegram-bot/node_modules/request-promise/lib/errors.js:26:15)
at Request.RP$callback [as _callback] (/home/bysmyyr/teleirc/node_modules/telegram-bot/node_modules/request-promise/lib/rp.js:64:32)
at Request.self.callback (/home/bysmyyr/teleirc/node_modules/telegram-bot/node_modules/request-promise/node_modules/request/request.js:198:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (/home/bysmyyr/teleirc/node_modules/telegram-bot/node_modules/request-promise/node_modules/request/request.js:1073:14)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/bysmyyr/teleirc/node_modules/telegram-bot/node_modules/request-promise/node_modules/request/request.js:1019:12)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
It is much more professional to push only fully working commits. So every stage in the sourcetree should work. That makes reading the history much easier and do not show your typos to everyone and give much more picture to companies when they like to hire you.
http://stackoverflow.com/questions/5721566/combining-multiple-commits-into-one-prior-to-push
After running teleirc for some days there have now been two occasions where the messages from Telegram are not passed on to IRC but works all the time the other way round. There is no sign of those messages in the debug.
After restart the missing messages are relayed from the queue.
As stated in title. When adding or removing a bot from a telegram group a message will come on irc from the user that did it that simply says "undefined".
It would be nice that the bot would start ignoring Telegram-spammers for some time (and automatically unignoring after that time) when they decide it's a good idea to paste /etc/pacman.d/mirrorlist
from pacman-mirrorlist
package.
Would be nice to be able to ignore different users or messages based on regex so that they would not be sent from irc to telegram. For example ignoring some output from ircbots sending titles from URLs, or completly ignoring ircbots.
Currently arguments are nicely hardcoded and required to be in a certain position at the command line. This is no good, let's use a proper library such as yargs. This also makes it trivial to implement e.g. config loading from a custom path, supplied on the command line.
When trying to get my TeleIRC bot to link one Telegram group to two IRC channels, only the first IRC channel in config.js receives Telegram messages. The other channels will relay messages from IRC to Telegram, but I can't have it relay to both #mainchat and #debug and #test from a single Telegram group.
It would be nice to eventually have a loadable module system similar to ZNC, for features that don't belong in core teleirc.
Here's the contents of msg
when this happens:
{ message_id: 10,
from:
{ id: ...,
first_name: '...',
last_name: '...',
username: 'fruits' },
chat: { id: ..., title: 'Fruits bot testing', type: 'group' },
date: 1446976507,
new_chat_photo:
[ { file_id: '...',
file_size: 5217,
width: 160,
height: 160 },
{ file_id: '...',
file_size: 10738,
width: 320,
height: 320 },
{ file_id: '...',
file_size: 22508,
width: 640,
height: 640 } ] }
relaying to IRC: : undefined
According to the Telegram library we're using, we should now be able to get URLs to sent files or download sent files. We could use this to share the media files to IRC.
Ideally, the bot should download each media file that is sent to Telegram, host them via HTTP with for example node-static
, and then send an URL to the hosted file to IRC. We could also just send the link we get from getFileLink()
, but it's only valid for one hour.
Ignore this issue, it's just for testing a GitHub web hook. :)
Related to that commit message, program crash when pic is send to channel when irc is not ready. I will investigate that later but if somebody have time, here is initial crash report. I think that is older problem but triggered only for now.
Unhandled rejection TypeError: Cannot call method 'match' of undefined
at Client._splitLongLines (/home/bysmyyr/teleirc/node_modules/irc/lib/irc.js:923:11)
at /home/bysmyyr/teleirc/node_modules/irc/lib/irc.js:960:36
at Array.forEach (native)
at Client._speak (/home/bysmyyr/teleirc/node_modules/irc/lib/irc.js:959:12)
at Client.say (/home/bysmyyr/teleirc/node_modules/irc/lib/irc.js:946:10)
at Object.sendTo.irc (/home/bysmyyr/teleirc/irc.js:86:13)
at /home/bysmyyr/teleirc/tg.js:99:22
at tryCatcher (/home/bysmyyr/teleirc/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/home/bysmyyr/teleirc/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:507:31)
at Promise._settlePromiseAt (/home/bysmyyr/teleirc/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:581:18)
at Promise._settlePromises (/home/bysmyyr/teleirc/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:697:14)
at Async._drainQueue (/home/bysmyyr/teleirc/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/home/bysmyyr/teleirc/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:133:10)
at Async.drainQueues (/home/bysmyyr/teleirc/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:15:14)
at process._tickCallback (node.js:442:13)
When someone joins public supergroup using https://telegram.me/ link, Teleirc says user was added by user
at IRC and I think it looks a little weird and should instead be something like user joined via telegram.me/groupname
.
node-icu-charset-detector.target.mk:88: recipe for target 'Release/obj.target/node-icu-charset-detector/node-icu-charset-detector.o' failed
make: *** [Release/obj.target/node-icu-charset-detector/node-icu-charset-detector.o] Error 1
make: Leaving directory '/usr/lib/node_modules/teleirc/node_modules/node-icu-charset-detector/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.1.5-x86_64-linode61
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/teleirc/node_modules/node-icu-charset-detector
gyp ERR! node -v v5.1.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
Attempting to build on Debian Jessie with node installed from the node repository.
Currently there's plenty of paths such as process.env.HOME + '/.teleirc/files'
used in the source,
we should strive to replace all of these with eg. path.join(os.homedir(), '.teleirc', 'files')
so that teleirc can work on all platforms supported by node.js.
File paths to teleirc script does not match anymore after refactor
I'd suggest we replace all instances of console.log, console.error etc. with a proper logging library such as Winston. I'd prefer enabling coloring different log levels by default, and also having the log level configurable in our config file.
When the bot is configured with config.irc_relay_all = true;
all messages from IRC gets relayed, which is nice, but also if the bot quits and joins the network/channel it receives the channel topic and this gets forwarded to Telegram.
It would be nice to have an option to only forward user messages and not channel messages :)
I think our current api is quite limited. It is missing for example pic download. I made only short searching, found several of them. This atleast looks promising, and not too different so moving to it should be easy. https://www.npmjs.com/package/node-telegram-bot-api . I someone is not faster than I I can maybe do the job some day.
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.