Item has a rating of 5 (Liked by Chris Graham)
#5996 (In Topic #1431)
Standard member
jacobgkau is in the usergroup ‘Well-settled’

2-way chat bridge between Composr and IRC

Greetings! I wasn't sure if this should go in Deploying or Developing, but I made it in the process of deploying, so I'm sticking it here.

I love Composr's built-in chat system. It was one of the things that drew me toward ocPortal/Composr in the first place. It doesn't require any client-side plugins, the authentication is integrated with the rest of the website, and the default logging works perfectly for my needs.

On my website, I have a Composr chat room that I use to interact with live viewers during video streams. I don't only stream to my website, however; I multi-stream to Twitch, Mixer, and several other platforms. This gives me a wider potential audience, but it also has the effect of splitting my audience between several different chat rooms. To rectify this, I have set up an IRC server to use as a relay, and am standing up bridges between that IRC server and all of the individual chat rooms.

Hence, OcIrcBridge is a command-line Java application that will forward messages between a Composr chat room and an IRC channel! It's a little rough around the edges (I'm an operations/administration guy, not a developer), but it's working great so far. Here are some of the key points:
  • The Composr-side listener continuously polls your MySQL/MariaDB database and checks for any new messages. When it sees new messages, it forwards them to IRC via the PircBotX library.
    • This means you will need to set up a MySQL user for OcIrcBot, with read-only access to your Composr chat messages table.
  • The IRC-side listener (PircBotX) fires events when new messages are received. Upon receipt, they are forwarded to Composr via an authenticated HTTP POST request.
    • This means you will need to create an account on your Composr website for OcIrcBot; the bot also requires the use of TLS (as the HTTPS protocol is hardcoded.)
Despite being written in Java, the bot is fairly lightweight. I am running several of these Java apps along with an entirely separate RocketChat instance on a $5/month DigitalOcean droplet (1GB RAM, 1 CPU core) and have not had any performance issues yet, although my volume is relatively low right now. (The whole system will be getting a great workout later this year.)

One of the biggest challenges was that the Composr web session would expire after a certain amount of inactivity, causing forwarded messages to show up as "guest posts" in the Composr chat room (which I haven't figured out how to disable entirely yet without affecting view permissions.) To get around this, the bot checks if it is still logged into Composr every time it sends a message. If it is still logged in, it will forward the message right away; if it's not logged in, it will re-login before forwarding the message. This is probably the clunkiest part of the program right now (and it does add a little more delay in forwarding), but it allows the bot to function indefinitely without having to manually restart the program, and it's still faster than re-logging every time a message is forwarded.

Composr, IRC, and chat bridges are all fairly niche, so I'm not sure if anyone else will have a use for this, but I wanted to put it out there just in case anyone was looking for something like this. The source code is on GitLab as well as GitHub, and compiled releases are hosted on GitHub for now.
Online now: No Back to the top


Site director
Chris Graham is in the usergroup ‘Administrators’
That's really cool.

FYI systems integrating with Composr should be able to log in using regular HTTP authentication to establish their session. i.e. you don't need to simulate any kind of login via a web form, just submit HTTP authentication headers.

Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top
1 guest and 0 members have just viewed this.


Users online:

Vaiva, babu, MVLipwig, John Connor, deepu_ms, Paul D, Manu, gabriel58

Forum statistics:
  • 1,339 topics, 5,886 posts, 7,196 members
  • Our newest member is clicksbazaar
Back to Top