Skip to content

Commit 753474e

Browse files
committed
refactor: Changes
- Started the migration to TwichJs - From original pre-alpha TMI (Twitch Messenging Interface) - This starts new pre_alpha v2.0.0 release v0.0.1.pre_alpha.2.0.0
1 parent 4e8d582 commit 753474e

File tree

625 files changed

+8591
-85152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

625 files changed

+8591
-85152
lines changed

.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// https://stackoverflow.com/questions/41292559/could-not-find-a-declaration-file-for-module-module-name-path-to-module-nam
22
// declare module '*'; The benefit (and downside) of this is that you can import absolutely anything and TS will compile.
3-
declare module 'tmi.js';
4-
declare module 'tmi.js'
3+
//declare module 'tmi.js';
4+
//declare module 'tmi.js'

WaldyBotTwitch.js

Lines changed: 74 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Imported Node Modules
2-
const tmi = require('tmi.js'); //Twitch Messaging Interface https://docs.tmijs.org/
3-
var client = new tmi.client(ClientOptions);
2+
const TwitchJs = require('twitch-js').default; // TwitchJS https://twitch-apis.github.io/twitch-js/docs/getting-started
3+
//const tmi = require('tmi.js'); //Twitch Messaging Interface https://docs.tmijs.org/ // TMI REDO
4+
//var client = new tmi.client(ClientOptions); // TMI REDO
45
var fs = require('fs');
56
var globalVarsObjs = require('./Objects/GlobalVarsObjects.js');
67
var testAuthNotCommited = require('./testauth.js');
@@ -9,6 +10,7 @@ var testAuthNotCommited = require('./testauth.js');
910
var commandPrefix = 'w';
1011

1112
// TMI Module's Options Object (Passed into the new client var.)
13+
// TMI REDO
1214
var ClientOptions = {
1315
options: {
1416
debug: true
@@ -22,7 +24,7 @@ var ClientOptions = {
2224
username: "waldybot", // <-- YOUR account's username (String). See Objects/Media Storage/bot account username how to.png.
2325
// Default: Use globalVarsObjs.authenticationObject.authToken
2426
// IF still commited as my local enviroment. Setup for default as follows:
25-
// Overwrite: testAuthNotCommited.testerTwitchTokenO bject.TestTwitchOAuth With: globalVarsObjs.authenticationObject.authToken
27+
// Overwrite: testAuthNotCommited.testerTwitchTokenObject.TestTwitchOAuth With: globalVarsObjs.authenticationObject.authToken
2628
password: testAuthNotCommited.testerTwitchTokenObject.TestTwitchOAuth // <-- OAuth password. See Objects/Auth.js for detailed instructions on key generation + Auth.js setup.
2729
},
2830
channels: ["carc1nogen", "hdbeasta", "#hdbeasta", "#HDBeasta"]
@@ -35,14 +37,30 @@ var ClientOptions = {
3537
// Go here for a reference to the userstate object. Which is a chat users info. https://docs.tmijs.org/v1.2.1/Events.html#chat
3638

3739

38-
// makin a edit
39-
4040
// Global Vars
4141
var packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
4242
var waldyBotVersion = packageJson["version"];
4343

44+
var TwitchJsClient = new TwitchJs({ twitchPassword, twitchUserName });
45+
var twitchUserName = 'waldybot'; // <-- YOUR account's username (String). See Objects/Media Storage/bot account username how to.png.
46+
// Default: Use globalVarsObjs.authenticationObject.authToken
47+
// IF still commited as my local enviroment. Setup as follows:
48+
// Overwrite: testAuthNotCommited.testerTwitchTokenObject.TestTwitchOAuth
49+
// With: globalVarsObjs.authenticationObject.authToken
50+
var twitchPassword = testAuthNotCommited.testerTwitchTokenObject.TestTwitchOAuth; // <-- OAuth password.
51+
// See Objects/Auth.js for detailed instructions on key generation + Auth.js setup.
52+
var twitchChannels = {
53+
channels: ["carc1nogen", "hdbeasta", "#hdbeasta", "#HDBeasta"] // <-- YOUR twitch channels you want to connect to. Overwite/add your channels here.
54+
}
55+
var { api, chatConstants } = TwitchJsClient;
56+
var { chat } = TwitchJsClient;
57+
58+
59+
// Global Objects
60+
4461

4562
// Startup
63+
// TMI REDO
4664
client.on('connected', (addr, port) => {
4765
// On chat connection. Msgs logged to console:
4866
console.log('Address:' + addr); // Connected address
@@ -62,41 +80,7 @@ client.on('connected', (addr, port) => {
6280
// Event Handlers:
6381
// Note: Registers the event handlers. (Defined Below)
6482

65-
//client.on("action", function (channel, userstate, message, self) { // placeholder
66-
// Received action message on channel. (/me <message>)
67-
// if (self) return; // Ignores bot's own messages.
68-
//});
69-
70-
/*client.on('message', (target, context, msg, self) => {
71-
// Called when chat message comes in.
72-
if(self) { return } // Ignore messages from the bot
73-
// This isn't a command since it has no prefix:
74-
if(msg.substr(0, 1) !== commandPrefix) {
75-
console.log(`[${target} (${context['message-type']})] ${context.username}: ${msg}`)
76-
return
77-
}
78-
}); // Channel Message Event Handler. placeholder */
79-
80-
/*client.on("message", function (channel, userstate, message, self) {
81-
if (self) return; // Ignore messages from the bot
82-
83-
// Handle different message types..
84-
switch(userstate["message-type"]) {
85-
case "action":
86-
// This is an action message..
87-
break;
88-
case "chat":
89-
// This is a chat message..
90-
break;
91-
case "whisper":
92-
// This is a whisper..
93-
break;
94-
default:
95-
// Something else ?
96-
break;
97-
}
98-
}); // placeholder */
99-
83+
// TMI REDO
10084
client.on("chat", function (channel, userstate, message, self) { //in progress
10185
if(self) return; // Ignores bot msgs
10286
//if(message.substr(0, 1) === commandPrefix) {
@@ -109,19 +93,66 @@ client.on("chat", function (channel, userstate, message, self) { //in progress
10993
client.action(channel = "carc1nogen", userstate['username'] + " fuck you");
11094
client.action(channel = "hdbeasta", userstate['username'] + " fuck you");
11195
});
112-
//
96+
11397

11498
// TESTTEST
99+
// Get featured streams.
100+
api.get('streams/featured').then(response => {
101+
console.log(response)
102+
})
103+
// Listen to all events.
104+
const log = msg => console.log(msg)
105+
chat.on(chatConstants.EVENTS.ALL, log)
106+
107+
108+
109+
// TMI REDO
115110
client.on("ping", function () {
116111
console.log('ping');
117112
});
113+
// TMI REDO
118114
client.on("pong", function (latency) {
119115
console.log('pong');
120116
});
121117

118+
// Called every time a message comes in:
119+
// TMI REDO
120+
function onMessageHandler (target, context, msg, self) {
121+
if (self) { return } // Ignore messages from the bot
122+
123+
// This isn't a command since it has no prefix:
124+
if (msg.substr(0, 1) !== commandPrefix) {
125+
console.log(`[${target} (${context['message-type']})] ${context.username}: ${msg}`)
126+
return
127+
}
128+
129+
// Split the message into individual words:
130+
const parse = msg.slice(1).split(' ')
131+
// The command name is the first (0th) one:
132+
const commandName = parse[0]
133+
// The rest (if any) are the parameters:
134+
const params = parse.splice(1)
135+
136+
// If the command is known, let's execute it:
137+
if (commandName in knownCommands) {
138+
// Retrieve the function by its name:
139+
const command = knownCommands[commandName]
140+
// Then call the command with parameters:
141+
command(target, context, params)
142+
console.log(`* Executed ${commandName} command for ${context.username}`)
143+
} else {
144+
console.log(`* Unknown command ${commandName} from ${context.username}`)
145+
}
146+
}
147+
148+
122149
// Commands:
123150
// Placeholder Command 1
124151
// Placeholder Command 2
125152

126-
127-
client.connect(); // See package.json: "start": "node WaldyBotTwitch.js",. Call "node WaldyBotTwitch.js" to start bot.
153+
chat.connect().then(() => {
154+
// ... and then join the channel.
155+
chat.join(twitchChannels.channels);
156+
//chat.join(twitchChannels.channels(array.forEach(element => {return})));
157+
});
158+
//client.connect(); // See package.json: "start": "node WaldyBotTwitch.js",. Call "node WaldyBotTwitch.js" to start bot.

node_modules/.bin/har-validator

Lines changed: 0 additions & 15 deletions
This file was deleted.

node_modules/.bin/har-validator.cmd

Lines changed: 0 additions & 7 deletions
This file was deleted.

node_modules/.bin/sshpk-conv

Lines changed: 0 additions & 15 deletions
This file was deleted.

node_modules/.bin/sshpk-conv.cmd

Lines changed: 0 additions & 7 deletions
This file was deleted.

node_modules/.bin/sshpk-sign

Lines changed: 0 additions & 15 deletions
This file was deleted.

node_modules/.bin/sshpk-sign.cmd

Lines changed: 0 additions & 7 deletions
This file was deleted.

node_modules/.bin/sshpk-verify

Lines changed: 0 additions & 15 deletions
This file was deleted.

node_modules/.bin/sshpk-verify.cmd

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)