From 3c803441eae6331b3b22a4918741315e4579b908 Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Tue, 7 Feb 2012 17:05:52 +0000 Subject: [PATCH] Use CModCommand in partyline --- modules/partyline.cpp | 79 ++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 53 deletions(-) diff --git a/modules/partyline.cpp b/modules/partyline.cpp index 2b04185a..3c362513 100644 --- a/modules/partyline.cpp +++ b/modules/partyline.cpp @@ -42,7 +42,32 @@ protected: class CPartylineMod : public CModule { public: - MODCONSTRUCTOR(CPartylineMod) {} + void ListChannelsCommand(const CString& sLine) { + if (!m_ssChannels.size()) { + PutModule("There are no open channels."); + return; + } + + CTable Table; + + Table.AddColumn("Channel"); + Table.AddColumn("Users"); + + for (set::const_iterator a = m_ssChannels.begin(); a != m_ssChannels.end(); ++a) { + Table.AddRow(); + + Table.SetCell("Channel", (*a)->GetName()); + Table.SetCell("Users", CString((*a)->GetNicks().size())); + } + + PutModule(Table); + } + + MODCONSTRUCTOR(CPartylineMod) { + AddHelpCommand(); + AddCommand("List", static_cast(&CPartylineMod::ListChannelsCommand), + "", "List all open channels"); + } virtual ~CPartylineMod() { while (m_ssChannels.size()) { @@ -456,58 +481,6 @@ public: return HandleMessage("NOTICE", sTarget, "\001" + sMessage + "\001"); } - virtual void OnModCommand(const CString& sLine) { - CString sCommand = sLine.Token(0); - - if (sCommand.Equals("HELP")) { - CTable Table; - Table.AddColumn("Command"); - Table.AddColumn("Arguments"); - Table.AddColumn("Description"); - - Table.AddRow(); - Table.SetCell("Command", "Help"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "List all partyline commands"); - - Table.AddRow(); - Table.SetCell("Command", "List"); - Table.SetCell("Arguments", ""); - Table.SetCell("Description", "List all open channels"); - - PutModule(Table); - } else if (sCommand.Equals("LIST")) { - if (!m_ssChannels.size()) { - PutModule("There are no open channels."); - return; - } - - CTable Table; - - Table.AddColumn("Channel"); - Table.AddColumn("Users"); - - for (set::const_iterator a = m_ssChannels.begin(); a != m_ssChannels.end(); ++a) { - Table.AddRow(); - - Table.SetCell("Channel", (*a)->GetName()); - Table.SetCell("Users", CString((*a)->GetNicks().size())); - } - - PutModule(Table); - } else if (sCommand.Equals("ADDFIXCHAN")) { - PutModule("Sorry, support for fixed channels was dropped"); - } else if (sCommand.Equals("DELFIXCHAN")) { - PutModule("Sorry, support for fixed channels was dropped"); - } else if (sCommand.Equals("LISTFIXCHANS")) { - PutModule("Sorry, support for fixed channels was dropped"); - } else if (sCommand.Equals("LISTFIXUSERS")) { - PutModule("Sorry, support for fixed channels was dropped"); - } else { - PutModule("Unknown command, try 'HELP'"); - } - } - const CString GetIRCServer(CIRCNetwork *pNetwork) { if (!pNetwork) { return "irc.znc.in";