/
trac.cs
86 lines (82 loc) · 2.71 KB
/
trac.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
using System;
using Squishy.Irc.Commands;
namespace WCellNotifier
{
public class GetTicketCommand : Command
{
public GetTicketCommand()
: base("gt", "getticket")
{
Usage = "getticket id";
Description = "Gets the information of the ticket you specify";
}
public override void Process(CmdTrigger trigger)
{
try
{
string reply = "";
foreach (var value in TracBackend.GetTicket(trigger.Args.NextInt(1)))
{
reply += value;
reply += " ";
}
reply = reply.Replace("\n", " ");
reply = reply.Replace("\r", " ");
trigger.Reply(reply);
}
catch (Exception e)
{
// Error handling
}
}
}
public class CreateTicketCommand : Command
{
public CreateTicketCommand()
: base("ct")
{
Usage = "ct -summary summary here -description description here -attr none -notify false";
Description = "Add a new ticket";
}
public override void Process(CmdTrigger trigger)
{
try
{
string summary = "", description = "";
PageAttributes attributes = new PageAttributes();
bool notify = false;
while (trigger.Args.HasNext)
{
var next = trigger.Args.NextModifiers();
switch (next)
{
case "s":
case "summary":
summary = trigger.Args.NextWord("\"");
break;
case "d":
case "description":
description = trigger.Args.NextWord("\"");
break;
case "a":
case "attr":
attributes.comment = trigger.Args.NextWord("\"");
break;
case "n":
case "notify":
notify = Convert.ToBoolean(trigger.Args.NextWord());
break;
default:
Console.WriteLine(trigger.Args.NextWord("\""));
break;
}
}
trigger.Reply(TracBackend.CreateTicket(summary, description, attributes, notify));
}
catch (Exception e)
{
// Error handling
}
}
}
}