Update IRC bot
This commit is contained in:
@@ -18,7 +18,7 @@ export class IrcbotService {
|
|||||||
public readonly domainrProxy: DomainrproxyService,
|
public readonly domainrProxy: DomainrproxyService,
|
||||||
) {
|
) {
|
||||||
if (!this.configService.get<boolean>('irc.enabled')) return;
|
if (!this.configService.get<boolean>('irc.enabled')) return;
|
||||||
const nick = process.env.NODE_ENV === 'production' ? 'usbot' : 'usdev';
|
const nick = process.env.NODE_ENV === 'production' ? 'us-bot' : 'us-dev';
|
||||||
const ircPassword = this.configService.get<string>('irc.password');
|
const ircPassword = this.configService.get<string>('irc.password');
|
||||||
this.socket = connect({
|
this.socket = connect({
|
||||||
port: this.configService.get<number>('irc.port'),
|
port: this.configService.get<number>('irc.port'),
|
||||||
@@ -26,10 +26,11 @@ export class IrcbotService {
|
|||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
});
|
});
|
||||||
this.client = irc(this.socket);
|
this.client = irc(this.socket);
|
||||||
|
|
||||||
if (ircPassword) this.client.pass(ircPassword);
|
if (ircPassword) this.client.pass(ircPassword);
|
||||||
this.client.user(nick + 'login', `us.dev bot ${process.env.NODE_ENV}`);
|
this.client.user(nick, `us.dev bot ${process.env.NODE_ENV}`);
|
||||||
this.client.nick(nick + 'login');
|
this.client.nick(nick);
|
||||||
this.client.send('nickserv', `identify ${nick} ${ircPassword}`);
|
// this.client.send('nickserv', `identify ${nick} ${ircPassword}`);
|
||||||
console.log(nick);
|
console.log(nick);
|
||||||
const channel: string = this.configService.get<string>(
|
const channel: string = this.configService.get<string>(
|
||||||
'irc.channel',
|
'irc.channel',
|
||||||
@@ -39,16 +40,19 @@ export class IrcbotService {
|
|||||||
this.logger.verbose(`${channel} contains ${JSON.stringify(names)}`);
|
this.logger.verbose(`${channel} contains ${JSON.stringify(names)}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.client.on('errors', (event: any) => this.logger.error(event));
|
// this.client.on('errors', (event: any) => this.logger.error(event));
|
||||||
this.client.on('error', (event: any) => this.logger.error(event));
|
// this.client.on('error', (event: any) => this.logger.error(event));
|
||||||
this.client.on('notice', (event) => this.logger.verbose(event));
|
// this.client.on('notice', (event) => this.logger.verbose(event));
|
||||||
this.client.on('data', (event) => this.logger.verbose(event));
|
// this.client.on('data', (event) => this.logger.verbose('data', event));
|
||||||
|
// this.client.on('quit', console.log);
|
||||||
|
// this.client.on('mode', console.log);
|
||||||
|
|
||||||
this.client.on('message', async (message) => {
|
this.client.on('message', async (message) => {
|
||||||
if (message.to !== channel) return;
|
if (message.to !== channel) return;
|
||||||
if (message.message[0] !== this.prefix) return;
|
if (message.message[0] !== this.prefix) return;
|
||||||
|
|
||||||
const [command, ...args] = message.message.substring(1).split(' ');
|
const [command, ...args] = message.message.substring(1).split(' ');
|
||||||
|
this.logger.verbose(`${command} in ${message.to}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
|
Reference in New Issue
Block a user