00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "channeltab.h"
00023
00024 #include "channel.h"
00025
00026 #include "net/chathandler.h"
00027 #include "net/net.h"
00028
00029 #include "utils/gettext.h"
00030
00031 ChannelTab::ChannelTab(Channel *channel) :
00032 ChatTab(channel->getName()),
00033 mChannel(channel)
00034 {
00035 channel->setTab(this);
00036 }
00037
00038 ChannelTab::~ChannelTab()
00039 {
00040 }
00041
00042 void ChannelTab::handleInput(const std::string &msg)
00043 {
00044 Net::getChatHandler()->sendToChannel(getChannel()->getId(), msg);
00045 }
00046
00047 void ChannelTab::showHelp()
00048 {
00049 chatLog(_("/users > Lists the users in the current channel"));
00050 chatLog(_("/topic > Set the topic of the current channel"));
00051 chatLog(_("/quit > Leave a channel"));
00052 chatLog(_("/op > Make a user a channel operator"));
00053 chatLog(_("/kick > Kick a user from the channel"));
00054 }
00055
00056 bool ChannelTab::handleCommand(const std::string &type,
00057 const std::string &args)
00058 {
00059 if (type == "help")
00060 {
00061 if (args == "users")
00062 {
00063 chatLog(_("Command: /users"));
00064 chatLog(_("This command shows the users in this channel."));
00065 }
00066 else if (args == "topic")
00067 {
00068 chatLog(_("Command: /topic <message>"));
00069 chatLog(_("This command sets the topic to <message>."));
00070 }
00071 else if (args == "quit")
00072 {
00073 chatLog(_("Command: /quit"));
00074 chatLog(_("This command leaves the current channel."));
00075 chatLog(_("If you're the last person in the channel, it will be deleted."));
00076 }
00077 else if (args == "op")
00078 {
00079 chatLog(_("Command: /op <nick>"));
00080 chatLog(_("This command makes <nick> a channel operator."));
00081 chatLog(_("If the <nick> has spaces in it, enclose it in "
00082 "double quotes (\")."));
00083 chatLog(_("Channel operators can kick and op other users "
00084 "from the channel."));
00085 }
00086 else if (args == "kick")
00087 {
00088 chatLog(_("Command: /kick <nick>"));
00089 chatLog(_("This command makes <nick> leave the channel."));
00090 chatLog(_("If the <nick> has spaces in it, enclose it in "
00091 "double quotes (\")."));
00092 }
00093 else
00094 return false;
00095 }
00096 else if (type == "users")
00097 {
00098 Net::getChatHandler()->userList(mChannel->getName());
00099 }
00100 else if (type == "topic")
00101 {
00102 Net::getChatHandler()->setChannelTopic(mChannel->getId(), args);
00103 }
00104 else if (type == "topic")
00105 {
00106 Net::getChatHandler()->setChannelTopic(mChannel->getId(), args);
00107 }
00108 else if (type == "quit")
00109 {
00110 Net::getChatHandler()->quitChannel(mChannel->getId());
00111 }
00112 else if (type == "op")
00113 {
00114
00115 if (args != "")
00116 Net::getChatHandler()->setUserMode(mChannel->getId(), args, 'o');
00117 else
00118 chatLog(_("Need a user to op!"), BY_CHANNEL);
00119 }
00120 else if (type == "kick")
00121 {
00122 if (args != "")
00123 Net::getChatHandler()->kickUser(mChannel->getId(), args);
00124 else
00125 chatLog(_("Need a user to kick!"), BY_CHANNEL);
00126 }
00127 else
00128 return false;
00129
00130 return true;
00131 }