mirror of
https://github.com/moparisthebest/Yaaic
synced 2025-02-16 15:00:14 -05:00
Remember channel's topic and print on /topic
This commit is contained in:
parent
c5dc8115d2
commit
3b8f6ee494
@ -41,7 +41,7 @@ public class TopicCommand extends BaseCommand
|
||||
{
|
||||
if (params.length == 1) {
|
||||
// Show topic
|
||||
// XXX: PircBot doesn't save the channel's topic - we have to keep track of the topic in the channel class
|
||||
service.getConnection(server.getId()).onTopic(channel.getName(), channel.getTopic(), "", 0, false);
|
||||
} else if (params.length > 1) {
|
||||
// Change topic
|
||||
service.getConnection(server.getId()).setTopic(channel.getName(), BaseCommand.mergeParams(params));
|
||||
|
@ -384,7 +384,7 @@ public class IRCConnection extends PircBot
|
||||
* On Topic
|
||||
*/
|
||||
@Override
|
||||
protected void onTopic(String target, String topic, String setBy, long date, boolean changed)
|
||||
public void onTopic(String target, String topic, String setBy, long date, boolean changed)
|
||||
{
|
||||
debug("Topic", target + " " + setBy + " " + topic);
|
||||
|
||||
@ -398,8 +398,10 @@ public class IRCConnection extends PircBot
|
||||
server.getChannel(target).addMessage(message);
|
||||
}
|
||||
|
||||
// remember channel's topic
|
||||
server.getChannel(target).setTopic(topic);
|
||||
|
||||
Intent intent = new Intent(Broadcast.CHANNEL_MESSAGE);
|
||||
|
||||
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
|
||||
intent.putExtra(Broadcast.EXTRA_CHANNEL, target);
|
||||
service.sendBroadcast(intent);
|
||||
|
@ -32,6 +32,7 @@ public class Channel
|
||||
private static final int BUFFER_SIZE = 30;
|
||||
|
||||
private String name;
|
||||
private String topic;
|
||||
private LinkedList<Message> buffer = new LinkedList<Message>();
|
||||
private LinkedList<Message> history = new LinkedList<Message>();
|
||||
|
||||
@ -43,6 +44,7 @@ public class Channel
|
||||
public Channel(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.topic = "";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,4 +105,24 @@ public class Channel
|
||||
{
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the channel's topic
|
||||
*
|
||||
* @param topic The topic of the channel
|
||||
*/
|
||||
public void setTopic(String topic)
|
||||
{
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the topic of the channel
|
||||
*
|
||||
* @return The channel's topic
|
||||
*/
|
||||
public String getTopic()
|
||||
{
|
||||
return topic;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user