-
-
Notifications
You must be signed in to change notification settings - Fork 4
Scripting
Велимир Мајсторов edited this page Feb 13, 2026
·
1 revision
AndroidIRCX includes a built-in JavaScript scripting engine.
This page follows the in-app Scripting Help content and documents hooks, API, examples, and usage tips.
Scripts are plain JavaScript modules. Export hooks to react to events:
module.exports = {
onConnect: (networkId) => { /* ... */ },
onDisconnect: (networkId, reason) => { /* ... */ },
onMessage: (msg) => { /* msg.channel, msg.from, msg.text */ },
onNotice: (msg) => { /* notice messages */ },
onJoin: (channel, nick, msg) => { /* ... */ },
onPart: (channel, nick, reason, msg) => { /* ... */ },
onQuit: (nick, reason, msg) => { /* ... */ },
onNickChange: (oldNick, newNick, msg) => { /* ... */ },
onKick: (channel, kickedNick, kickerNick, reason, msg) => { /* ... */ },
onMode: (channel, setterNick, mode, target, msg) => { /* ... */ },
onTopic: (channel, topic, setterNick, msg) => { /* ... */ },
onInvite: (channel, inviterNick, msg) => { /* ... */ },
onCTCP: (type, from, text, msg) => { /* ... */ },
onRaw: (line, direction, msg) => { /* return modified line or { cancel: true } */ },
onCommand: (text, ctx) => { /* return newText or { cancel: true } */ },
onTimer: (name) => { /* timer fired */ },
};-
api.log(text)- log to script log buffer api.sendMessage(channel, text, networkId?)api.sendCommand(command, networkId?)api.sendNotice(target, text, networkId?)api.sendCTCP(target, type, params?, networkId?)-
api.getChannelUsers(channel, networkId?)- returnsstring[] -
api.getChannels(networkId?)- returnsstring[] -
api.setTimer(name, delayMs, repeat?)- set timer -
api.clearTimer(name)- clear timer -
api.getNetworkId()- current network ID -
api.isConnected(networkId?)- check connection -
api.userNick- current nick -
api.getConfig()- script config JSON
-
onConnect(networkId)- when connected -
onDisconnect(networkId, reason?)- when disconnected
-
onMessage(msg)- channel/query messages -
onNotice(msg)- notice messages -
onCTCP(type, from, text, msg)- CTCP requests
-
onJoin(channel, nick, msg)- user joined -
onPart(channel, nick, reason, msg)- user parted -
onQuit(nick, reason, msg)- user quit -
onNickChange(oldNick, newNick, msg)- nick changed -
onKick(channel, kickedNick, kickerNick, reason, msg)- user kicked -
onMode(channel, setterNick, mode, target?, msg)- mode changed -
onTopic(channel, topic, setterNick, msg)- topic changed -
onInvite(channel, inviterNick, msg)- channel invite
-
onRaw(line, direction, msg?)- raw IRC line (in/out) -
onCommand(text, ctx)- outgoing command -
onTimer(name)- timer fired
module.exports = {
onJoin: (channel, nick, msg) => {
if (nick === api.userNick) return;
api.sendCommand('MODE ' + channel + ' +o ' + nick);
},
};module.exports = {
onJoin: (channel, nick) => {
api.sendMessage(channel, 'Welcome, ' + nick + '!');
},
};module.exports = {
onCommand: (text) => {
if (text.startsWith('/hello')) return '/say Hello there!';
return text;
},
};module.exports = {
onCTCP: (type, from, text) => {
if (type === 'VERSION') {
api.sendCTCP(from, 'VERSION', 'AndroidIRCX');
}
},
};module.exports = {
onConnect: () => {
api.setTimer('periodic', 60000, true); // every 60s
},
onTimer: (name) => {
if (name === 'periodic') {
api.log('Timer fired!');
}
},
onDisconnect: () => {
api.clearTimer('periodic');
},
};module.exports = {
onKick: (channel, kickedNick, kickerNick, reason) => {
if (kickedNick === api.userNick) {
api.sendCommand('JOIN ' + channel);
}
},
};- Scripts are disabled by default; enable each one.
- Use Lint to catch syntax errors.
- Enable logging to see script output/errors in the log tab.
-
onCommandcan cancel send by returning{ cancel: true }. -
onRawcan modify or cancel raw IRC lines. - Use timers for periodic tasks; clear them on disconnect.
- Check
api.isConnected()before sending commands.
- Open
Settings. - Go to
Scripting & Ads. - Open
Scripts (Scripting Time & No-Ads). - Add/edit scripts and enable them.
- Use
Script Logsto inspect output and errors.
AndroidIRCX — Modern IRC client with IRCv3, ZNC support and end-to-end encryption.
🔗 Website: https://androidircx.com
📱 Google Play: https://play.google.com/store/apps/details?id=com.androidircx
💻 Source code: https://github.com/AndroidIRCX/AndroidIRCX
© AndroidIRCX Project