Fix irc bot auth
This commit is contained in:
@@ -27,6 +27,6 @@ import { IrcbotService } from './ircbot/ircbot.service';
|
|||||||
IrcbotModule,
|
IrcbotModule,
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [AppService, IrcbotService],
|
providers: [AppService],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
@@ -9,5 +9,6 @@ export default () => ({
|
|||||||
tls: process.env.IRC_TLS === 'true',
|
tls: process.env.IRC_TLS === 'true',
|
||||||
port: parseInt(process.env.IRC_PORT ?? '6697'),
|
port: parseInt(process.env.IRC_PORT ?? '6697'),
|
||||||
channel: process.env.IRC_CHANNEL ?? '#usdev',
|
channel: process.env.IRC_CHANNEL ?? '#usdev',
|
||||||
|
password: process.env.IRC_PASSWORD ?? '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@@ -4,6 +4,5 @@ import { DomainrproxyService } from 'src/domainrproxy/domainrproxy.service';
|
|||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
providers: [IrcbotService, DomainrproxyService],
|
providers: [IrcbotService, DomainrproxyService],
|
||||||
exports: [IrcbotService],
|
|
||||||
})
|
})
|
||||||
export class IrcbotModule {}
|
export class IrcbotModule {}
|
||||||
|
@@ -18,14 +18,19 @@ 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 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'),
|
||||||
host: this.configService.get<string>('irc.server'),
|
host: this.configService.get<string>('irc.server'),
|
||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
});
|
});
|
||||||
this.client = irc(this.socket);
|
this.client = irc(this.socket);
|
||||||
this.client.nick(process.env.NODE_ENV === 'production' ? 'usbot' : 'usdev');
|
if (ircPassword) this.client.pass(ircPassword);
|
||||||
this.client.user('usbot', 'usbot');
|
this.client.user(nick + 'login', `us.dev bot ${process.env.NODE_ENV}`);
|
||||||
|
this.client.nick(nick + 'login');
|
||||||
|
this.client.send('nickserv', `identify ${nick} ${ircPassword}`);
|
||||||
|
console.log(nick);
|
||||||
const channel: string = this.configService.get<string>(
|
const channel: string = this.configService.get<string>(
|
||||||
'irc.channel',
|
'irc.channel',
|
||||||
) as string;
|
) as string;
|
||||||
@@ -34,15 +39,13 @@ export class IrcbotService {
|
|||||||
this.logger.verbose(`${channel} contains ${JSON.stringify(names)}`);
|
this.logger.verbose(`${channel} contains ${JSON.stringify(names)}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.client.on('errors', this.logger.error);
|
|
||||||
|
|
||||||
this.client.on('message', async (message) => {
|
this.client.on('message', async (message) => {
|
||||||
console.log(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(' ');
|
||||||
|
|
||||||
|
try {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 'domain':
|
case 'domain':
|
||||||
const domain = args[0];
|
const domain = args[0];
|
||||||
@@ -56,6 +59,7 @@ export class IrcbotService {
|
|||||||
this.client.send(channel, `Dunno what ${command} means`);
|
this.client.send(channel, `Dunno what ${command} means`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} catch {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user