Comments (10)
rewrite the line according to whether you want to use cli or discord.
Line 28 in a2c1427
Line 27 in a2c1427
let ircClient = new irc.Client(c.server, c.nick, { port: 6667, password: "your password" });
or
c.opt.password = "your password";
let ircClient = new irc.Client(c.server, c.nick, c.opt);
from osu-ahr.
yep, but you can ignore trial files.
trial is used to check the behavior of the program and is not used in normal operation.
from osu-ahr.
thank you!
for discord token though I put my discord token directly here by replacing this.cfg.token
osu-ahr/src/discord/DiscordBot.ts
Line 84 in e5d328c
- await this.discordClient.login(this.cfg.token);
+ await this.discordClient.login('MyStringToken');
and here
https://github.com/Meowhal/osu-ahr/blob/199a661afc4938160b2fd9537e48d4fc87081e6d/src/trials/AppendersTrial.ts#L55
is that alright or can that be done better?
from osu-ahr.
for discord token though I put my discord token directly here by replacing this.cfg.token in between the ()
Just make sure to not share your discord token by pushing to your fork by adding it to .gitignore.
from osu-ahr.
c.opt.password = "your password"; let ircClient = new irc.Client(c.server, c.nick, c.opt);
using that ^, one gives an error. the first one works, i just tried this 2nd one and found out it doesn't work.
> [email protected] start:discord > ts-node src/discord/index.ts starting up... [22:23:57.955][ERROR] cli - TypeError: Cannot assign to read only property 'password' of object '#<Object>' at Object.<anonymous> (/home/runner/ahr/src/discord/index.ts:29:19) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Module.m._compile (/home/runner/ahr/node_modules/ts-node/src/index.ts:1365:23) at Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Object.require.extensions.<computed> [as .ts] (/home/runner/ahr/node_modules/ts-node/src/index.ts:1368:12) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) at main (/home/runner/ahr/node_modules/ts-node/src/bin.ts:331:12) at Object.<anonymous> (/home/runner/ahr/node_modules/ts-node/src/bin.ts:482:3)
IIrcConfig
is interface not class so it need to be implemented before usage. Create IrcConfig
and ClientOpts
class first in TypedConfig.ts
export class ClientOpts implements IClientOpts {
}
export class IrcConfig implements IIrcConfig {
server: string;
nick: string;
opt: IClientOpts;
constructor(server: string, nick: string, opt: ClientOpts){
this.server = server;
this.nick = nick;
this.opt = opt;
}
}
then create the object in the index.ts
var cOpt : ClientOpts = {port: 6667,password: "yourPassword"};
var c = new IrcConfig("irc.ppy.sh","YourNickname",cOpt);
from osu-ahr.
yes that's the one, var c
that I mentioned above should be used with const c = getIrcConfig();
commented out
from osu-ahr.
oooh! so with that it's supposed to look like
import { Client, Intents } from "discord.js";
import log4js from "log4js";
import { DiscordBot } from './DiscordBot';
import { logIrcEvent } from "..";
import * as irc from '../libs/irc';
- import { getIrcConfig } from "../TypedConfig";
+ import { ClientOpts, IrcConfig } from "../TypedConfig";
import { logPrivateMessage } from '../IIrcClient';
import { applySpeedLimit } from "../libs/ChatLimiter";
const logger = log4js.getLogger("cli");
console.log("starting up...");
const config_path = "./config/log_discord.json";
try {
log4js.configure(config_path);
- const c = getIrcConfig();
+ var cOpt: ClientOpts = {port: 6667,password: "yourPassword"};
+ var c = new IrcConfig("irc.ppy.sh","YourNickname",cOpt);
if (c.nick == "your account id" || c.opt.password == "you can get password from 'https://osu.ppy.sh/p/irc'") {
logger.error("you must enter your account name and irc password in the config file. ");
logger.error("you can get the password from 'https://osu.ppy.sh/p/irc' ");
logger.error("Copy config/default.json to config/local.json, and enter your id and irc password.");
process.exit(1);
}
let ircClient = new irc.Client(c.server, c.nick, c.opt);
ircClient.on("error", err => {
if (err.command == "err_passwdmismatch") {
logger.error('%s: %s', err.command, err.args.join(' '));
logger.error("check your account id and password.");
process.exit(1);
}
});
applySpeedLimit(ircClient, 10, 5000);
logIrcEvent(ircClient);
logPrivateMessage(ircClient);
let discordClient = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_INTEGRATIONS] });
const bot = new DiscordBot(ircClient, discordClient);
bot.start();
} catch (e: any) {
logger.error(e);
process.exit(1);
}
thank you so much for your time! have a good day, y'all amazing for making this awesome bot, looking forward towards its improvement!
from osu-ahr.
Just make sure that index.ts
doesn't get commited to your public repository because your IRC credential is there now. You can create another index file like index-local.ts
then on package.json
change this line "start:discord": "ts-node src/discord/index.ts",
to "start:discord": "ts-node src/discord/index-local.ts",
then add the path to gitignore.
from osu-ahr.
or
c.opt.password = "your password"; let ircClient = new irc.Client(c.server, c.nick, c.opt);
the first implementation works. trying that second implementation however gives an error, i had just found out that the second implementation doesn't work.
> osu-ahr@1.5.13 start:discord
> ts-node src/discord/index.ts
starting up...
[22:23:57.955][ERROR] cli - TypeError: Cannot assign to read only property 'password' of object '#<Object>'
at Object.<anonymous> (/home/runner/ahr/src/discord/index.ts:29:19)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (/home/runner/ahr/node_modules/ts-node/src/index.ts:1365:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/home/runner/ahr/node_modules/ts-node/src/index.ts:1368:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at main (/home/runner/ahr/node_modules/ts-node/src/bin.ts:331:12)
at Object.<anonymous> (/home/runner/ahr/node_modules/ts-node/src/bin.ts:482:3)
from osu-ahr.
IIrcConfig is interface not class so it need to be implemented before usage.
i did what you suggested on TypedConfig
but
i was not sure where or how to put those var in src/discord/index.ts
,
so here are the things i changed in src/discord/index.ts
Line 19 in a2c1427
const c = getIrcConfig();
+ var cOpt: ClientOpts = {port: 6667,password: "yourPassword"};
+ var c = new IrcConfig("irc.ppy.sh","YourNickname",cOpt);
i ran the bot.
i got a compilation error on console that ClientOpts
and IrcConfig
can't be found.
TSError: ⨯ Unable to compile TypeScript:
src/discord/index.ts:11:12 - error TS2304: Cannot find name 'ClientOpts'.
src/discord/index.ts:12:13 - error TS2304: Cannot find name 'IrcConfig'.
so...
Line 5 in a2c1427
- import { getIrcConfig } from "../TypedConfig";
+ import { ClientOpts, IrcConfig } from "../TypedConfig";
I attempted to run it again with another error.
Cannot initialize outer scoped variable 'c' in the same scope as block scoped declaration 'c'.
so...
Line 19 in a2c1427
- const c = getIrcConfig();
var cOpt : ClientOpts = {port: 6667,password: "yourPassword"};
var c = new IrcConfig("irc.ppy.sh","YourNickname",cOpt);
i attempted to run it again. this time it worked.
did I do it right or did I do something wrong and it wasn't supposed to be done like that?
from osu-ahr.
Related Issues (20)
- Node.js @Lobby#raiseNetError getaddrinfo ENOTFOUND HOT 2
- (Deleted)
- Discord BOT HOT 2
- SyntaxError: Unexpected token , in JSON at position 145 HOT 3
- DISCORD BOT not responding to commands HOT 2
- discord token != empty HOT 2
- DM spamming HOT 3
- is it possible? If so, how? HOT 4
- reason? HOT 2
- Suggestion: Blacklist Maps Function
- I cant get the thing to start. HOT 3
- Help HOT 1
- please help what is an irc password? HOT 11
- when i start the git bash the console throw me this please help HOT 2
- Can't start the bot HOT 1
- hostkick_tolerance kinda unusable
- Add Chat Gpt Support
- Command HOT 1
- Disable LobbyTerminator HOT 1
- discord: use channel ids instead of creating channels
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osu-ahr.