forked from amoeba/TownCrier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPluginCore.Events.cs
114 lines (102 loc) · 3.23 KB
/
PluginCore.Events.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using System.Text;
using Decal.Adapter;
using Decal.Adapter.Wrappers;
namespace TownCrier
{
[WireUpBaseEvents]
public partial class PluginCore : PluginBase
{
[BaseEvent("LoginComplete", "CharacterFilter")]
private void CharacterFilter_LoginComplete(object sender, EventArgs e)
{
try
{
LoadSettings();
Core.CharacterFilter.Death += CharacterFilter_Death;
TriggerWebhooksForEvent(EVENTS.LOGIN, Core.CharacterFilter.Name + " has logged in.");
}
catch (Exception ex) { Util.LogError(ex); }
}
[BaseEvent("ChatBoxMessage")]
private void Core_ChatBoxMessage(object sender, ChatTextInterceptEventArgs e)
{
try
{
if (ChatPatterns != null)
{
foreach (ChatPattern pattern in ChatPatterns)
{
if (!pattern.Match(e))
{
continue;
}
// Messages sometimes have newlines in them
TriggerWebhooksForEvent(pattern.Event, e.Text.Replace("\n", ""));
}
}
if (ChatTriggers != null)
{
foreach (ChatTrigger trigger in ChatTriggers)
{
if (!trigger.Match(e))
{
continue;
}
// Messages sometimes have newlines in them
TriggerWebhooksForChatTrigger(trigger, e.Text.Replace("\n", ""));
}
}
}
catch (Exception ex)
{
Util.LogError(ex);
}
}
[BaseEvent("Logoff", "CharacterFilter")]
private void CharacterFilter_Logoff(object sender, LogoffEventArgs e)
{
try
{
TriggerWebhooksForEvent(EVENTS.LOGOFF, Core.CharacterFilter.Name + " has logged off.");
SaveSettings();
Core.CharacterFilter.Death -= CharacterFilter_Death;
}
catch (Exception ex)
{
Util.LogError(ex);
}
}
[BaseEvent("ServerDispatch", "EchoFilter")]
private void EchoFilter(object sender, NetworkMessageEventArgs e)
{
if (EventTriggers == null)
{
return;
}
try
{
if (e.Message.Type == 0xF7B0) // Game Event
{
int eventId = (int)e.Message["event"];
// TODO
}
}
catch (Exception ex)
{
Util.LogError(ex);
}
}
private void CharacterFilter_Death(object sender, DeathEventArgs e)
{
try
{
TriggerWebhooksForEvent(EVENTS.DEATH, Core.CharacterFilter.Name + " has died: " + e.Text);
}
catch (Exception ex)
{
Util.LogError(ex);
}
}
}
}