blob: 311e17dc8cbf6fd45b6d2a905af9cf50166fa93a (
plain)
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
|
package f00f.net.irc.martyr.replies;
import java.util.Date;
import java.util.StringTokenizer;
import f00f.net.irc.martyr.InCommand;
import f00f.net.irc.martyr.clientstate.Channel;
import f00f.net.irc.martyr.clientstate.ClientState;
/**
* Contains info about the topic, who set it and when.
*/
public class TopicInfoReply extends GenericReply
{
private String channelName;
private Date date;
private String author;
/** For use as a factory. */
public TopicInfoReply()
{
}
public TopicInfoReply( String channelName, Date date, String author )
{
this.channelName = channelName;
this.date = date;
this.author = author;
}
public String getIrcIdentifier()
{
return "333";
}
public String getChannel()
{
return this.channelName;
}
public InCommand parse( String prefix, String identifier, String params )
{
StringTokenizer tokens = new StringTokenizer( params );
// Our nick. We don't need that, I think.
tokens.nextToken();
// The channel.
String chan = tokens.nextToken();
// The author
String author = tokens.nextToken();
// The date.
Date date;
try
{
date = new Date( Long.parseLong( tokens.nextToken() ) * 1000 );
}
catch( NumberFormatException nfe )
{
// riiiight...
date = new Date(0);
}
return new TopicInfoReply( chan, date, author );
}
public boolean updateClientState( ClientState state )
{
Channel channel = state.getChannel( channelName );
channel.setTopicDate( date );
channel.setTopicAuthor( author );
return true;
}
}
|