Closed Scout339 closed 5 years ago
if (fromID === me && text.includes("r/") ) {
bot.sendMessage({ to: channel, message: text.replace(/(.*)r\/([^ ]+).*/,"https://www.reddit.com/r/$2") });
}
Above will produce for input check out r/github you guys!
with result https://www.reddit.com/r/github
If you want the text after the space then /(.*)r\/([^ ]+.*)/
which will produce https://www.reddit.com/r/github you guys!
`
Thank you! That is all I needed for now.
Edit: Faulty code that I had to rework with a lot of help... Ended up scrapping all of it.
How might I make a bot that listens for a keyword, and only repeats what is after the keyword up until a space is detected? Here is what I have so far:
But i'm thinking that it will continue to copy the message after the spaces, such as the outcome of "check out r/github you guys!"
Bot returns: "https://www.reddit.com/r/github you guys!"