Skip to content

Commit

Permalink
version update with small bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dv13vlm committed Nov 23, 2022
1 parent 1432e30 commit d193a99
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
38 changes: 27 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,28 @@ const setup = () =>{
save()
}

function debugtxt(...text){
if(data.debug){
for(let i=0; i<text.length; i++){
console.log(txt[i])
}
}
}

let chat
const execute = () => {
let tokenstring
if(data.token && data.token !== "TOKEN"){
tokenstring = "with token"
chat = new tmi.Client(
{identity: {
{
identity: {
username: data.username,
password: data.token
},
},
channels: [data.channel]
}
)
}
)
}else{
tokenstring = "without token"
chat = new tmi.Client(
Expand All @@ -225,7 +234,6 @@ const execute = () => {
)
}


chat.connect().then(() => {
console.log(`
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n
Expand All @@ -239,14 +247,20 @@ const execute = () => {
fileWriteHandler()

chat.on("message", (channel, tags, message, self)=>{
if((tags.badges.moderator === "1" || tags.badges.broadcaster === "1") && message.split(" ")[0].toLowerCase() === data.controlCommandName.toLowerCase()){
controlCommand(message.split(" "))
if(tags !== null && tags !== undefined){
if(message.split(" ")[0].toLowerCase() === data.controlCommandName.toLowerCase()){
if((tags.badges.moderator === "1" || tags.badges.broadcaster === "1")){
controlCommand(message.split(" "))
}
}
}else{
debugtxt(tags, message)
}
})

chat.on("cheer", (channel, userstate, message) =>{
if(data.cheerMode !== "off"){
console.log(`${CurrentTime()}: Cheer from ${userstate["display-name"]}, cheered: ${userstate["bits"]}`)
console.log(`${CurrentTime()}: From: ${userstate["display-name"]}, cheered: ${userstate["bits"]}`)
bitsPointCalculation(parseInt(userstate["bits"]))
}

Expand Down Expand Up @@ -304,7 +318,6 @@ const execute = () => {
})

chat.on("subgift", (channel, username, streakMonths, recipient, methods, userstate) => {
console.log(channel, username, streakMonths, recipient, methods, userstate)
if (username.toLowerCase() === data.channel.toLowerCase() && !data.shouldGiftedFromChannelCount) return

let giftMonths = parseInt(userstate["msg-param-gift-months"])
Expand Down Expand Up @@ -507,9 +520,11 @@ const fileWriteHandler = () => {
outstring = outstring.replaceAll("${points}", data.points).replaceAll("${goal}", data.goal).replaceAll("${goalCount}", data.goalCount)
fs.writeFile("output.txt", outstring, function (err) {
if (err){
return console.log(err)
console.log(`${CurrentTime()}: file write error: `)
console.log(err)
}else{
console.log(`${CurrentTime()}:"${outstring}" written to output.txt`)
}
console.log(`${CurrentTime()}:"${outstring}" written to output.txt`)
})
save()
}
Expand Down Expand Up @@ -537,6 +552,7 @@ const commands = () => {
removePoints(x) : remove x number of points.
addGoals(x) : add x number of goals reached.
removeGoals(x) : remove x number of goals reached.
resetGoal(): resets the multigoal.
exit() : End the program.
fullReset(): Will fully reset your settings and quit out
of the script, the next time you start it it will prompt
Expand Down
2 changes: 1 addition & 1 deletion output.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0/10 points to reach goal number #17
0/10 points to reach goal number #1
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twitch-multigoal",
"version": "0.8",
"version": "0.9",
"scripts": {
"start": "npx node-repl ./index.js",
"dev": "npx node-repl ./index.js"
Expand Down

0 comments on commit d193a99

Please sign in to comment.