Skip to content

Commit

Permalink
custom auto responded added
Browse files Browse the repository at this point in the history
  • Loading branch information
steveseguin committed Jan 15, 2024
1 parent 97f6682 commit aa01e65
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 5 deletions.
31 changes: 31 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3331,6 +3331,25 @@ async function applyBotActions(data, tab=false){ // this can be customized to cr
return null;
}
}
if (data.chatmessage){
for (var i = 1;i<=10;i++){
if (settings['botReplyMessageEvent'+i] && settings['botReplyMessageCommand'+i] && settings['botReplyMessageCommand'+i].textsetting && settings['botReplyMessageValue'+i] && settings['botReplyMessageValue'+i].textsetting && (data.chatmessage.indexOf(settings['botReplyMessageCommand'+i].textsetting)!=-1)){
var timeoutBot = 0;
if (settings['botReplyMessageTimeout'+i]){
timeoutBot = settings['botReplyMessageTimeout'+i].numbersetting || 0;
}
if (Date.now() - messageTimeout > timeoutBot){ // respond to "1" with a "1" automatically; at most 1 time per minute.
messageTimeout = Date.now();
var msg = {};
msg.tid = data.tid;
msg.response = settings['botReplyMessageValue'+i].textsetting;
processResponse(msg);
}
break;
}
}
}



if (settings.blacklist && data.chatmessage){
Expand Down Expand Up @@ -3359,6 +3378,18 @@ async function applyBotActions(data, tab=false){ // this can be customized to cr
}
}

if (settings.autohi && data.chatname){
if (data.chatmessage.toLowerCase() === "hi"){
if (Date.now() - messageTimeout > 60000){ // respond to "1" with a "1" automatically; at most 1 time per minute.
messageTimeout = Date.now();
var msg = {};
msg.tid = data.tid;
msg.response = "Hi, @"+data.chatname+" !";
processResponse(msg);
}
}
}

// applyBotActions nor applyCustomActions ; I'm going to allow for copy/paste here I think instead.

if (settings.relaydonos && data.hasDonation && data.chatname && data.type){
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Social Stream Ninja",
"description": "Powerful tooling to engage live chat on Youtube, Twitch, Zoom, and more",
"manifest_version": 2,
"version": "1.68.2",
"version": "1.68.3",
"homepage_url": "http://socialstream.ninja/",
"icons": {
"128": "icons/icon-128.png"
Expand Down
22 changes: 19 additions & 3 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@
border-radius:10px;
margin-top:10px;
}
#botReplyMessages {
overflow-y: auto;
max-height:156px;
box-shadow: inset 0px 0px 5px #0000002e;
border-radius:10px;
margin-top:10px;
}
.rounded_area {
background-color: var(--color-accent-subtle);
border-radius: 6px;
Expand Down Expand Up @@ -2467,16 +2474,25 @@ <h3><span data-translate="giphy-support">Giphy support</span></h3>
</div>

<br>
<h3><span data-translate="trigger-webhook-url-by-a-command">Trigger webhook URL by a !command</span></h3><span data-translate="have-custom-chat-commands-poke-a-custom-api-endpoint">
<h3><span data-translate="trigger-webhook-url-by-a-command">Trigger webhook URL by a !command</span></h3>
<span data-translate="have-custom-chat-commands-poke-a-custom-api-endpoint">
Have custom chat commands poke a custom API endpoint
</span><div id="chatCommands">
</div>
<br>
<h3><span data-translate="send-fixed-messages-at-intervals">Send fixed messages at intervals</span></h3><span data-translate="specify-frequency-and-starting-offset-of-fixed-messages">


<h3><span data-translate="send-fixed-messages-at-intervals">Send fixed messages at intervals</span></h3>
<span data-translate="specify-frequency-and-starting-offset-of-fixed-messages">
Specify frequency and starting offset of fixed messages
</span><div id="timedMessages">
</div>
<br>

<h3><span data-translate="custom-commands">Auto-responder</span></h3>
<span data-translate="auto-responder">
Auto-respond to custom chat commands
</span><div id="botReplyMessages">
</div>

</div>
</div>
Expand Down
24 changes: 23 additions & 1 deletion popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,29 @@ document.addEventListener("DOMContentLoaded", async function(event) {
document.getElementById("timedMessages").appendChild(chat);
}


for (var i=1;i<=10;i++){
var chat = document.createElement("div");
chat.innerHTML = '<label class="switch" style="vertical-align: top; margin: 26px 0 0 0">\
<input type="checkbox" data-setting="botReplyMessageEvent'+ i +'">\
<span class="slider round"></span>\
</label>\
<div style="display:inline-block">\
<div class="textInputContainer" style="width: 235px">\
<input type="text" id="botReplyMessageCommand'+ i +'" class="textInput" autocomplete="off" placeholder="Message to send to chat" data-textsetting="botReplyMessageCommand'+ i +'">\
<label for="botReplyMessageCommand'+ i +'">&gt; Triggering command. eg: !discord</label>\
</div>\
<div class="textInputContainer" style="width: 235px">\
<input type="text" id="botReplyMessageValue'+ i +'" class="textInput" autocomplete="off" placeholder="Message to respond with" data-textsetting="botReplyMessageValue'+ i +'">\
<label for="botReplyMessageValue'+ i +'">&gt; Message to respond with.</label>\
</div>\
<div class="textInputContainer" style="width: 235px">\
<input type="number" id="botReplyMessageTimeout'+ i +'" class="textInput" min="0" autocomplete="off" placeholder="Timeout needed between responses" data-numbersetting="botReplyMessageTimeout'+ i +'">\
<label for="botReplyMessageTimeout'+ i +'">&gt; Trigger timeout (ms)</label>\
</div>\
</div>';
document.getElementById("botReplyMessages").appendChild(chat);
}

var iii = document.querySelectorAll("input[type='checkbox']");
for (var i=0;i<iii.length;i++){
iii[i].onchange = updateSettings;
Expand Down

0 comments on commit aa01e65

Please sign in to comment.