0

I am making a twitch chat bot with c# and I would like to know how I can purge/timeout users that are spamming or using banned words. I have searched everywhere i can to find a solution for this, but I can not find an answer anywhere.

Ben Rueter
  • 21
  • 6

2 Answers2

0

i have solved the problem, but if anyone else has the same problem you just simply send ".timeout [user] 1"

Ben Rueter
  • 21
  • 6
0

You don't seem to provide any implementation in your question, so I will make some assumptions. I assume that you have a list of banned words in a List<String> object called bannedWords, and are considering spam as a message that exceeds a given number of characters.

You have it correct that in order to time out someone, you need to send .timeout [user] [number of seconds], and this will 'delete' any messages they've sent (although users can simply click the <message deleted> link to see the original message).

One way you could do this is by doing the following:

// Code attribution: http://stackoverflow.com/a/9032686/2605758    
if (bannedWords.Any(str => str.Contains(message)) || message.Length >= maxLength)
{
    /* use whatever method you use to send a message to your channel */
    SendMessage(".timeout " + userNick + " 1"); 
}
Hoppeduppeanut
  • 1,109
  • 6
  • 20
  • 29
  • Also, for future reference, it's a good idea to provide code examples of what you have for the relevant parts of your program so far (even if they're not working - non-working code is better than no code at all!), so that we have a better idea of what you plan to do, and what kind of implementation you require. – Hoppeduppeanut Sep 07 '15 at 01:14
  • thank you for the help on formatting, i will keep all of that in mind in the future. – Ben Rueter Sep 09 '15 at 00:21