25c5119b2c2836972e347b41545d7a2c3fa01288
[reactos.git] / irc / TechBot / TechBot.Library / Commands / Base / Command.cs
1 using System;
2 using System.Text.RegularExpressions;
3
4 namespace TechBot.Library
5 {
6 public abstract class Command
7 {
8 protected TechBotService m_TechBotService = null;
9 protected MessageContext m_Context = null;
10 protected string m_Params = null;
11
12 public TechBotService TechBot
13 {
14 get { return m_TechBotService; }
15 set { m_TechBotService = value; }
16 }
17
18 public MessageContext Context
19 {
20 get { return m_Context; }
21 set { m_Context = value; }
22 }
23
24 public string Name
25 {
26 get
27 {
28 CommandAttribute commandAttribute = (CommandAttribute)
29 Attribute.GetCustomAttribute(GetType(), typeof(CommandAttribute));
30
31 return commandAttribute.Name;
32 }
33 }
34
35 public string Parameters
36 {
37 get { return m_Params; }
38 set { m_Params = value; }
39 }
40
41 protected virtual void Say()
42 {
43 TechBot.ServiceOutput.WriteLine(Context, string.Empty);
44 }
45
46 protected virtual void Say(string message)
47 {
48 TechBot.ServiceOutput.WriteLine(Context, message);
49 }
50
51 protected virtual void Say(string format , params object[] args)
52 {
53 TechBot.ServiceOutput.WriteLine(Context, String.Format(format, args));
54 }
55
56 public abstract void ExecuteCommand();
57
58 public virtual void Initialize()
59 {
60 }
61
62 public virtual void DeInitialize()
63 {
64 }
65 }
66 }