Mana
Loading...
Searching...
No Matches
channeltab.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2008-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "channeltab.h"
23
24#include "channel.h"
25
26#include "net/chathandler.h"
27#include "net/net.h"
28
29#include "utils/gettext.h"
30
32 ChatTab(channel->getName()),
33 mChannel(channel)
34{
35}
36
40
41void ChannelTab::handleInput(const std::string &msg)
42{
44}
45
47{
48 chatLog(_("/users > Lists the users in the current channel"));
49 chatLog(_("/topic > Set the topic of the current channel"));
50 chatLog(_("/quit > Leave a channel"));
51 chatLog(_("/op > Make a user a channel operator"));
52 chatLog(_("/kick > Kick a user from the channel"));
53}
54
55bool ChannelTab::handleCommand(const std::string &type,
56 const std::string &args)
57{
58 if (type == "help")
59 {
60 if (args == "users")
61 {
62 chatLog(_("Command: /users"));
63 chatLog(_("This command shows the users in this channel."));
64 }
65 else if (args == "topic")
66 {
67 chatLog(_("Command: /topic <message>"));
68 chatLog(_("This command sets the topic to <message>."));
69 }
70 else if (args == "quit")
71 {
72 chatLog(_("Command: /quit"));
73 chatLog(_("This command leaves the current channel."));
74 chatLog(_("If you're the last person in the channel, "
75 "it will be deleted."));
76 }
77 else if (args == "op")
78 {
79 chatLog(_("Command: /op <nick>"));
80 chatLog(_("This command makes <nick> a channel operator."));
81 chatLog(_("If the <nick> has spaces in it, enclose it in "
82 "double quotes (\")."));
83 chatLog(_("Channel operators can kick and op other users "
84 "from the channel."));
85 }
86 else if (args == "kick")
87 {
88 chatLog(_("Command: /kick <nick>"));
89 chatLog(_("This command makes <nick> leave the channel."));
90 chatLog(_("If the <nick> has spaces in it, enclose it in "
91 "double quotes (\")."));
92 }
93 else
94 return false;
95 }
96 else if (type == "users")
97 {
99 }
100 else if (type == "topic")
101 {
103 }
104 else if (type == "quit")
105 {
107 }
108 else if (type == "op")
109 {
110 // set the user mode 'o' to op a user
111 if (!args.empty())
113 else
114 chatLog(_("Need a user to op!"), BY_CHANNEL);
115 }
116 else if (type == "kick")
117 {
118 if (!args.empty())
120 else
121 chatLog(_("Need a user to kick!"), BY_CHANNEL);
122 }
123 else
124 return false;
125
126 return true;
127}
@ BY_CHANNEL
Definition chatwindow.h:51
Channel * mChannel
Definition channeltab.h:51
ChannelTab(Channel *channel)
~ChannelTab() override
void handleInput(const std::string &msg) override
void showHelp() override
Add any extra help text to the output.
bool handleCommand(const std::string &type, const std::string &args) override
Handle special commands.
Channel * getChannel() const
Definition channeltab.h:34
const std::string & getName() const
Get this channel's name.
Definition channel.h:52
int getId() const
Get the id associated witht his channel.
Definition channel.h:47
A tab for the chat window.
Definition chattab.h:36
void chatLog(std::string line, Own own=BY_SERVER, bool ignoreRecord=false)
Adds a line of text to our message list.
Definition chattab.cpp:111
virtual void setChannelTopic(int channelId, const std::string &text)=0
virtual void setUserMode(int channelId, const std::string &name, int mode)=0
virtual void quitChannel(int channelId)=0
virtual void sendToChannel(int channelId, const std::string &text)=0
virtual void userList(const std::string &channel)=0
virtual void kickUser(int channelId, const std::string &name)=0
#define _(s)
Definition gettext.h:38
ChatHandler * getChatHandler()
Definition net.cpp:70