Przeglądaj źródła

remove empty file

tags/v0.1.0
Daniel Oaks 8 lat temu
rodzic
commit
138f61d852
2 zmienionych plików z 20 dodań i 366 usunięć
  1. 0
    366
      irc/commandhandlers.go
  2. 20
    0
      irc/theater.go

+ 0
- 366
irc/commandhandlers.go Wyświetl plik

@@ -1,366 +0,0 @@
1
-// Copyright (c) 2012-2014 Jeremy Latt
2
-// Copyright (c) 2014-2015 Edmund Huber
3
-// Copyright (c) 2016- Daniel Oaks <daniel@danieloaks.net>
4
-// released under the MIT license
5
-
6
-package irc
7
-
8
-/*
9
-
10
-func ParseModeCommand(args []string) (Command, error) {
11
-	name := NewName(args[0])
12
-	if name.IsChannel() {
13
-		return ParseChannelModeCommand(name, args[1:])
14
-	} else {
15
-		return ParseUserModeCommand(name, args[1:])
16
-	}
17
-}
18
-
19
-type WhoisCommand struct {
20
-	BaseCommand
21
-	target Name
22
-	masks  []Name
23
-}
24
-
25
-// WHOIS [ <target> ] <mask> *( "," <mask> )
26
-func ParseWhoisCommand(args []string) (Command, error) {
27
-	var masks string
28
-	var target string
29
-
30
-	if len(args) > 1 {
31
-		target = args[0]
32
-		masks = args[1]
33
-	} else {
34
-		masks = args[0]
35
-	}
36
-
37
-	return &WhoisCommand{
38
-		target: NewName(target),
39
-		masks:  NewNames(strings.Split(masks, ",")),
40
-	}, nil
41
-}
42
-
43
-type WhoCommand struct {
44
-	BaseCommand
45
-	mask         Name
46
-	operatorOnly bool
47
-}
48
-
49
-// WHO [ <mask> [ "o" ] ]
50
-func ParseWhoCommand(args []string) (Command, error) {
51
-	cmd := &WhoCommand{}
52
-
53
-	if len(args) > 0 {
54
-		cmd.mask = NewName(args[0])
55
-	}
56
-
57
-	if (len(args) > 1) && (args[1] == "o") {
58
-		cmd.operatorOnly = true
59
-	}
60
-
61
-	return cmd, nil
62
-}
63
-
64
-type OperCommand struct {
65
-	PassCommand
66
-	name Name
67
-}
68
-
69
-func (msg *OperCommand) LoadPassword(server *Server) {
70
-	msg.hash = server.operators[msg.name]
71
-}
72
-
73
-// OPER <name> <password>
74
-func ParseOperCommand(args []string) (Command, error) {
75
-	cmd := &OperCommand{
76
-		name: NewName(args[0]),
77
-	}
78
-	cmd.password = []byte(args[1])
79
-	return cmd, nil
80
-}
81
-
82
-type CapCommand struct {
83
-	BaseCommand
84
-	subCommand   CapSubCommand
85
-	capabilities CapabilitySet
86
-}
87
-
88
-func ParseCapCommand(args []string) (Command, error) {
89
-	cmd := &CapCommand{
90
-		subCommand:   CapSubCommand(strings.ToUpper(args[0])),
91
-		capabilities: make(CapabilitySet),
92
-	}
93
-
94
-	if len(args) > 1 {
95
-		strs := spacesExpr.Split(args[1], -1)
96
-		for _, str := range strs {
97
-			cmd.capabilities[Capability(str)] = true
98
-		}
99
-	}
100
-	return cmd, nil
101
-}
102
-
103
-// HAPROXY support
104
-type ProxyCommand struct {
105
-	BaseCommand
106
-	net        Name
107
-	sourceIP   Name
108
-	destIP     Name
109
-	sourcePort Name
110
-	destPort   Name
111
-	hostname   Name // looked up in socket thread
112
-}
113
-
114
-func NewProxyCommand(hostname Name) *ProxyCommand {
115
-	cmd := &ProxyCommand{
116
-		hostname: hostname,
117
-	}
118
-	cmd.code = PROXY
119
-	return cmd
120
-}
121
-
122
-func ParseProxyCommand(args []string) (Command, error) {
123
-	return &ProxyCommand{
124
-		net:        NewName(args[0]),
125
-		sourceIP:   NewName(args[1]),
126
-		destIP:     NewName(args[2]),
127
-		sourcePort: NewName(args[3]),
128
-		destPort:   NewName(args[4]),
129
-		hostname:   LookupHostname(NewName(args[1])),
130
-	}, nil
131
-}
132
-
133
-type AwayCommand struct {
134
-	BaseCommand
135
-	text Text
136
-}
137
-
138
-func ParseAwayCommand(args []string) (Command, error) {
139
-	cmd := &AwayCommand{}
140
-
141
-	if len(args) > 0 {
142
-		cmd.text = NewText(args[0])
143
-	}
144
-
145
-	return cmd, nil
146
-}
147
-
148
-type IsOnCommand struct {
149
-	BaseCommand
150
-	nicks []Name
151
-}
152
-
153
-func ParseIsOnCommand(args []string) (Command, error) {
154
-	return &IsOnCommand{
155
-		nicks: NewNames(args),
156
-	}, nil
157
-}
158
-
159
-type MOTDCommand struct {
160
-	BaseCommand
161
-	target Name
162
-}
163
-
164
-func ParseMOTDCommand(args []string) (Command, error) {
165
-	cmd := &MOTDCommand{}
166
-	if len(args) > 0 {
167
-		cmd.target = NewName(args[0])
168
-	}
169
-	return cmd, nil
170
-}
171
-
172
-type NoticeCommand struct {
173
-	BaseCommand
174
-	target  Name
175
-	message Text
176
-}
177
-
178
-func ParseNoticeCommand(args []string) (Command, error) {
179
-	return &NoticeCommand{
180
-		target:  NewName(args[0]),
181
-		message: NewText(args[1]),
182
-	}, nil
183
-}
184
-
185
-type KickCommand struct {
186
-	BaseCommand
187
-	kicks   map[Name]Name
188
-	comment Text
189
-}
190
-
191
-func (msg *KickCommand) Comment() Text {
192
-	if msg.comment == "" {
193
-		return msg.Client().Nick().Text()
194
-	}
195
-	return msg.comment
196
-}
197
-
198
-func ParseKickCommand(args []string) (Command, error) {
199
-	channels := NewNames(strings.Split(args[0], ","))
200
-	users := NewNames(strings.Split(args[1], ","))
201
-	if (len(channels) != len(users)) && (len(users) != 1) {
202
-		return nil, NotEnoughArgsError
203
-	}
204
-	cmd := &KickCommand{
205
-		kicks: make(map[Name]Name),
206
-	}
207
-	for index, channel := range channels {
208
-		if len(users) == 1 {
209
-			cmd.kicks[channel] = users[0]
210
-		} else {
211
-			cmd.kicks[channel] = users[index]
212
-		}
213
-	}
214
-	if len(args) > 2 {
215
-		cmd.comment = NewText(args[2])
216
-	}
217
-	return cmd, nil
218
-}
219
-
220
-type ListCommand struct {
221
-	BaseCommand
222
-	channels []Name
223
-	target   Name
224
-}
225
-
226
-func ParseListCommand(args []string) (Command, error) {
227
-	cmd := &ListCommand{}
228
-	if len(args) > 0 {
229
-		cmd.channels = NewNames(strings.Split(args[0], ","))
230
-	}
231
-	if len(args) > 1 {
232
-		cmd.target = NewName(args[1])
233
-	}
234
-	return cmd, nil
235
-}
236
-
237
-type NamesCommand struct {
238
-	BaseCommand
239
-	channels []Name
240
-	target   Name
241
-}
242
-
243
-func ParseNamesCommand(args []string) (Command, error) {
244
-	cmd := &NamesCommand{}
245
-	if len(args) > 0 {
246
-		cmd.channels = NewNames(strings.Split(args[0], ","))
247
-	}
248
-	if len(args) > 1 {
249
-		cmd.target = NewName(args[1])
250
-	}
251
-	return cmd, nil
252
-}
253
-
254
-type DebugCommand struct {
255
-	BaseCommand
256
-	subCommand Name
257
-}
258
-
259
-func ParseDebugCommand(args []string) (Command, error) {
260
-	return &DebugCommand{
261
-		subCommand: NewName(strings.ToUpper(args[0])),
262
-	}, nil
263
-}
264
-
265
-type VersionCommand struct {
266
-	BaseCommand
267
-	target Name
268
-}
269
-
270
-func ParseVersionCommand(args []string) (Command, error) {
271
-	cmd := &VersionCommand{}
272
-	if len(args) > 0 {
273
-		cmd.target = NewName(args[0])
274
-	}
275
-	return cmd, nil
276
-}
277
-
278
-type InviteCommand struct {
279
-	BaseCommand
280
-	nickname Name
281
-	channel  Name
282
-}
283
-
284
-func ParseInviteCommand(args []string) (Command, error) {
285
-	return &InviteCommand{
286
-		nickname: NewName(args[0]),
287
-		channel:  NewName(args[1]),
288
-	}, nil
289
-}
290
-
291
-func ParseTheaterCommand(args []string) (Command, error) {
292
-	if upperSubCmd := strings.ToUpper(args[0]); upperSubCmd == "IDENTIFY" && len(args) == 3 {
293
-		return &TheaterIdentifyCommand{
294
-			channel:     NewName(args[1]),
295
-			PassCommand: PassCommand{password: []byte(args[2])},
296
-		}, nil
297
-	} else if upperSubCmd == "PRIVMSG" && len(args) == 4 {
298
-		return &TheaterPrivMsgCommand{
299
-			channel: NewName(args[1]),
300
-			asNick:  NewName(args[2]),
301
-			message: NewText(args[3]),
302
-		}, nil
303
-	} else if upperSubCmd == "ACTION" && len(args) == 4 {
304
-		return &TheaterActionCommand{
305
-			channel: NewName(args[1]),
306
-			asNick:  NewName(args[2]),
307
-			action:  NewCTCPText(args[3]),
308
-		}, nil
309
-	} else {
310
-		return nil, ErrParseCommand
311
-	}
312
-}
313
-
314
-type TimeCommand struct {
315
-	BaseCommand
316
-	target Name
317
-}
318
-
319
-func ParseTimeCommand(args []string) (Command, error) {
320
-	cmd := &TimeCommand{}
321
-	if len(args) > 0 {
322
-		cmd.target = NewName(args[0])
323
-	}
324
-	return cmd, nil
325
-}
326
-
327
-type KillCommand struct {
328
-	BaseCommand
329
-	nickname Name
330
-	comment  Text
331
-}
332
-
333
-func ParseKillCommand(args []string) (Command, error) {
334
-	return &KillCommand{
335
-		nickname: NewName(args[0]),
336
-		comment:  NewText(args[1]),
337
-	}, nil
338
-}
339
-
340
-type WhoWasCommand struct {
341
-	BaseCommand
342
-	nicknames []Name
343
-	count     int64
344
-	target    Name
345
-}
346
-
347
-func ParseWhoWasCommand(args []string) (Command, error) {
348
-	cmd := &WhoWasCommand{
349
-		nicknames: NewNames(strings.Split(args[0], ",")),
350
-	}
351
-	if len(args) > 1 {
352
-		cmd.count, _ = strconv.ParseInt(args[1], 10, 64)
353
-	}
354
-	if len(args) > 2 {
355
-		cmd.target = NewName(args[2])
356
-	}
357
-	return cmd, nil
358
-}
359
-
360
-func ParseOperNickCommand(args []string) (Command, error) {
361
-	return &OperNickCommand{
362
-		target: NewName(args[0]),
363
-		nick:   NewName(args[1]),
364
-	}, nil
365
-}
366
-*/

+ 20
- 0
irc/theater.go Wyświetl plik

@@ -19,6 +19,26 @@ func (m *TheaterIdentifyCommand) LoadPassword(s *Server) {
19 19
 	m.hash = s.theaters[m.channel]
20 20
 }
21 21
 
22
+	if upperSubCmd := strings.ToUpper(args[0]); upperSubCmd == "IDENTIFY" && len(args) == 3 {
23
+		return &TheaterIdentifyCommand{
24
+			channel:     NewName(args[1]),
25
+			PassCommand: PassCommand{password: []byte(args[2])},
26
+		}, nil
27
+	} else if upperSubCmd == "PRIVMSG" && len(args) == 4 {
28
+		return &TheaterPrivMsgCommand{
29
+			channel: NewName(args[1]),
30
+			asNick:  NewName(args[2]),
31
+			message: NewText(args[3]),
32
+		}, nil
33
+	} else if upperSubCmd == "ACTION" && len(args) == 4 {
34
+		return &TheaterActionCommand{
35
+			channel: NewName(args[1]),
36
+			asNick:  NewName(args[2]),
37
+			action:  NewCTCPText(args[3]),
38
+		}, nil
39
+	} else {
40
+		return nil, ErrParseCommand
41
+	}
22 42
 func (m *TheaterIdentifyCommand) HandleServer(s *Server) {
23 43
 	client := m.Client()
24 44
 	if !m.channel.IsChannel() {

Ładowanie…
Anuluj
Zapisz