-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamplePlugin.cs
More file actions
75 lines (67 loc) · 1.89 KB
/
ExamplePlugin.cs
File metadata and controls
75 lines (67 loc) · 1.89 KB
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
using System;
using System.IO;
using btbcomm;
using System.Runtime.Serialization.Formatters.Binary;
namespace btbplugin
{
[Serializable()]
public class btbCommand : ICommand
{
private int count = 1;
public string Name
{
get
{
return "Example";
}
}
public string Help
{
get
{
return "Type \"!Example param1\" to try";
}
}
public string[] Command
{
get
{
string[] commands = { "!example" };
return commands;
}
}
public PluginResponse ValidateParameters(string command, string[] args)
{
if (args.Length < 1)
return PluginResponse.Help;
return PluginResponse.Accept;
}
public bool Execute(out string message, string command, User usr, string[] args)
{
message = usr.displayName + ": Here is an example response, you have " + usr.points + "points.";
message += " This command has been ran a total of " + count++ + " times.";
message += " Args passed are: ";
foreach (string arg in args)
{
message += '"' + arg + "\", ";
}
btblog.WriteLine("Example plugin has ran successfully");
return true;
}
public byte[] Save()
{
// Example
MemoryStream exampleStream = new MemoryStream();
BinaryFormatter serialiser = new BinaryFormatter();
serialiser.Serialize(exampleStream, this);
return exampleStream.GetBuffer();
}
public void Load(byte[] data, IBtbInterface ignored)
{
// Example
MemoryStream exampleStream = new MemoryStream(data, false);
BinaryFormatter deserialiser = new BinaryFormatter();
count = (deserialiser.Deserialize(exampleStream) as btbCommand).count;
}
}
}