79 lines
1.5 KiB
TypeScript
79 lines
1.5 KiB
TypeScript
import { IRCBot } from '../bot';
|
|
import { NickServValidator } from '../utility/nickserv-validator';
|
|
|
|
const bot = new IRCBot({
|
|
host: 'icynet.eu',
|
|
nick: 'MyTestBot',
|
|
channels: ['#squeebot'],
|
|
nickserv: {
|
|
enabled: true,
|
|
command: 'STATUS',
|
|
},
|
|
});
|
|
|
|
const nickserv = new NickServValidator(bot);
|
|
|
|
bot.on('authenticated', () => {
|
|
console.log('Successful connection!');
|
|
});
|
|
|
|
bot.on('server-supports', (supported) => {
|
|
console.log(supported);
|
|
});
|
|
|
|
bot.on('supported-modes', (supported) => {
|
|
console.log(supported);
|
|
});
|
|
|
|
// bot.on('line', console.log);
|
|
|
|
bot.on('message', ({ message, to, nickname }) => {
|
|
console.log(`[${to}] ${nickname}: ${message}`);
|
|
|
|
if (message.startsWith('!test')) {
|
|
nickserv
|
|
.getNickStatus(nickname)
|
|
.then((valid) =>
|
|
bot.send(
|
|
to,
|
|
`Hello, %s! ${
|
|
valid ? 'You are logged in.' : 'You are not logged in.'
|
|
}`,
|
|
nickname,
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
|
|
if (message.startsWith('!whois')) {
|
|
bot.whois(nickname).then(console.log);
|
|
return;
|
|
}
|
|
|
|
if (message.startsWith('!who')) {
|
|
bot.who(to).then(console.log);
|
|
return;
|
|
}
|
|
|
|
if (message.startsWith('!names')) {
|
|
bot.names(to).then(console.log);
|
|
return;
|
|
}
|
|
|
|
if (message.startsWith('!list')) {
|
|
bot.list().then(console.log);
|
|
return;
|
|
}
|
|
|
|
if (message.startsWith('!ping')) {
|
|
bot.getPing().then((res) => bot.send(to, `Pong: ${res / 1000}s`));
|
|
return;
|
|
}
|
|
});
|
|
|
|
bot.on('disconnect', console.log);
|
|
|
|
bot.on('names', console.log);
|
|
|
|
bot.connect();
|