Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Accessing IrcBot from a script #23

hferentschik opened this Issue · 5 comments

4 participants



more of a question really, but how would I go about if I want to write a custom script and want to access the bot variable defined in the Is that possible?


Good question. I am wondering something similar, I need to send raw Irc commands from my Hubot. Is that possible?


Well, the hubot (hubot-irc) has a reference to the Irc module as the .bot property.

I'm not sure what exactly your use case is, but I would probably approach this as a script.

This explanation of Hubot Scripts shows that you get a reference to the hubot from your script initialization. You could check for the presence of and that it was of type Irc; something like this (this exact code probably won't work)


module.exports = (robot) ->
  return unless typeof is "IrcClient"

  robot.respond /hi|hello/i, (msg) ->
    # Send some IRC command...

Hope that helps, if not, please give some examples of what you've tried and what your use case is.


I have found that you can access the irc 'bot' via

module.exports = (robot) ->

So now the issue for me is sending raw commands such as MODE. We have a private internal IRC server and our bots control operators with on an old java framework. I would like to have my irc hubot send the MODE command to add operator mode to a given user. I have tried modifying the adapter and playing around even with the node-irc package to no avail. Here is one example of something that didnt work from within the irc hubot adapter

mode: () ->
    @bot.emit 'raw',
       command: 'MODE'
       nick: process.env.HUBOT_IRC_NICK
       args: ["#myroom", "+o", "myuser"]

Something like that seems like it should work when calling it like:

module.exports = (robot) ->

Function gets called as you would expect, but mode does not change. Maybe an expert here can comment. Cheers


Here is a simple hubot script that grants OP to anyone that asks hubot for it - no need to edit

module.exports = (robot) ->
  robot.respond /op me/i, (msg) ->
    robot.adapter.command('MODE',, '+o',;

Awesome find nmcclain! I could have sworn I tried that, but I must have missed it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.