summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.adoc1
-rw-r--r--doc/de/weechat_scripting.de.adoc3
-rw-r--r--doc/en/weechat_plugin_api.en.adoc57
-rw-r--r--doc/en/weechat_scripting.en.adoc3
-rw-r--r--doc/fr/weechat_plugin_api.fr.adoc57
-rw-r--r--doc/fr/weechat_scripting.fr.adoc5
-rw-r--r--doc/it/weechat_plugin_api.it.adoc61
-rw-r--r--doc/it/weechat_scripting.it.adoc3
-rw-r--r--doc/ja/weechat_plugin_api.ja.adoc61
-rw-r--r--doc/ja/weechat_scripting.ja.adoc5
-rw-r--r--doc/pl/weechat_scripting.pl.adoc7
-rw-r--r--po/cs.po18
-rw-r--r--po/de.po17
-rw-r--r--po/es.po18
-rw-r--r--po/fr.po17
-rw-r--r--po/hu.po21
-rw-r--r--po/it.po18
-rw-r--r--po/ja.po17
-rw-r--r--po/pl.po17
-rw-r--r--po/pt.po17
-rw-r--r--po/pt_BR.po20
-rw-r--r--po/ru.po21
-rw-r--r--po/tr.po6
-rw-r--r--po/weechat.pot6
-rw-r--r--src/core/wee-input.c23
-rw-r--r--src/core/wee-input.h2
-rw-r--r--src/plugins/guile/weechat-guile-api.c29
-rw-r--r--src/plugins/javascript/weechat-js-api.cpp28
-rw-r--r--src/plugins/lua/weechat-lua-api.c30
-rw-r--r--src/plugins/perl/weechat-perl-api.c30
-rw-r--r--src/plugins/php/weechat-php-api.c34
-rw-r--r--src/plugins/php/weechat-php-api.h1
-rw-r--r--src/plugins/php/weechat-php.c1
-rw-r--r--src/plugins/plugin-api.c40
-rw-r--r--src/plugins/plugin-api.h4
-rw-r--r--src/plugins/plugin-script-api.c27
-rw-r--r--src/plugins/plugin-script-api.h5
-rw-r--r--src/plugins/plugin.c1
-rw-r--r--src/plugins/python/weechat-python-api.c30
-rw-r--r--src/plugins/ruby/weechat-ruby-api.c36
-rw-r--r--src/plugins/tcl/weechat-tcl-api.c31
-rw-r--r--src/plugins/weechat-plugin.h8
-rw-r--r--tests/scripts/python/testapi.py8
43 files changed, 686 insertions, 158 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 1649d47d9..90cac3d34 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -21,6 +21,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
New features::
* core: add option "addreplace" in command /filter (issue #1055, issue #1312)
+ * api: add function command_options (issue #928)
* api: add function string_match_list
* spell: rename aspell plugin to spell (issue #1299)
diff --git a/doc/de/weechat_scripting.de.adoc b/doc/de/weechat_scripting.de.adoc
index 0187722ec..352277c37 100644
--- a/doc/de/weechat_scripting.de.adoc
+++ b/doc/de/weechat_scripting.de.adoc
@@ -604,7 +604,8 @@ Liste der Skript API Funktionen:
bar_remove
| Befehle |
- command
+ command +
+ command_options
| Informationen |
info_get +
diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc
index c60adc90e..edc10be7c 100644
--- a/doc/en/weechat_plugin_api.en.adoc
+++ b/doc/en/weechat_plugin_api.en.adoc
@@ -14375,6 +14375,63 @@ weechat.command(buffer, command)
rc = weechat.command(weechat.buffer_search("irc", "freenode.#weechat"), "/whois FlashCode")
----
+==== command_options
+
+_WeeChat ≥ 2.5._
+
+Execute a command or send text to buffer with options.
+
+Prototype:
+
+[source,C]
+----
+int weechat_command_options (struct t_gui_buffer *buffer, const char *command,
+ struct t_hashtable *options);
+----
+
+Arguments:
+
+* _buffer_: buffer pointer (command is executed on this buffer, use NULL for
+ current buffer)
+* _command_: command to execute (if beginning with a "/"), or text to send to
+ buffer
+* _options_: a hashtable with some options (keys and values must be string)
+ (can be NULL):
+** _commands_: a comma-separated list of commands allowed to be executed during
+ this call; see function <<_string_match_list,string_match_list>> for the
+ format
+
+Return value:
+
+* _WEECHAT_RC_OK_ if successful
+* _WEECHAT_RC_ERROR_ if error
+
+C example:
+
+[source,C]
+----
+/* allow any command except /exec */
+int rc;
+struct t_hashtable *options = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+weechat_hashtable_set (options, "commands", "*,!exec");
+rc = weechat_command_options (NULL, "/some_command arguments", options);
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototype
+weechat.command_options(buffer, command, options)
+
+# example: allow any command except /exec
+rc = weechat.command("", "/some_command arguments", {"commands": "*,!exec"})
+----
+
[[network]]
=== Network
diff --git a/doc/en/weechat_scripting.en.adoc b/doc/en/weechat_scripting.en.adoc
index 166416bea..eebd7ffd0 100644
--- a/doc/en/weechat_scripting.en.adoc
+++ b/doc/en/weechat_scripting.en.adoc
@@ -591,7 +591,8 @@ List of functions in script API:
bar_remove
| commands |
- command
+ command +
+ command_options
| infos |
info_get +
diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc
index 2f263a2a3..b6805684f 100644
--- a/doc/fr/weechat_plugin_api.fr.adoc
+++ b/doc/fr/weechat_plugin_api.fr.adoc
@@ -14691,6 +14691,63 @@ weechat.command(buffer, command)
rc = weechat.command(weechat.buffer_search("irc", "freenode.#weechat"), "/whois FlashCode")
----
+==== command_options
+
+_WeeChat ≥ 2.5._
+
+Exécuter une commande ou envoyer du texte au tampon avec des options.
+
+Prototype :
+
+[source,C]
+----
+int weechat_command_options (struct t_gui_buffer *buffer, const char *command,
+ struct t_hashtable *options);
+----
+
+Paramètres :
+
+* _buffer_ : pointeur vers le tampon (la commande est exécutée sur ce tampon,
+ NULL pour le tampon courant)
+* _command_ : commande à exécuter (si elle commence par "/"), ou texte à
+ envoyer au tampon
+* _options_ : table de hachage avec des options (les clés et valeurs doivent
+ être des chaînes) (peut être NULL) :
+** _commands_ : une liste de commandes autorisées pendant l'appel, séparées par
+ des virgules ; voir la fonction <<_string_match_list,string_match_list>>
+ pour le format
+
+Valeur de retour :
+
+* _WEECHAT_RC_OK_ si ok
+* _WEECHAT_RC_ERROR_ si erreur
+
+Exemple en C :
+
+[source,C]
+----
+/* autoriser toute commande sauf /exec */
+int rc;
+struct t_hashtable *options = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+weechat_hashtable_set (options, "commands", "*,!exec");
+rc = weechat_command_options (NULL, "/une_commande paramètres", options);
+----
+
+Script (Python) :
+
+[source,python]
+----
+# prototype
+weechat.command_options(buffer, command, options)
+
+# exemple : autoriser toute commande sauf /exec
+rc = weechat.command("", "/une_commande paramètres", {"commands": "*,!exec"})
+----
+
[[network]]
=== Réseau
diff --git a/doc/fr/weechat_scripting.fr.adoc b/doc/fr/weechat_scripting.fr.adoc
index a7c3fb075..61acecebc 100644
--- a/doc/fr/weechat_scripting.fr.adoc
+++ b/doc/fr/weechat_scripting.fr.adoc
@@ -603,9 +603,10 @@ Liste des fonctions de l'API script :
bar_remove
| commandes |
- command
+ command +
+ command_options
-| infos |
+| infos |
info_get +
info_get_hashtable
diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc
index b8c189798..899747e7e 100644
--- a/doc/it/weechat_plugin_api.it.adoc
+++ b/doc/it/weechat_plugin_api.it.adoc
@@ -14953,6 +14953,67 @@ weechat.command(buffer, command)
rc = weechat.command(weechat.buffer_search("irc", "freenode.#weechat"), "/whois FlashCode")
----
+==== command_options
+
+_WeeChat ≥ 2.5._
+
+// TRANSLATION MISSING
+Execute a command or send text to buffer with options.
+
+Prototipo:
+
+[source,C]
+----
+int weechat_command_options (struct t_gui_buffer *buffer, const char *command,
+ struct t_hashtable *options);
+----
+
+Argomenti:
+
+* _buffer_: puntatore al buffer (il comando viene eseguito su questo buffer,
+ utilizzare NULL per il buffer corrente)
+* _command_: comando da eseguire (se preceduto da "/"), oppure il testo
+ viene inviato sul buffer
+// TRANSLATION MISSING
+* _options_: a hashtable with some options (keys and values must be string)
+ (can be NULL):
+** _commands_: a comma-separated list of commands allowed to be executed during
+ this call; see function <<_string_match_list,string_match_list>> for the
+ format
+
+Valori restituiti:
+
+* _WEECHAT_RC_OK_ se l'operazione ha successo
+* _WEECHAT_RC_ERROR_ se c'è un errore
+
+Esempio in C:
+
+// TRANSLATION MISSING
+[source,C]
+----
+/* allow any command except /exec */
+int rc;
+struct t_hashtable *options = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+weechat_hashtable_set (options, "commands", "*,!exec");
+rc = weechat_command_options (NULL, "/some_command arguments", options);
+----
+
+Script (Python):
+
+// TRANSLATION MISSING
+[source,python]
+----
+# prototipo
+weechat.command_options(buffer, command, options)
+
+# example: allow any command except /exec
+rc = weechat.command("", "/some_command arguments", {"commands": "*,!exec"})
+----
+
[[network]]
=== Network
diff --git a/doc/it/weechat_scripting.it.adoc b/doc/it/weechat_scripting.it.adoc
index 113243d81..0756dc6cc 100644
--- a/doc/it/weechat_scripting.it.adoc
+++ b/doc/it/weechat_scripting.it.adoc
@@ -611,7 +611,8 @@ Elenco di funzioni nelle API per gli script:
bar_remove
| comandi |
- comando
+ command +
+ command_options
| info |
info_get +
diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc
index a5d56088f..77f5c587f 100644
--- a/doc/ja/weechat_plugin_api.ja.adoc
+++ b/doc/ja/weechat_plugin_api.ja.adoc
@@ -14335,6 +14335,67 @@ weechat.command(buffer, command)
rc = weechat.command(weechat.buffer_search("irc", "freenode.#weechat"), "/whois FlashCode")
----
+==== command_options
+
+_WeeChat ≥ 2.5._
+
+// TRANSLATION MISSING
+Execute a command or send text to buffer with options.
+
+プロトタイプ:
+
+[source,C]
+----
+int weechat_command_options (struct t_gui_buffer *buffer, const char *command,
+ struct t_hashtable *options);
+----
+
+引数:
+
+* _buffer_: バッファへのポインタ
+ (コマンドは指定したバッファで実行されます、現在のバッファで実行するには NULL を指定してください)
+* _command_: 実行するコマンド ("/"
+ で始まっている場合)、またはバッファに送信するテキスト
+// TRANSLATION MISSING
+* _options_: a hashtable with some options (keys and values must be string)
+ (can be NULL):
+** _commands_: a comma-separated list of commands allowed to be executed during
+ this call; see function <<_string_match_list,string_match_list>> for the
+ format
+
+戻り値:
+
+* _WEECHAT_RC_OK_ 成功した場合
+* _WEECHAT_RC_ERROR_ エラーが起きた場合
+
+C 言語での使用例:
+
+// TRANSLATION MISSING
+[source,C]
+----
+/* allow any command except /exec */
+int rc;
+struct t_hashtable *options = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+weechat_hashtable_set (options, "commands", "*,!exec");
+rc = weechat_command_options (NULL, "/some_command arguments", options);
+----
+
+スクリプト (Python) での使用例:
+
+// TRANSLATION MISSING
+[source,python]
+----
+# プロトタイプ
+weechat.command_options(buffer, command, options)
+
+# example: allow any command except /exec
+rc = weechat.command("", "/some_command arguments", {"commands": "*,!exec"})
+----
+
[[network]]
=== ネットワーク
diff --git a/doc/ja/weechat_scripting.ja.adoc b/doc/ja/weechat_scripting.ja.adoc
index f37cc2595..9fba9374e 100644
--- a/doc/ja/weechat_scripting.ja.adoc
+++ b/doc/ja/weechat_scripting.ja.adoc
@@ -570,7 +570,7 @@ link:weechat_plugin_api.ja.html[WeeChat プラグイン API リファレンス]
window_get_pointer +
window_set_title
-| ニックネームリスト |
+| ニックネームリスト |
nicklist_add_group +
nicklist_search_group +
nicklist_add_nick +
@@ -599,7 +599,8 @@ link:weechat_plugin_api.ja.html[WeeChat プラグイン API リファレンス]
bar_remove
| コマンド |
- command
+ command +
+ command_options
| インフォ |
info_get +
diff --git a/doc/pl/weechat_scripting.pl.adoc b/doc/pl/weechat_scripting.pl.adoc
index 148118ab3..ff7111c4f 100644
--- a/doc/pl/weechat_scripting.pl.adoc
+++ b/doc/pl/weechat_scripting.pl.adoc
@@ -466,7 +466,7 @@ Lista funkcji w API skryptów:
list_remove_all +
list_free
-| pliki konfiguracyjne|
+| pliki konfiguracyjne |
config_new +
config_new_section +
config_search_section +
@@ -504,7 +504,7 @@ Lista funkcji w API skryptów:
config_set_desc_plugin +
config_unset_plugin
-| przypisania klawiszy|
+| przypisania klawiszy |
key_bind +
key_unbind
@@ -597,7 +597,8 @@ Lista funkcji w API skryptów:
bar_remove
| komendy |
- command
+ command +
+ command_options
| informacje |
info_get +
diff --git a/po/cs.po b/po/cs.po
index d20fe0f4f..bc9a1f295 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
-"PO-Revision-Date: 2019-01-29 21:01+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
+"PO-Revision-Date: 2019-02-28 20:18+0100\n"
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: cs\n"
@@ -4130,6 +4130,10 @@ msgstr "%sChyba odesílání signálu %d na pid %d: %s"
msgid "%sYou can not write text in this buffer"
msgstr "%sDo tohoto bufferu nemůžete zapisovat text"
+#, fuzzy, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr "%sBarva \"%s\" není definovávána v paletě"
+
#, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr "%sChyba: neznámý příkaz \"%s\" (napište /help pro nápovědu)"
@@ -12680,13 +12684,3 @@ msgstr "%s%s: vypršel časový limit \"%s\" pro %s"
#, c-format
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr "%s%s: nemohu se připojit\" neočekávaná chyba (%d)"
-
-#, fuzzy
-#~ msgid "a filter with same name already exists"
-#~ msgstr "%sChyba: buffer se stejným jménem (%s) už existuje"
-
-#~ msgid "Aspell enabled"
-#~ msgstr "Aspell povolen"
-
-#~ msgid "Aspell disabled"
-#~ msgstr "Aspell zakázán"
diff --git a/po/de.po b/po/de.po
index 556cea239..406f9ba3d 100644
--- a/po/de.po
+++ b/po/de.po
@@ -24,8 +24,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
-"PO-Revision-Date: 2019-02-23 23:18+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
+"PO-Revision-Date: 2019-02-28 20:18+0100\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <kde-i18n-de@kde.org>\n"
"Language: de\n"
@@ -4981,6 +4981,10 @@ msgstr "%sFehler beim Versenden des Signals %d an pid %d: %s"
msgid "%sYou can not write text in this buffer"
msgstr "%sIn diesen Buffer kann nicht geschrieben werden"
+#, fuzzy, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr "%sBefehl \"/%s eval\" ist zur Zeit noch nicht implementiert"
+
#, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr ""
@@ -14801,12 +14805,3 @@ msgstr "%s%s: Zeitüberschreitung für \"%s\" mit %s"
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr ""
"%s%s: Verbindung konnte nicht hergestellt werden: unerwarteter Fehler (%d)"
-
-#~ msgid "a filter with same name already exists"
-#~ msgstr "es existiert bereits ein Filter mit dem selben Namen"
-
-#~ msgid "Aspell enabled"
-#~ msgstr "Aspell wurde aktiviert"
-
-#~ msgid "Aspell disabled"
-#~ msgstr "Aspell wurde deaktiviert"
diff --git a/po/es.po b/po/es.po
index 05a99a2b6..6fd98f8b3 100644
--- a/po/es.po
+++ b/po/es.po
@@ -22,8 +22,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
-"PO-Revision-Date: 2019-01-29 21:02+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
+"PO-Revision-Date: 2019-02-28 20:18+0100\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: es\n"
@@ -4323,6 +4323,10 @@ msgstr ""
msgid "%sYou can not write text in this buffer"
msgstr "%sNo es posible escribir texto en este buffer"
+#, fuzzy, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr "%sColor \"%s\" no está definido en la paleta"
+
#, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr "%sError: comando \"%s\" desconocido (use /help para ver la ayuda)"
@@ -12964,13 +12968,3 @@ msgstr "%s%s: tiempo de espera máximo para \"%s\" con %s"
#, fuzzy, c-format
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr "%s%s: no es posible conectarse al transmisor"
-
-#, fuzzy
-#~ msgid "a filter with same name already exists"
-#~ msgstr "%sError: un buffer con el mismo nombre (%s) ya existe"
-
-#~ msgid "Aspell enabled"
-#~ msgstr "Aspell activado"
-
-#~ msgid "Aspell disabled"
-#~ msgstr "Aspell desactivado"
diff --git a/po/fr.po b/po/fr.po
index a8dda2bbe..8a7a21349 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
-"PO-Revision-Date: 2019-02-23 13:40+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
+"PO-Revision-Date: 2019-02-28 20:18+0100\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@@ -4853,6 +4853,10 @@ msgid "%sYou can not write text in this buffer"
msgstr "%sVous ne pouvez pas écrire de texte dans ce tampon"
#, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr "debug : la commande \"%s\" n'est pas autorisée dans ce contexte"
+
+#, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr "%sErreur : commande \"%s\" inconnue (tapez /help pour l'aide)"
@@ -14499,12 +14503,3 @@ msgstr "%s%s : délai d'attente dépassé pour \"%s\" avec %s"
#, c-format
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr "%s%s : impossible de se connecter : erreur inattendue (%d)"
-
-#~ msgid "a filter with same name already exists"
-#~ msgstr "un filtre avec le même nom existe déjà"
-
-#~ msgid "Aspell enabled"
-#~ msgstr "Aspell activé"
-
-#~ msgid "Aspell disabled"
-#~ msgstr "Aspell désactivé"
diff --git a/po/hu.po b/po/hu.po
index a209dbfdc..c0d0880d7 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -20,8 +20,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
-"PO-Revision-Date: 2018-11-17 10:36+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
+"PO-Revision-Date: 2019-02-28 20:18+0100\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: hu\n"
@@ -3697,6 +3697,10 @@ msgstr ""
msgid "%sYou can not write text in this buffer"
msgstr "%s az utolsó puffert nem lehet bezárni\n"
+#, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr ""
+
#, fuzzy, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr "%s a \"%s\" aliasz vagy parancs nem található\n"
@@ -11951,16 +11955,3 @@ msgstr "%s hiányzó argumentum a(z) \"%s\" opciónak\n"
#, fuzzy, c-format
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr "%s DCC: nem sikerült kapcsolódni a küldőhöz\n"
-
-#, fuzzy
-#~ msgid "a filter with same name already exists"
-#~ msgstr ""
-#~ "%s nem sikerült a \"%s\" modult betölteni: már van ilyen nevű modul\n"
-
-#, fuzzy
-#~ msgid "Aspell enabled"
-#~ msgstr "a felhasználók le lettek tiltva"
-
-#, fuzzy
-#~ msgid "Aspell disabled"
-#~ msgstr "Nincs aliasz definiálva.\n"
diff --git a/po/it.po b/po/it.po
index 805d6291e..720af6a67 100644
--- a/po/it.po
+++ b/po/it.po
@@ -20,8 +20,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
-"PO-Revision-Date: 2019-01-29 21:03+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
+"PO-Revision-Date: 2019-02-28 20:18+0100\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: it\n"
@@ -4438,6 +4438,10 @@ msgstr ""
msgid "%sYou can not write text in this buffer"
msgstr "%sNon è possibile scrivere del testo in questo buffer"
+#, fuzzy, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr "%sColore \"%s\" non definito nella tavolozza"
+
#, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr "%sErrore: comando \"%s\" sconosciuto (digita /help per l'aiuto)"
@@ -13181,13 +13185,3 @@ msgstr "%s%s: timeout per \"%s\" con %s"
#, fuzzy, c-format
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr "%s%s: impossibile connettersi al mittente"
-
-#, fuzzy
-#~ msgid "a filter with same name already exists"
-#~ msgstr "%sErrore: un buffer con lo stesso nome (%s) esiste già"
-
-#~ msgid "Aspell enabled"
-#~ msgstr "Aspell abilitato"
-
-#~ msgid "Aspell disabled"
-#~ msgstr "Aspell disabilitato"
diff --git a/po/ja.po b/po/ja.po
index 9cfd873a9..2bb6c9a4b 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -20,8 +20,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
-"PO-Revision-Date: 2019-02-03 19:01+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
+"PO-Revision-Date: 2019-02-28 20:18+0100\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/weechat/tree/master/"
"translation/ja_JP>\n"
@@ -4642,6 +4642,10 @@ msgstr "%sシグナル %d を pid %d に送信中にエラー: %s"
msgid "%sYou can not write text in this buffer"
msgstr "%sこのバッファに書き込むことは出来ません"
+#, fuzzy, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr "%sコマンド \"/%s eval\" はまだ実装されていません"
+
#, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr "%sエラー: 未定義のコマンド \"%s\" (ヘルプを見るには /help を入力)"
@@ -13967,12 +13971,3 @@ msgstr "%s%s: \"%s\" のタイムアウト %s"
#, c-format
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr "%s%s: 接続できません: 未定義のエラー (%d)"
-
-#~ msgid "a filter with same name already exists"
-#~ msgstr "同名のフィルタが既に存在します"
-
-#~ msgid "Aspell enabled"
-#~ msgstr "Aspell が有効化されています"
-
-#~ msgid "Aspell disabled"
-#~ msgstr "Aspell が無効化されています"
diff --git a/po/pl.po b/po/pl.po
index 52f4c47d6..06eb111ed 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -22,8 +22,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
-"PO-Revision-Date: 2019-02-09 21:00+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
+"PO-Revision-Date: 2019-02-28 20:19+0100\n"
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
"Language-Team: Polish <kde-i18n-doc@kde.org>\n"
"Language: pl\n"
@@ -4750,6 +4750,10 @@ msgstr "%sBłąd wysyłania sygnału %d do pid %d: %s"
msgid "%sYou can not write text in this buffer"
msgstr "%s nie możesz nic pisać w tym buforze"
+#, fuzzy, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr "%sKomenda \"/%s eval\" nie jest jeszcze zaimplementowana"
+
#, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr "%sBłąd: nieznana komenda \"%s\" (wpisz /help , aby uzyskać pomoc)"
@@ -14187,12 +14191,3 @@ msgstr "%s%s: przekroczono czas na \"%s\" z %s"
#, c-format
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr "%s%s: nie można połączyć: niespodziewany błąd (%d)"
-
-#~ msgid "a filter with same name already exists"
-#~ msgstr "filtr o tej nazwie już istnieje"
-
-#~ msgid "Aspell enabled"
-#~ msgstr "Aspell włączony"
-
-#~ msgid "Aspell disabled"
-#~ msgstr "Aspell wyłączony"
diff --git a/po/pt.po b/po/pt.po
index 2a704fbd0..1cd75a15f 100644
--- a/po/pt.po
+++ b/po/pt.po
@@ -20,8 +20,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
-"PO-Revision-Date: 2019-02-03 19:01+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
+"PO-Revision-Date: 2019-02-28 20:19+0100\n"
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
"Language-Team: Portuguese <>\n"
"Language: pt\n"
@@ -4690,6 +4690,10 @@ msgstr "%sErro ao enviar o sinal %d ao pid %d: %s"
msgid "%sYou can not write text in this buffer"
msgstr "%sNão pode escrever texto neste buffer"
+#, fuzzy, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr "%sA cor \"%s\" não está definida na paleta"
+
#, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr "%sErro: comando desconhecido: \"%s\" (escreva /help para obter ajuda)"
@@ -13846,12 +13850,3 @@ msgstr "%s%s: tempo limite de \"%s\" com %s"
#, c-format
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr "%s%s: não foi possível conectar: erro inesperado (%d)"
-
-#~ msgid "a filter with same name already exists"
-#~ msgstr "já existe um filtro com o mesmo nome"
-
-#~ msgid "Aspell enabled"
-#~ msgstr "Aspell ativado"
-
-#~ msgid "Aspell disabled"
-#~ msgstr "Aspell desativado"
diff --git a/po/pt_BR.po b/po/pt_BR.po
index ef61028e3..c5aa6ba57 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
-"PO-Revision-Date: 2019-01-29 21:05+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
+"PO-Revision-Date: 2019-02-28 20:19+0100\n"
"Last-Translator: Eduardo Elias <camponez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: pt_BR\n"
@@ -4320,6 +4320,10 @@ msgstr ""
msgid "%sYou can not write text in this buffer"
msgstr ""
+#, fuzzy, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr "%sCor \"%s\" não está definida na palheta"
+
#, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr ""
@@ -12418,15 +12422,3 @@ msgstr "%s%s: tempo esgotado para \"%s\" com %s"
#, fuzzy, c-format
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr "%s%s: não foi possível conectar ao remetente"
-
-#, fuzzy
-#~ msgid "a filter with same name already exists"
-#~ msgstr "%sErro: um buffer com o mesmo nome (%s) já existe"
-
-#, fuzzy
-#~ msgid "Aspell enabled"
-#~ msgstr "Mouse habilitado"
-
-#, fuzzy
-#~ msgid "Aspell disabled"
-#~ msgstr "Mouse desabilitado"
diff --git a/po/ru.po b/po/ru.po
index 8749e94c3..53b232ebd 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
-"PO-Revision-Date: 2018-11-17 10:36+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
+"PO-Revision-Date: 2019-02-28 20:19+0100\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: ru\n"
@@ -3727,6 +3727,10 @@ msgid "%sYou can not write text in this buffer"
msgstr "%s невозможно закрыть единственный буфер\n"
#, fuzzy, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr "%sЦвет \"%s\" не определён в палитре"
+
+#, fuzzy, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr "%s сокращение или команда \"%s\" не найдены\n"
@@ -11982,16 +11986,3 @@ msgstr "%s нет аргумента для параметра \"%s\"\n"
#, fuzzy, c-format
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr "%s DCC: не могу соединиться с отправителем\n"
-
-#, fuzzy
-#~ msgid "a filter with same name already exists"
-#~ msgstr ""
-#~ "%s не могу загрузить plugin \"%s\": одноимённый plugin уже существует\n"
-
-#, fuzzy
-#~ msgid "Aspell enabled"
-#~ msgstr "команда users отключена"
-
-#, fuzzy
-#~ msgid "Aspell disabled"
-#~ msgstr "Сокращения не заданы.\n"
diff --git a/po/tr.po b/po/tr.po
index 5db9ed4ee..57fd53ec9 100644
--- a/po/tr.po
+++ b/po/tr.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
"PO-Revision-Date: 2019-01-29 21:05+0100\n"
"Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -3354,6 +3354,10 @@ msgid "%sYou can not write text in this buffer"
msgstr ""
#, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr ""
+
+#, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr ""
diff --git a/po/weechat.pot b/po/weechat.pot
index c64a34e03..35ea1f655 100644
--- a/po/weechat.pot
+++ b/po/weechat.pot
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2019-02-23 13:36+0100\n"
+"POT-Creation-Date: 2019-02-28 20:16+0100\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -3344,6 +3344,10 @@ msgid "%sYou can not write text in this buffer"
msgstr ""
#, c-format
+msgid "debug: command \"%s\" is not allowed in this context"
+msgstr ""
+
+#, c-format
msgid "%sError: unknown command \"%s\" (type /help for help)"
msgstr ""
diff --git a/src/core/wee-input.c b/src/core/wee-input.c
index 4037df2aa..00c7edc3c 100644
--- a/src/core/wee-input.c
+++ b/src/core/wee-input.c
@@ -39,6 +39,9 @@
#include "../plugins/plugin.h"
+char **input_commands_allowed = NULL;
+
+
/*
* Sends data to buffer input callback.
*/
@@ -103,8 +106,25 @@ input_exec_command (struct t_gui_buffer *buffer,
return WEECHAT_RC_ERROR;
}
- /* execute command */
rc = WEECHAT_RC_OK;
+
+ /* check if command is allowed */
+ if (input_commands_allowed
+ && !string_match_list (command_name + 1,
+ (const char **)input_commands_allowed, 0))
+ {
+ if (weechat_debug_core >= 1)
+ {
+ gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER,
+ _("debug: command \"%s\" is not "
+ "allowed in this context"),
+ command_name);
+ }
+ rc = WEECHAT_RC_ERROR;
+ goto end;
+ }
+
+ /* execute command */
switch (hook_command_exec (buffer, any_plugin, plugin, command))
{
case HOOK_COMMAND_EXEC_OK:
@@ -171,6 +191,7 @@ input_exec_command (struct t_gui_buffer *buffer,
break;
}
+end:
free (command);
free (command_name);
diff --git a/src/core/wee-input.h b/src/core/wee-input.h
index a35f2284f..d6c6b3dac 100644
--- a/src/core/wee-input.h
+++ b/src/core/wee-input.h
@@ -23,6 +23,8 @@
struct t_gui_buffer;
struct t_weechat_plugin;
+extern char **input_commands_allowed;
+
extern int input_exec_command (struct t_gui_buffer *buffer,
int any_plugin,
struct t_weechat_plugin *plugin,
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c
index 29f8fbf78..410eebe49 100644
--- a/src/plugins/guile/weechat-guile-api.c
+++ b/src/plugins/guile/weechat-guile-api.c
@@ -4077,6 +4077,34 @@ weechat_guile_api_command (SCM buffer, SCM command)
}
SCM
+weechat_guile_api_command_options (SCM buffer, SCM command, SCM options)
+{
+ struct t_hashtable *c_options;
+ int rc;
+
+ API_INIT_FUNC(1, "command_options", API_RETURN_INT(WEECHAT_RC_ERROR));
+ if (!scm_is_string (buffer) || !scm_is_string (command)
+ || !scm_list_p (options))
+ API_WRONG_ARGS(API_RETURN_INT(WEECHAT_RC_ERROR));
+
+ c_options = weechat_guile_alist_to_hashtable (options,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ rc = plugin_script_api_command_options (weechat_guile_plugin,
+ guile_current_script,
+ API_STR2PTR(API_SCM_TO_STRING(buffer)),
+ API_SCM_TO_STRING(command),
+ c_options);
+
+ if (c_options)
+ weechat_hashtable_free (c_options);
+
+ API_RETURN_INT(rc);
+}
+
+SCM
weechat_guile_api_info_get (SCM info_name, SCM arguments)
{
const char *result;
@@ -5016,6 +5044,7 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(bar_update, 1);
API_DEF_FUNC(bar_remove, 1);
API_DEF_FUNC(command, 2);
+ API_DEF_FUNC(command_options, 3);
API_DEF_FUNC(info_get, 2);
API_DEF_FUNC(info_get_hashtable, 2);
API_DEF_FUNC(infolist_new, 0);
diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp
index 8f0032bac..7dd8272d4 100644
--- a/src/plugins/javascript/weechat-js-api.cpp
+++ b/src/plugins/javascript/weechat-js-api.cpp
@@ -3976,6 +3976,33 @@ API_FUNC(command)
API_RETURN_INT(rc);
}
+API_FUNC(command_options)
+{
+ struct t_hashtable *options;
+ int rc;
+
+ API_INIT_FUNC(1, "command_options", "ssh", API_RETURN_INT(WEECHAT_RC_ERROR));
+
+ v8::String::Utf8Value buffer(args[0]);
+ v8::String::Utf8Value command(args[1]);
+ options = weechat_js_object_to_hashtable (
+ args[2]->ToObject(),
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ rc = plugin_script_api_command_options (weechat_js_plugin,
+ js_current_script,
+ (struct t_gui_buffer *)API_STR2PTR(*buffer),
+ *command,
+ options);
+
+ if (options)
+ weechat_hashtable_free (options);
+
+ API_RETURN_INT(rc);
+}
+
API_FUNC(info_get)
{
const char *result;
@@ -4967,6 +4994,7 @@ WeechatJsV8::loadLibs()
API_DEF_FUNC(bar_update);
API_DEF_FUNC(bar_remove);
API_DEF_FUNC(command);
+ API_DEF_FUNC(command_options);
API_DEF_FUNC(info_get);
API_DEF_FUNC(info_get_hashtable);
API_DEF_FUNC(infolist_new);
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index a07709fa1..908097a4c 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -4312,6 +4312,35 @@ API_FUNC(command)
API_RETURN_INT(rc);
}
+API_FUNC(command_options)
+{
+ const char *buffer, *command;
+ struct t_hashtable *options;
+ int rc;
+
+ API_INIT_FUNC(1, "command_options", API_RETURN_INT(WEECHAT_RC_ERROR));
+ if (lua_gettop (L) < 3)
+ API_WRONG_ARGS(API_RETURN_INT(WEECHAT_RC_ERROR));
+
+ buffer = lua_tostring (L, -3);
+ command = lua_tostring (L, -2);
+ options = weechat_lua_tohashtable (L, -1,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ rc = plugin_script_api_command_options (weechat_lua_plugin,
+ lua_current_script,
+ API_STR2PTR(buffer),
+ command,
+ options);
+
+ if (options)
+ weechat_hashtable_free (options);
+
+ API_RETURN_INT(rc);
+}
+
API_FUNC(info_get)
{
const char *info_name, *arguments, *result;
@@ -5318,6 +5347,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(bar_update),
API_DEF_FUNC(bar_remove),
API_DEF_FUNC(command),
+ API_DEF_FUNC(command_options),
API_DEF_FUNC(info_get),
API_DEF_FUNC(info_get_hashtable),
API_DEF_FUNC(infolist_new),
diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c
index 9192bbe97..5c0ab0e0e 100644
--- a/src/plugins/perl/weechat-perl-api.c
+++ b/src/plugins/perl/weechat-perl-api.c
@@ -4233,6 +4233,35 @@ API_FUNC(command)
API_RETURN_INT(rc);
}
+API_FUNC(command_options)
+{
+ char *buffer, *command;
+ struct t_hashtable *options;
+ int rc;
+ dXSARGS;
+
+ API_INIT_FUNC(1, "command_options", API_RETURN_INT(WEECHAT_RC_ERROR));
+ if (items < 3)
+ API_WRONG_ARGS(API_RETURN_INT(WEECHAT_RC_ERROR));
+
+ buffer = SvPV_nolen (ST (0));
+ command = SvPV_nolen (ST (1));
+ options = weechat_perl_hash_to_hashtable (ST (2),
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ rc = plugin_script_api_command_options (weechat_perl_plugin,
+ perl_current_script,
+ API_STR2PTR(buffer),
+ command,
+ options);
+ if (options)
+ weechat_hashtable_free (options);
+
+ API_RETURN_INT(rc);
+}
+
API_FUNC(info_get)
{
char *info_name, *arguments;
@@ -5277,6 +5306,7 @@ weechat_perl_api_init (pTHX)
API_DEF_FUNC(bar_update);
API_DEF_FUNC(bar_remove);
API_DEF_FUNC(command);
+ API_DEF_FUNC(command_options);
API_DEF_FUNC(info_get);
API_DEF_FUNC(info_get_hashtable);
API_DEF_FUNC(infolist_new);
diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c
index e95bf5786..f648efd41 100644
--- a/src/plugins/php/weechat-php-api.c
+++ b/src/plugins/php/weechat-php-api.c
@@ -4144,6 +4144,40 @@ API_FUNC(command)
API_RETURN_INT(result);
}
+API_FUNC(command_options)
+{
+ zend_string *z_buffer, *z_command;
+ zval *z_options;
+ struct t_gui_buffer *buffer;
+ char *command;
+ struct t_hashtable *options;
+ int result;
+
+ API_INIT_FUNC(1, "command", API_RETURN_INT(WEECHAT_RC_ERROR));
+ if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSa", &z_buffer,
+ &z_command, &z_options) == FAILURE)
+ API_WRONG_ARGS(API_RETURN_INT(WEECHAT_RC_ERROR));
+
+ buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
+ command = ZSTR_VAL(z_command);
+ options = weechat_php_array_to_hashtable (
+ z_options,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ result = plugin_script_api_command_options (weechat_php_plugin,
+ php_current_script,
+ buffer,
+ (const char *)command,
+ options);
+
+ if (options)
+ weechat_hashtable_free (options);
+
+ API_RETURN_INT(result);
+}
+
API_FUNC(info_get)
{
zend_string *z_info_name, *z_arguments;
diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h
index ca01f3f02..06195a0b6 100644
--- a/src/plugins/php/weechat-php-api.h
+++ b/src/plugins/php/weechat-php-api.h
@@ -197,6 +197,7 @@ PHP_FUNCTION(weechat_bar_set);
PHP_FUNCTION(weechat_bar_update);
PHP_FUNCTION(weechat_bar_remove);
PHP_FUNCTION(weechat_command);
+PHP_FUNCTION(weechat_command_options);
PHP_FUNCTION(weechat_info_get);
PHP_FUNCTION(weechat_info_get_hashtable);
PHP_FUNCTION(weechat_infolist_new);
diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c
index f84e49f4f..85dd6b3ea 100644
--- a/src/plugins/php/weechat-php.c
+++ b/src/plugins/php/weechat-php.c
@@ -251,6 +251,7 @@ const zend_function_entry weechat_functions[] = {
PHP_FE(weechat_bar_update, NULL)
PHP_FE(weechat_bar_remove, NULL)
PHP_FE(weechat_command, NULL)
+ PHP_FE(weechat_command_options, NULL)
PHP_FE(weechat_info_get, NULL)
PHP_FE(weechat_info_get_hashtable, NULL)
PHP_FE(weechat_infolist_new, NULL)
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index 174ee9093..69615e8c4 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -28,6 +28,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
+#include "../core/wee-hashtable.h"
#include "../core/wee-hook.h"
#include "../core/wee-infolist.h"
#include "../core/wee-input.h"
@@ -294,19 +295,35 @@ plugin_api_color (const char *color_name)
}
/*
- * Executes a command on a buffer (simulates user entry).
+ * Executes a command on a buffer (simulates user entry) with options.
*/
int
-plugin_api_command (struct t_weechat_plugin *plugin,
- struct t_gui_buffer *buffer, const char *command)
+plugin_api_command_options (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer, const char *command,
+ struct t_hashtable *options)
{
- char *command2;
+ char *command2, **old_commands_allowed, **new_commands_allowed;
+ const char *ptr_commands;
int rc;
if (!plugin || !command)
return WEECHAT_RC_ERROR;
+ old_commands_allowed = input_commands_allowed;
+ new_commands_allowed = NULL;
+
+ if (options)
+ {
+ ptr_commands = hashtable_get (options, "commands");
+ if (ptr_commands)
+ {
+ new_commands_allowed = string_split (ptr_commands, ",", 0, 0,
+ NULL);
+ input_commands_allowed = new_commands_allowed;
+ }
+ }
+
command2 = string_iconv_to_internal (plugin->charset, command);
if (!buffer)
buffer = gui_current_window->buffer;
@@ -314,10 +331,25 @@ plugin_api_command (struct t_weechat_plugin *plugin,
if (command2)
free (command2);
+ if (new_commands_allowed)
+ string_free_split (new_commands_allowed);
+ input_commands_allowed = old_commands_allowed;
+
return rc;
}
/*
+ * Executes a command on a buffer (simulates user entry).
+ */
+
+int
+plugin_api_command (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer, const char *command)
+{
+ return plugin_api_command_options (plugin, buffer, command, NULL);
+}
+
+/*
* Modifier to decode ANSI colors.
*/
diff --git a/src/plugins/plugin-api.h b/src/plugins/plugin-api.h
index 405f1edbe..5223585b2 100644
--- a/src/plugins/plugin-api.h
+++ b/src/plugins/plugin-api.h
@@ -54,6 +54,10 @@ extern const char *plugin_api_prefix (const char *prefix);
extern const char *plugin_api_color (const char *color_name);
/* command */
+extern int plugin_api_command_options (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer,
+ const char *command,
+ struct t_hashtable *options);
extern int plugin_api_command (struct t_weechat_plugin *plugin,
struct t_gui_buffer *buffer,
const char *command);
diff --git a/src/plugins/plugin-script-api.c b/src/plugins/plugin-script-api.c
index bb797ced1..11b404d92 100644
--- a/src/plugins/plugin-script-api.c
+++ b/src/plugins/plugin-script-api.c
@@ -1279,13 +1279,15 @@ plugin_script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin,
}
/*
- * Executes a command on a buffer (simulates user entry).
+ * Executes a command on a buffer (simulates user entry) with options.
*/
int
-plugin_script_api_command (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- struct t_gui_buffer *buffer, const char *command)
+plugin_script_api_command_options (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script,
+ struct t_gui_buffer *buffer,
+ const char *command,
+ struct t_hashtable *options)
{
char *command2;
int rc;
@@ -1293,7 +1295,9 @@ plugin_script_api_command (struct t_weechat_plugin *weechat_plugin,
command2 = (script && script->charset && script->charset[0]) ?
weechat_iconv_to_internal (script->charset, command) : NULL;
- rc = weechat_command (buffer, (command2) ? command2 : command);
+ rc = weechat_command_options (buffer,
+ (command2) ? command2 : command,
+ options);
if (command2)
free (command2);
@@ -1302,6 +1306,19 @@ plugin_script_api_command (struct t_weechat_plugin *weechat_plugin,
}
/*
+ * Executes a command on a buffer (simulates user entry).
+ */
+
+int
+plugin_script_api_command (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script,
+ struct t_gui_buffer *buffer, const char *command)
+{
+ return plugin_script_api_command_options (weechat_plugin, script, buffer,
+ command, NULL);
+}
+
+/*
* Gets value of a script option (format in file is "plugin.script.option").
*/
diff --git a/src/plugins/plugin-script-api.h b/src/plugins/plugin-script-api.h
index ce7bd285a..55f6d55f3 100644
--- a/src/plugins/plugin-script-api.h
+++ b/src/plugins/plugin-script-api.h
@@ -353,6 +353,11 @@ extern struct t_gui_bar_item *plugin_script_api_bar_item_new (struct t_weechat_p
struct t_hashtable *extra_info),
const char *function,
const char *data);
+extern int plugin_script_api_command_options (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script,
+ struct t_gui_buffer *buffer,
+ const char *command,
+ struct t_hashtable *options);
extern int plugin_script_api_command (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index dd04d1a7d..6ed45e602 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -828,6 +828,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->bar_remove = &gui_bar_free;
new_plugin->command = &plugin_api_command;
+ new_plugin->command_options = &plugin_api_command_options;
new_plugin->network_pass_proxy = &network_pass_proxy;
new_plugin->network_connect_to = &network_connect_to;
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index f27d1e169..572ce70aa 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -4247,6 +4247,35 @@ API_FUNC(command)
API_RETURN_INT(rc);
}
+API_FUNC(command_options)
+{
+ char *buffer, *command;
+ struct t_hashtable *options;
+ int rc;
+ PyObject *dict;
+
+ API_INIT_FUNC(1, "command_options", API_RETURN_INT(WEECHAT_RC_ERROR));
+ buffer = NULL;
+ command = NULL;
+ options = NULL;
+ if (!PyArg_ParseTuple (args, "ssO", &buffer, &command, &dict))
+ API_WRONG_ARGS(API_RETURN_INT(WEECHAT_RC_ERROR));
+
+ options = weechat_python_dict_to_hashtable (dict,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+ rc = plugin_script_api_command_options (weechat_python_plugin,
+ python_current_script,
+ API_STR2PTR(buffer),
+ command,
+ options);
+ if (options)
+ weechat_hashtable_free (options);
+
+ API_RETURN_INT(rc);
+}
+
API_FUNC(info_get)
{
char *info_name, *arguments;
@@ -5227,6 +5256,7 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(bar_update),
API_DEF_FUNC(bar_remove),
API_DEF_FUNC(command),
+ API_DEF_FUNC(command_options),
API_DEF_FUNC(info_get),
API_DEF_FUNC(info_get_hashtable),
API_DEF_FUNC(infolist_new),
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index dbd7ce278..c5f0475d6 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -5119,6 +5119,41 @@ weechat_ruby_api_command (VALUE class, VALUE buffer, VALUE command)
}
static VALUE
+weechat_ruby_api_command_options (VALUE class, VALUE buffer, VALUE command,
+ VALUE options)
+{
+ char *c_buffer, *c_command;
+ struct t_hashtable *c_options;
+ int rc;
+
+ API_INIT_FUNC(1, "command_options", API_RETURN_INT(WEECHAT_RC_ERROR));
+ if (NIL_P (buffer) || NIL_P (command) || NIL_P (options))
+ API_WRONG_ARGS(API_RETURN_INT(WEECHAT_RC_ERROR));
+
+ Check_Type (buffer, T_STRING);
+ Check_Type (command, T_STRING);
+ Check_Type (options, T_HASH);
+
+ c_buffer = StringValuePtr (buffer);
+ c_command = StringValuePtr (command);
+ c_options = weechat_ruby_hash_to_hashtable (options,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ rc = plugin_script_api_command_options (weechat_ruby_plugin,
+ ruby_current_script,
+ API_STR2PTR(c_buffer),
+ c_command,
+ c_options);
+
+ if (c_options)
+ weechat_hashtable_free (c_options);
+
+ API_RETURN_INT(rc);
+}
+
+static VALUE
weechat_ruby_api_info_get (VALUE class, VALUE info_name, VALUE arguments)
{
char *c_info_name, *c_arguments;
@@ -6388,6 +6423,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(bar_update, 1);
API_DEF_FUNC(bar_remove, 1);
API_DEF_FUNC(command, 2);
+ API_DEF_FUNC(command_options, 3);
API_DEF_FUNC(info_get, 2);
API_DEF_FUNC(info_get_hashtable, 2);
API_DEF_FUNC(infolist_new, 0);
diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c
index 527380e48..08b7e4f93 100644
--- a/src/plugins/tcl/weechat-tcl-api.c
+++ b/src/plugins/tcl/weechat-tcl-api.c
@@ -4598,6 +4598,36 @@ API_FUNC(command)
API_RETURN_INT(rc);
}
+API_FUNC(command_options)
+{
+ Tcl_Obj *objp;
+ char *buffer, *command;
+ struct t_hashtable *options;
+ int i, rc;
+
+ API_INIT_FUNC(1, "command_options", API_RETURN_INT(WEECHAT_RC_ERROR));
+ if (objc < 4)
+ API_WRONG_ARGS(API_RETURN_INT(WEECHAT_RC_ERROR));
+
+ buffer = Tcl_GetStringFromObj (objv[1], &i);
+ command = Tcl_GetStringFromObj (objv[2], &i);
+ options = weechat_tcl_dict_to_hashtable (interp, objv[3],
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ rc = plugin_script_api_command_options (weechat_tcl_plugin,
+ tcl_current_script,
+ API_STR2PTR(buffer),
+ command,
+ options);
+
+ if (options)
+ weechat_hashtable_free (options);
+
+ API_RETURN_INT(rc);
+}
+
API_FUNC(info_get)
{
Tcl_Obj *objp;
@@ -5753,6 +5783,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
API_DEF_FUNC(bar_update);
API_DEF_FUNC(bar_remove);
API_DEF_FUNC(command);
+ API_DEF_FUNC(command_options);
API_DEF_FUNC(info_get);
API_DEF_FUNC(info_get_hashtable);
API_DEF_FUNC(infolist_new);
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index da4eda6ba..b802f1960 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -67,7 +67,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
-#define WEECHAT_PLUGIN_API_VERSION "20190226-01"
+#define WEECHAT_PLUGIN_API_VERSION "20190228-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -985,6 +985,9 @@ struct t_weechat_plugin
/* command */
int (*command) (struct t_weechat_plugin *plugin,
struct t_gui_buffer *buffer, const char *command);
+ int (*command_options) (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer, const char *command,
+ struct t_hashtable *options);
/* network */
int (*network_pass_proxy) (const char *proxy, int sock,
@@ -1899,6 +1902,9 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
/* command */
#define weechat_command(__buffer, __command) \
(weechat_plugin->command)(weechat_plugin, __buffer, __command)
+#define weechat_command_options(__buffer, __command, __options) \
+ (weechat_plugin->command_options)(weechat_plugin, __buffer, \
+ __command, __options)
/* network */
#define weechat_network_pass_proxy(__proxy, __sock, __address, __port) \
diff --git a/tests/scripts/python/testapi.py b/tests/scripts/python/testapi.py
index 5a4c19190..036d0bb92 100644
--- a/tests/scripts/python/testapi.py
+++ b/tests/scripts/python/testapi.py
@@ -200,6 +200,13 @@ def test_hooks():
weechat.unhook(hook_cmplt)
+def test_command():
+ """Test command functions."""
+ check(weechat.command('', '/mute') == 0)
+ check(weechat.command_options('', '/mute', {'commands': '*,!print'}) == 0)
+ check(weechat.command_options('', '/mute', {'commands': '*,!mute'}) == -1)
+
+
def infolist_cb(data, infolist_name, pointer, arguments):
"""Infolist callback."""
infolist = weechat.infolist_new()
@@ -244,6 +251,7 @@ def cmd_test_cb(data, buf, args):
test_key()
test_display()
test_hooks()
+ test_command()
test_infolist()
weechat.prnt('', ' > TESTS END')
return weechat.WEECHAT_RC_OK