Skip to content

Instantly share code, notes, and snippets.

@ItsOnlyBinary
Created September 9, 2020 14:45
Show Gist options
  • Save ItsOnlyBinary/9f8707d9a84906ce077e3283d9312e28 to your computer and use it in GitHub Desktop.
Save ItsOnlyBinary/9f8707d9a84906ce077e3283d9312e28 to your computer and use it in GitHub Desktop.
<script>
kiwi.plugin('ctcp_version', function(kiwi, log) {
kiwi.on('irc.ctcp request', function(event, network, ircEventObj) {
if (event.type !== 'VERSION') {
return;
}
// This adds a message to the server buffer for the request
let TextFormatting = kiwi.require('helpers/TextFormatting');
let serverTime = (event && event.time) || 0;
let eventTime = (event && event.time) ?
network.ircClient.network.timeToLocal(event.time) :
Date.now();
let buffer = network.bufferByName(event.target) || network.serverBuffer();
let messageBody = TextFormatting.formatText('ctcp_request', {
nick: event.nick,
message: event.message,
type: event.type,
});
kiwi.state.addMessage(buffer, {
time: eventTime,
server_time: serverTime,
nick: '',
message: messageBody,
type: 'error',
});
// This sends the reply
ircEventObj.handled = true;
network.ircClient.ctcpResponse(event.nick, 'VERSION', 'Kiwi IRC test');
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment