fixed help command
This commit is contained in:
parent
787a307b83
commit
2bfa510156
4 changed files with 26 additions and 23 deletions
|
@ -1,6 +1,7 @@
|
|||
import requests
|
||||
import time
|
||||
import json
|
||||
import os
|
||||
|
||||
with open('settings.json') as f:
|
||||
settings = json.load(f)
|
||||
|
@ -11,7 +12,7 @@ WRITE_FILE = settings['write_file']
|
|||
USER = settings['username']
|
||||
UPDATE = settings['seconds_interval']
|
||||
|
||||
print("Running!")
|
||||
print("* Follower/sub goal is now running. To add to your stream, add a text source and open the file " + os.path.abspath(WRITE_FILE) + " to display on your stream.")
|
||||
while(True):
|
||||
followers = open(WRITE_FILE, 'w')
|
||||
url_follows = "https://api.crunchprank.net/twitch/followcount/" + USER
|
||||
|
@ -23,3 +24,4 @@ while(True):
|
|||
print(f"Subs: {read_subs.text}/{SUB_GOAL}\nFollower goal: {read_follows.text}/{FOLLOWER_GOAL}\n", end='', file=followers)
|
||||
followers.close()
|
||||
time.sleep(UPDATE)
|
||||
|
||||
|
|
0
follow-src/source_output.txt
Normal file
0
follow-src/source_output.txt
Normal file
2
run.sh
2
run.sh
|
@ -5,7 +5,7 @@ cd ../follow-src
|
|||
python3 source.py &
|
||||
SCRIPT_PID=$!
|
||||
|
||||
echo "The Twitch bot and Source script is now running. You can stop this script by typing \"stop\""
|
||||
echo "The Twitch bot and Source script is now running. You can stop this script by typing \"stop\" or pressing ^C"
|
||||
|
||||
while read input; do
|
||||
case $input in
|
||||
|
|
|
@ -5,7 +5,7 @@ const fs = require('fs');
|
|||
try {
|
||||
var settings = JSON.parse(fs.readFileSync('./settings.json', 'utf8'));
|
||||
var reacts = JSON.parse(fs.readFileSync('./reacts.json', 'utf8'));
|
||||
var commands = JSON.parse(fs.readFileSync('./commands.json', 'utf8'));
|
||||
var chat_commands = JSON.parse(fs.readFileSync('./commands.json', 'utf8'));
|
||||
var mod_commands = JSON.parse(fs.readFileSync('./mod_commands.json', 'utf8'));
|
||||
} catch (err) {
|
||||
console.error("An error occured trying to read the files for the Twitch bot: " + err);
|
||||
|
@ -23,7 +23,7 @@ var modString = "";
|
|||
var mods;
|
||||
|
||||
try {
|
||||
modString = fs.readFileSync('', 'utf8');
|
||||
modString = fs.readFileSync('mods.txt', 'utf8');
|
||||
modString = modString.replace(/(\r\n|\n|\r)/gm, "");
|
||||
mods = modString.split(",");
|
||||
} catch (err) {
|
||||
|
@ -32,21 +32,6 @@ try {
|
|||
|
||||
var modCommand = false;
|
||||
|
||||
// Twitch bot initialization
|
||||
const client = new tmi.client(opts);
|
||||
|
||||
// Register our event handlers (defined below)
|
||||
client.on('message', onMessageHandler);
|
||||
client.on('connected', onConnectedHandler);
|
||||
|
||||
// Connect to Twitch:
|
||||
client.connect();
|
||||
|
||||
// Notify when connected
|
||||
function onConnectedHandler (addr, port) {
|
||||
console.log(`* Main Bot successfully connected to ${addr}:${port}`);
|
||||
}
|
||||
|
||||
function onMessageHandler (target, context, msg, self) {
|
||||
if (self) { return; } // Ignore messages from the bot
|
||||
const user = context.username;
|
||||
|
@ -70,16 +55,17 @@ function commands (target, commandName, user, mods) {
|
|||
if (commandName === "help") {
|
||||
var allCommands = [];
|
||||
var finalString = "";
|
||||
commands.forEach(command => {
|
||||
chat_commands.forEach(command => {
|
||||
allCommands.push(command.command);
|
||||
});
|
||||
allCommands.forEach(command => {
|
||||
finalString = finalString + command.command;
|
||||
finalString = finalString + settings.command_char + command.command + " ";
|
||||
});
|
||||
client.say(target, `Here is the list of commands: ${finalString}`);
|
||||
valid = true;
|
||||
} else {
|
||||
commands.forEach(command => {
|
||||
if (message.search(command.command) !== -1) {
|
||||
chat_commands.forEach(command => {
|
||||
if (commandName.search(command.command) !== -1) {
|
||||
client.say(target, `${command.reply}`);
|
||||
valid = true;
|
||||
return true;
|
||||
|
@ -128,4 +114,19 @@ function reactions (target, message, user) {
|
|||
});
|
||||
}
|
||||
|
||||
// Twitch bot initialization
|
||||
const client = new tmi.client(opts);
|
||||
|
||||
// Register our event handlers (defined below)
|
||||
client.on('message', onMessageHandler);
|
||||
client.on('connected', onConnectedHandler);
|
||||
|
||||
// Connect to Twitch:
|
||||
client.connect();
|
||||
|
||||
// Notify when connected
|
||||
function onConnectedHandler (addr, port) {
|
||||
console.log(`* Main Bot successfully connected to ${addr}:${port}`);
|
||||
}
|
||||
|
||||
|
||||
|
|
Reference in a new issue