Giter VIP home page Giter VIP logo

teleirc's Introduction

NOTE: no longer maintained, look for alternatives such as: https://github.com/42wim/matterbridge

Logo

A simple Telegram ↔ IRC gateway.

Build Status npm module dependencies devDependencies

Features:

  • Supports multiple IRC channel ↔ Telegram group pairs
  • Telegram messages are always relayed to their respective IRC channel
  • IRC messages can be configured either to be relayed always, or only when the bot is hilighted via a configurable regexp
  • Supports Telegram media files, URL to file sent to IRC

Requirements

On Ubuntu:

sudo apt-get install libicu-dev

Quick start

Make sure you've installed the latest LTS version of Node.js.

  1. Install the teleirc npm module with npm install -g teleirc (might need sudo)
  2. Generate a default config using teleirc --genconfig NOTE: if this step fails, try mkdir ~/.teleirc and run the command again (FIXME).
  3. Set up your bot with BotFather
  4. Use the /setprivacy command with BotFather to allow your bot to see all messages in your group (NOTE on usage: bot name is preceded by @ sign and 'Disable' is case-sensitive)
  5. Edit the default config $EDITOR ~/.teleirc/config.js
  6. Run teleirc
  7. Invite your bot to any Telegram groups you've configured it for
  8. Greet your bot once on each of your Telegram groups 🎉! This is needed to fetch (and store!) an internally used group ID, making communication from IRC to the correct Telegram group possible.

Optional:

  • For your convenience, there is an included systemd unit file: teleirc.service
  • You can change your Telegram Bot's profile picture with the /setuserpic BotFather command. Here's an example icon for you.
  • You can tell Telegram which commands the teleirc bot supports by using the /setcommands BotFather command. You may copy-paste the contents of commands.txt to show all supported commands to Telegram clients.
  • Instead of enabling the HTTP server for serving sent media files, photo files sent to the groups can be uploaded to Imgur. See the README for Imgur for more information.

Troubleshooting

  1. Check your system clock. By default if a Telegram message's timestamp is older than one minute compared to your system clock, the message is skipped. You can configure this behaviour via config.maxMsgAge.
  2. Make sure your Telegram group's name and IRC channel has been entered correctly in your config (case sensitive!)
  3. Run with verbose flags to see more output: teleirc -vvv

Contributing

See CONTRIBUTING.md for developer info

Docker install

See the README for Docker

teleirc's People

Contributors

adedomin avatar albert-- avatar bysmyyr avatar fruitiex avatar janil avatar joshua1337 avatar jppcel avatar mariogrip avatar mikaela avatar neuro-sys avatar nikeee avatar ostpavel avatar pcchou avatar pmac avatar rennex avatar richrd avatar rittmeier avatar surye avatar themiron avatar thenets avatar tuupertunut avatar varal7 avatar warbaque avatar zertrin 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  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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

teleirc's Issues

Build fails at node-icu-charset-detector

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.

Loadable modules

It would be nice to eventually have a loadable module system similar to ZNC, for features that don't belong in core teleirc.

How to send Botcommands?

Hej,
It is possible to send botcommand like "!bla" to send from Telegram to irc without "< Nick >"
relay all is true in config

Use platform agnostic file paths in teleirc

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.

It works!

Ignore this issue, it's just for testing a GitHub web hook. :)

I can't find out how to create ~/.teleirc/chat_ids

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.

Improved arguments handling + custom configs

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.

Messages to Telegram not sent

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)

SASL support

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?

Better log output

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.

Teleirc highlight identical usernames on IRC

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?

Upgrading to a supergroup doesn't update chat_id file

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).

Don't add @ to my own messages from IRC to Telegram & possibly allow configuring if the @ is added to messages from anyone else.

If my nickname is Mikaela on IRC and Telegram, every time I write from IRC, Telegram alerts about @Mikaela being mentioned.

I think that

  1. the @ shouldn't be prepended to messages the user sends by themselves to avoid Telegram notification.
  2. there should be option for whether to automatically add the @ to messages other people send including the Telegram username or not.
    • I think this is generally desirable as usually people from IRC don't know to add the @ 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.

Command for showing the current version (including git commit) possibly also the latest released version

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.

README could use clearer example on how to get teleIRC running as a background process

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.

Suggested fixes:

  1. It's probably an unclear documentation issue. Add something to the README to indicate the right parameters for running the bridge in silent mode (would also be useful, even if this isn't the issue).
  2. Change the teleirc.service to be FreeBSD-compatible, or have a teleirc.BSD.service file for that purpose

Problems with sending IRC commands on connect?

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' ] }

Host Image files that were attached as "File"

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".

screen shot 2016-02-19 at 9 42 09 am

Steps to reproduce

  • on a Telegram group with a teleirc bot configured to host images, post an image using the option "Photo or Video"
  • on that same group, post the same image using the option "File"

Expected results

IRC users see links for both images

Actual results

IRC users see the first link, but on the second one they see "(Document)"

Telegram -> IRC message relaying stops

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.

Development: Sending pic when irc is not initialized crash

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)       

Is there anyway to see who's on IRC

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.

Got jammed sometimes

This happens 1-5 times per week. Needs manual restart.

Possibly unhandled StatusCodeError: 504 -

<title>504 Gateway Time-out</title>

504 Gateway Time-out


nginx/1.9.1
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>

504 Gateway Time-out


nginx/1.9.1
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)

option for not relaying topic messages

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 :)

screenshot:
screen shot 2015-10-23 at 8 50 35 pm

<username>: undefined sent to IRC when changing group pic

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

Flood protection to IRC-side

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.

The issue with bot api display names and irc nick names.

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

IRC Perform

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

One Telegram group won't link to two IRC channels nicely

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.

Telegram & IRC handling code should be self-contained

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.

Telegram -> IRC messages not sent

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?

Ignore nickname or ignore using regex

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.

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.