mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
IRCClient: Add Channel application menu and LIST and KICK commands
The new Channel application menu allow offers various commands related to the currently visible channel, including changing the topic, kicking a user, and leaving the channel.
This commit is contained in:
parent
9e855376dd
commit
175ec99814
4 changed files with 82 additions and 1 deletions
|
@ -317,6 +317,16 @@ void IRCClient::send_topic(const String& channel_name, const String& text)
|
|||
send(String::format("TOPIC %s :%s\r\n", channel_name.characters(), text.characters()));
|
||||
}
|
||||
|
||||
void IRCClient::send_kick(const String& channel_name, const String& nick, const String& comment)
|
||||
{
|
||||
send(String::format("KICK %s %s :%s\r\n", channel_name.characters(), nick.characters(), comment.characters()));
|
||||
}
|
||||
|
||||
void IRCClient::send_list()
|
||||
{
|
||||
send("LIST\r\n");
|
||||
}
|
||||
|
||||
void IRCClient::send_privmsg(const String& target, const String& text)
|
||||
{
|
||||
send(String::format("PRIVMSG %s :%s\r\n", target.characters(), text.characters()));
|
||||
|
@ -696,6 +706,19 @@ void IRCClient::handle_user_command(const String& input)
|
|||
send_topic(channel, topic);
|
||||
return;
|
||||
}
|
||||
if (command == "/KICK") {
|
||||
if (parts.size() < 3)
|
||||
return;
|
||||
auto channel = parts[1];
|
||||
auto nick = parts[2];
|
||||
auto reason = input.view().substring_view_starting_after_substring(nick);
|
||||
send_kick(channel, nick, reason);
|
||||
return;
|
||||
}
|
||||
if (command == "/LIST") {
|
||||
send_list();
|
||||
return;
|
||||
}
|
||||
if (command == "/QUERY") {
|
||||
if (parts.size() >= 2) {
|
||||
auto& query = ensure_query(parts[1]);
|
||||
|
@ -724,6 +747,11 @@ void IRCClient::change_nick(const String& nick)
|
|||
send(String::format("NICK %s\r\n", nick.characters()));
|
||||
}
|
||||
|
||||
void IRCClient::handle_list_channels_action()
|
||||
{
|
||||
send_list();
|
||||
}
|
||||
|
||||
void IRCClient::handle_whois_action(const String& nick)
|
||||
{
|
||||
send_whois(nick);
|
||||
|
@ -739,6 +767,16 @@ void IRCClient::handle_change_nick_action(const String& nick)
|
|||
change_nick(nick);
|
||||
}
|
||||
|
||||
void IRCClient::handle_change_topic_action(const String& channel, const String& topic)
|
||||
{
|
||||
send_topic(channel, topic);
|
||||
}
|
||||
|
||||
void IRCClient::handle_kick_user_action(const String& channel, const String& nick, const String& message)
|
||||
{
|
||||
send_kick(channel, nick, message);
|
||||
}
|
||||
|
||||
void IRCClient::handle_close_query_action(const String& nick)
|
||||
{
|
||||
m_queries.remove(nick);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue