我正在努力做到这一点,以便我可以在我的 twitch 机器人中注册第二部分:!test [var]。基本上,如果他们说 !test @jeff,它就可以说你好@jeff。
我正在使用tmi
client.on('chat', function(channel, user, message, self) {
if(message === "!twitter") {
client.action("kong_plays", user['display-name'] + " my twitter is x !");
}
if(message === "!youtube") {
client.action("kong_plays", user['display-name'] + " my youtube is x !");
}
if(message === "!discord") {
client.action("kong_plays", user['display-name'] + " you can join my discord with the link : https://discord.gg/GdbZea !");
}
if(message === "!sub") {
client.action("kong_plays", user['display-name'] + " It helps me out if you can sub. Also you receive access to exclusive perks such as: Sub Games, Sub only emotes, Sub Only Discord. Sub here x !");
}
if(message === "!tip") {
client.action("kong_plays", user['display-name'] + " Tipping helps me out a ton whether it be only $1 x !");
}
if(message === "!alerts") {
client.action("kong_plays", user['display-name'] + " The alerts are shown in chat as I stream with shadowplay not allowing me to show alerts!");
}
if(//someone inputs !test [var] ) {
register [var]
say something + [var]
}
最佳答案
也许只是用空格分割以获得不同的单词:
const [command, ...args] = message.split(" ");
所以你可以像这样访问它:
if(command === "!test") {
client.action("idk", "Hello " + args[0] + "!");
}
关于javascript - 如何在 twitch 机器人中分隔变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50888370/