//============================================================================= // // File : kvi_kvs_coresimplecommands_mr.cpp // Created on Fri 31 Oct 2003 00:04:25 by Szymon Stefanek // // This file is part of the KVIrc IRC client distribution // Copyright (C) 2003 Szymon Stefanek // // This program is FREE software. You can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your opinion) any later version. // // This program is distributed in the HOPE that it will be USEFUL, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, write to the Free Software Foundation, // Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // //============================================================================= #define __KVIRC__ #include "kvi_kvs_coresimplecommands.h" #include "kvi_window.h" #include "kvi_console.h" #include "kvi_query.h" #include "kvi_ircuserdb.h" #include "kvi_out.h" #include "kvi_locale.h" #include "kvi_app.h" #include "kvi_options.h" #include "kvi_fileutils.h" #include "kvi_filedialog.h" #include "kvi_ircconnection.h" #include "kvi_channel.h" #include "kvi_ircurl.h" #include "kvi_frame.h" #include "kvi_modulemanager.h" #include "kvi_kvs_moduleinterface.h" #include "kvi_kvs_variantlist.h" #include "kvi_kvs_script.h" #include "kvi_kvs_popupmanager.h" #include #include #include namespace KviKvsCoreSimpleCommands { ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* @doc: me @type: command @title: me @syntax: me @short: Sends a CTCP ACTION @description: Sends a CTCP ACTION to the current channel, query or dcc chat.[br] If you execute it in any other window type, you will get an error.[br] If you want to use this command in a window that is not a channel query or dcc chat, you may use the [doc:command_rebinding]standard -r switch[/doc]. @examples: [example] me is Hungry! [/example] */ KVSCSC(me) { QString szText; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("text",KVS_PT_STRING,KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING,szText) KVSCSC_PARAMETERS_END KVSCSC_REQUIRE_CONNECTION switch(KVSCSC_pWindow->type()) { case KVI_WINDOW_TYPE_CHANNEL: case KVI_WINDOW_TYPE_QUERY: case KVI_WINDOW_TYPE_DCCCHAT: KVSCSC_pWindow->ownAction(szText); break; default: KVSCSC_pContext->warning(__tr2qs("/me can be used only in channels, queries and DCC chat windows")); break; } return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* @doc: mode @type: command @title: mode @syntax: mode [mode parameters] @short: Sends a MODE irc message @description: Sends a MODE irc message to the server of the current IRC context.[br] The parameters are not modified in any way by KVIrc: so you should use the RFC1459 syntax.[br] This command is [doc:connection_dependant_commands]connection dependant[/doc]. @examples: [example] mode #kvirc +oo-b Pragma Buti *!*root@* [/example] */ KVSCSC(mode) { QString szText; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("text",KVS_PT_STRING,KVS_PF_APPENDREMAINING,szText) KVSCSC_PARAMETERS_END KVSCSC_REQUIRE_CONNECTION KviQCString szTxt = KVSCSC_pConnection->encodeText(szText); if(!szTxt.isEmpty()) { if(!KVSCSC_pConnection->sendFmtData("MODE %s",szTxt.data())) return KVSCSC_pContext->warningNoIrcConnection(); } return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* @doc: motd @type: command @title: motd @syntax: motd [target server] @short: Requests the Message of the day @description: Requests the Message of the day from the specified server or the current server if no [target server] is specified.[br] This command is a [doc:rfc2821wrappers]RFC2821 command wrapper[/doc]; see that document for more information.[br] */ // RCF2821 wrapper ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* @doc: msg @type: command @title: msg @syntax: msg [-q] @short: Alias for privmsg @switches: !sw: -q | --quiet Do not print any output @description: Sends a private message to the specified . may be any PRIVMSG target allowed by the underlying IRC protocol (see RFC1459). This is really similar to [cmd]privmsg[/cmd] but also outputs the message locally (unless the [-q] switch is used).[br] This command is [doc:connection_dependant_commands]connection dependant[/doc].[br] */ // Internally aliased to privmsg ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* @doc: nick @type: command @title: nick @syntax: nick @short: Changes your nickname @description: Changes your nickname in the connection associated to the current [b]IRC context[/b].[br] This command is "server based"; this means that the effects will be visible only after the server has acknowledged the change.[br] This command is [doc:connection_dependant_commands]connection dependant[/doc].[br] @examples: [example] nick Pragma [/example] */ KVSCSC(nick) { QString szNick; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("nickname",KVS_PT_NONEMPTYSTRING,0,szNick) KVSCSC_PARAMETERS_END KVSCSC_REQUIRE_CONNECTION KviQCString szData = KVSCSC_pConnection->encodeText(szNick); if(!szData.data())szData = ""; if(!KVSCSC_pConnection->sendFmtData("NICK %s",szData.data())) return KVSCSC_pContext->warningNoIrcConnection(); return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* @doc: notice @type: command @title: notice @syntax: notice [-q] @short: Sends a private notice @switches: !sw: -q | --quiet Do not print any output @description: Sends a private notice to the specified . may be any NOTICE target allowed by the underlying IRC protocol (see RFC1459). If the [-q] switch is specified, no output is printed. This command is [doc:connection_dependant_commands]connection dependant[/doc].[br] @examples: [example] notice Pragma Hello! notice Pragma,Crocodile Hello to you both! notice #kvirc Hello from outside! [/example] */ KVSCSC(notice) { QString szTarget,szText; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("target",KVS_PT_NONEMPTYSTRING,0,szTarget) KVSCSC_PARAMETER("text",KVS_PT_STRING,KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING,szText) KVSCSC_PARAMETERS_END KVSCSC_REQUIRE_CONNECTION KviWindow * w = KVSCSC_pConnection->findChannel(szTarget); if(!w)w = KVSCSC_pConnection->findQuery(szTarget); KviQCString szT = KVSCSC_pConnection->encodeText(szTarget); KviQCString szD = w ? w->encodeText(szText) : KVSCSC_pConnection->encodeText(szText); if(!szT.data())szT = ""; // encoding problems ? if(!szD.data())szD = ""; // encoding problems ? if(!(KVSCSC_pConnection->sendFmtData("NOTICE %s :%s",szT.data(),szD.data()))) return KVSCSC_pContext->warningNoIrcConnection(); if(!KVSCSC_pSwitches->find('q',"quiet")) KVSCSC_pWindow->output(KVI_OUT_OWNPRIVMSG,"[NOTICE >>> %Q]: %Q",&szTarget,&szText); return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* @doc: op @type: command @title: op @syntax: op @short: Sets chanop status to the specified users @description: Sets channel operator status to the users specified in , which is a comma separated list of nicknames. This command works only if executed in a channel window. The command is translated to a set of MODE messages containing a variable number of +o flags. This command is [doc:connection_dependant_commands]connection dependant[/doc]. @examples: [example] op Pragma,Crocodile [/example] @seealso: [cmd]deop[/cmd], [cmd]voice[/cmd], [cmd]devoice[/cmd] */ KVSCSC(op) { return multipleModeCommand(__pContext,__pParams,__pSwitches,'+','o'); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* @doc: openurl @type: command @title: openurl @syntax: openurl @short: Opens an url @description: Opens the specified with an appropriate handler.
The handlers for the supported url types are specified in the options dialog.
Each handler is a kvirc commandline that the url will be passed to as the first parameter ($0).
The supported url types are:
HTTP: http://<url> or sth that begins with "www."
HTTPS: https://<url>
FILE: file://<url>
IRC: irc[s][6]://[:][/[?]] (Handled internally)
FTP: ftp:// or sth that begins with "ftp."
MAIL: mailto:
@examples: [example] openurl http://www.kvirc.net openurl https://www.secure.net openurl file://home/pragma/pippo.txt openurl irc://irc.eu.dal.net:6667 openurl irc6://irc.ircd.it/#kvirc openurl ircs://crypto.azzurra.org:9999 openurl ircs6://ngnet.azzurra.org:9999 openurl ftp://ftp.localhost.net/pub/kvirc/ openurl mailto:users@domain.extension [/example] */ KVSCSC(openurl) { QString szUrl; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("url",KVS_PT_NONEMPTYSTRING,KVS_PF_APPENDREMAINING,szUrl) KVSCSC_PARAMETERS_END QString szCommand; if(KviQString::equalCIN(szUrl,"www.",4)) { szCommand = KVI_OPTION_STRING(KviOption_stringUrlHttpCommand); szUrl.prepend("http://"); } else if(KviQString::equalCIN(szUrl,"http:",5)) { szCommand = KVI_OPTION_STRING(KviOption_stringUrlHttpCommand); } else if(KviQString::equalCIN(szUrl,"https:",6)) { szCommand = KVI_OPTION_STRING(KviOption_stringUrlHttpsCommand); } else if(KviQString::equalCIN(szUrl,"ftp",3)) { szCommand = KVI_OPTION_STRING(KviOption_stringUrlFtpCommand); if(KviQString::equalCIN(szUrl,"ftp.",4))szUrl.prepend("ftp://"); } else if(KviQString::equalCIN(szUrl,"file",4)) { szCommand = KVI_OPTION_STRING(KviOption_stringUrlFileCommand); } else if(KviQString::equalCIN(szUrl,"irc",3)) { if(KviIrcUrl::run(szUrl,KviIrcUrl::FirstFreeContext,KVSCSC_pContext->console()) & KviIrcUrl::InvalidProtocol) { KVSCSC_pContext->warning(__tr2qs("Invalid IRC url (%Q)"),&szUrl); } return true; } else if(KviQString::equalCIN(szUrl,"mailto",6)) { szCommand = KVI_OPTION_STRING(KviOption_stringUrlMailtoCommand); } #ifdef COMPILE_ON_WINDOWS if(KVI_OPTION_BOOL(KviOption_boolUseSystemUrlHandlers)) { ShellExecute(NULL, "open", szUrl.local8Bit().data(), NULL, NULL, SW_SHOWNORMAL); } else { #endif if(szCommand.isEmpty())szCommand = KVI_OPTION_STRING(KviOption_stringUrlUnknownCommand); if(!szCommand.isEmpty()) { KviKvsVariantList vList; vList.append(new KviKvsVariant(szUrl)); QString szName = "openurl::handler"; KviKvsScript script(szName,szCommand); if(!script.run(KVSCSC_pWindow,&vList,0,KviKvsScript::PreserveParams)) KVSCSC_pContext->warning(__tr2qs("The commandline for this url type seems to be broken (%Q)"),&szUrl); } else KVSCSC_pContext->warning(__tr2qs("No commandline specified for this type of url (%Q)"),&szUrl); #ifdef COMPILE_ON_WINDOWS } #endif return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* @doc: oper @type: command @title: oper @syntax: oper @short: Requests IRC operator status @description: Requests IRC operator status.[br] This command is a [doc:rfc2821wrappers]RFC2821 command wrapper[/doc]; see that document for more information.[br] */ // RFC2821 wrapper ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* @doc: option @type: command @title: option @syntax: option [ ] @short: Sets an internal option @description: Sets an internal option named to the value . The value must be appropriate for the type of option that you're going to set.[br] With no parameters this command lists all the available option names sorted by option type.[br] The possible option types are:[br] [b]Boolean[/b]: must be "1" or "0"[br] [b]String[/b]: can be any string[br] [b]StringList[/b]: must be a comma separated list of strings (eventually empty)[br] [b]Color[/b]: must have the format #RRGGBB where R G and B are hex digits[br] [b]Font[/b]: is a comma separated list of font properties: ,,