Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Support TLS connections and custom ports (#41)
Browse files Browse the repository at this point in the history
* Add optional port and tls properties to config schema

* Add discordUsername to default IRC text formatting

* Add TLS and port configuration support to bot

* Remove console.log call on quit event

* Add TLS and port configuration to README example
  • Loading branch information
aronson authored Oct 10, 2023
1 parent 95b459e commit a03acd2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ First you need to create a Discord bot user, which you can do by following the i
{
"nickname": "test",
"server": "irc.bottest.org",
"port": 6697,
"tls": true,
"discordToken": "botwantsin123",
"autoSendCommands": [
// Commands that will be sent on connect
Expand Down
4 changes: 2 additions & 2 deletions lib/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default class Bot {
// displayUsername: nickname with wrapped colors
// attachmentURL: the URL of the attachment (only applicable in formatURLAttachment)
this.formatIRCText = config.format?.ircText ||
'<{$displayUsername}> {$text}';
'<{$displayUsername} [@{$discordUsername}]> {$text}';
this.formatURLAttachment = config.format?.urlAttachment ||
'<{$displayUsername}> {$attachmentURL}';

Expand Down Expand Up @@ -152,7 +152,7 @@ export default class Bot {
this.channelMapping = await ChannelMapper.CreateAsync(this.config, this, this.discord);

this.attachIrcListeners();
await this.ircClient.connect(this.config.server);
await this.ircClient.connect(this.config.server, this.config.port, this.config.tls);
this.channelMapping.ircNameToMapping.forEach((entry) => {
this.logger.info(`Joining channel ${entry.ircChannel}`);
this.ircClient.join(entry.ircChannel);
Expand Down
4 changes: 4 additions & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export type IgnoreConfig = {

export type Config = {
server: string;
port?: number;
tls?: boolean;
nickname: string;
discordToken: string;
channelMapping: Dictionary<string>;
Expand Down Expand Up @@ -94,6 +96,8 @@ export const IgnoreConfigSchema = z.object({

export const ConfigSchema = z.object({
server: z.string(),
port: z.number().optional(),
tls: z.boolean().optional(),
nickname: z.string(),
discordToken: z.string(),
channelMapping: z.record(z.string()),
Expand Down
2 changes: 0 additions & 2 deletions lib/ircListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ export function createIrcQuitListener(bot: Bot) {
`*${nick}* has quit (${reason})`,
);
});
console.log('quit');
console.log(event);
};
}

Expand Down

0 comments on commit a03acd2

Please sign in to comment.