-
Notifications
You must be signed in to change notification settings - Fork 1
/
EventParser.cs
46 lines (42 loc) · 1.13 KB
/
EventParser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Twitchie2.Enums;
namespace Twitchie2
{
internal static class EventParser
{
public static EventType ParseEventType(string buffer) =>
ParseCommand(buffer) switch
{
"001" => EventType.WelcomeMessage,
"002" => EventType.Ignored,
"004" => EventType.Ignored,
"375" => EventType.Ignored,
"372" => EventType.Ignored,
"376" => EventType.Ignored,
"CAP" => EventType.Ignored,
"PRIVMSG" => EventType.Message,
"ROOMSTATE" => EventType.RoomState,
"NOTICE" => EventType.Notice,
"HOSTTARGET" => EventType.HostTarget,
"CLEARCHAT" => EventType.ClearChat,
"CLEARMSG" => EventType.ClearMessage,
"PING" => EventType.Ping,
"MODE" => EventType.Mode,
"353" => EventType.NameListing,
"366" => EventType.NameListingEnd,
"JOIN" => EventType.Join,
"PART" => EventType.Part,
"USERNOTICE" => EventType.UserNotice,
"USERSTATE" => EventType.UserState,
_ => EventType.NotImplemented
};
static string ParseCommand(string buffer)
{
var splitted = buffer.Split(' ');
if (buffer[0] == '@')
{
return splitted[2];
}
return splitted[0] == "PING" ? splitted[0] : splitted[1];
}
}
}