mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 23:06:38 +02:00
Merge branch 'javascript'
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@ env:
|
||||
before_script:
|
||||
- echo 'APT::Install-Recommends "false";' | sudo tee -a /etc/apt/apt.conf
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get -y install devscripts equivs python-pip libenchant-dev autopoint asciidoc source-highlight xsltproc docbook-xsl docbook-xml cmake pkg-config libncursesw5-dev gem2deb libperl-dev python-dev python3-dev libaspell-dev liblua5.1-0-dev tcl8.5-dev guile-2.0-dev libcurl4-gnutls-dev libgcrypt11-dev libgnutls-dev zlib1g-dev curl
|
||||
- sudo apt-get -y install devscripts equivs python-pip libenchant-dev autopoint asciidoc source-highlight xsltproc docbook-xsl docbook-xml cmake pkg-config libncursesw5-dev gem2deb libperl-dev python-dev python3-dev libaspell-dev liblua5.1-0-dev tcl8.5-dev guile-2.0-dev libv8-dev libcurl4-gnutls-dev libgcrypt11-dev libgnutls-dev zlib1g-dev curl
|
||||
- curl -OL https://weechat.org/files/tests/ubuntu/precise/amd64/libcpputest-dev_3.4-3_amd64.deb
|
||||
- sudo dpkg -i libcpputest-dev_3.4-3_amd64.deb
|
||||
- sudo pip install msgcheck pylint
|
||||
|
||||
@@ -46,6 +46,7 @@ Alphabetically:
|
||||
* Jim Ramsay (lack)
|
||||
* Jiri Golembiovsky (GolemJ)
|
||||
* Julien Louis (ptitlouis)
|
||||
* Koka El Kiwi (KiwiDash)
|
||||
* Krzysztof Koroscik (soltys)
|
||||
* Kyle Fuller (kylef)
|
||||
* Lázaro A.
|
||||
|
||||
+28
-27
@@ -74,33 +74,34 @@ else()
|
||||
set(INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
option(ENABLE_NCURSES "Enable Ncurses interface" ON)
|
||||
option(ENABLE_NLS "Enable Native Language Support" ON)
|
||||
option(ENABLE_GNUTLS "Enable SSLv3/TLS support" ON)
|
||||
option(ENABLE_LARGEFILE "Enable Large File Support" ON)
|
||||
option(ENABLE_ALIAS "Enable Alias plugin" ON)
|
||||
option(ENABLE_ASPELL "Enable Aspell plugin" ON)
|
||||
option(ENABLE_ENCHANT "Enable Enchant lib for Aspell plugin" OFF)
|
||||
option(ENABLE_CHARSET "Enable Charset plugin" ON)
|
||||
option(ENABLE_EXEC "Enable Exec plugin" ON)
|
||||
option(ENABLE_FIFO "Enable FIFO plugin" ON)
|
||||
option(ENABLE_IRC "Enable IRC plugin" ON)
|
||||
option(ENABLE_LOGGER "Enable Logger plugin" ON)
|
||||
option(ENABLE_RELAY "Enable Relay plugin" ON)
|
||||
option(ENABLE_SCRIPT "Enable Script plugin (scripts manager)" ON)
|
||||
option(ENABLE_SCRIPTS "Enable script plugins (perl, python, ...)" ON)
|
||||
option(ENABLE_PERL "Enable Perl scripting language" ON)
|
||||
option(ENABLE_PYTHON "Enable Python scripting language" ON)
|
||||
option(ENABLE_PYTHON3 "Use Python 3.x if found (NOT recommended)" OFF)
|
||||
option(ENABLE_RUBY "Enable Ruby scripting language" ON)
|
||||
option(ENABLE_LUA "Enable Lua scripting language" ON)
|
||||
option(ENABLE_TCL "Enable Tcl scripting language" ON)
|
||||
option(ENABLE_GUILE "Enable Scheme (guile) scripting language" ON)
|
||||
option(ENABLE_TRIGGER "Enable Trigger plugin" ON)
|
||||
option(ENABLE_XFER "Enable Xfer plugin" ON)
|
||||
option(ENABLE_MAN "Enable build of man page" OFF)
|
||||
option(ENABLE_DOC "Enable build of documentation" OFF)
|
||||
option(ENABLE_TESTS "Enable tests" OFF)
|
||||
option(ENABLE_NCURSES "Enable Ncurses interface" ON)
|
||||
option(ENABLE_NLS "Enable Native Language Support" ON)
|
||||
option(ENABLE_GNUTLS "Enable SSLv3/TLS support" ON)
|
||||
option(ENABLE_LARGEFILE "Enable Large File Support" ON)
|
||||
option(ENABLE_ALIAS "Enable Alias plugin" ON)
|
||||
option(ENABLE_ASPELL "Enable Aspell plugin" ON)
|
||||
option(ENABLE_ENCHANT "Enable Enchant lib for Aspell plugin" OFF)
|
||||
option(ENABLE_CHARSET "Enable Charset plugin" ON)
|
||||
option(ENABLE_EXEC "Enable Exec plugin" ON)
|
||||
option(ENABLE_FIFO "Enable FIFO plugin" ON)
|
||||
option(ENABLE_IRC "Enable IRC plugin" ON)
|
||||
option(ENABLE_LOGGER "Enable Logger plugin" ON)
|
||||
option(ENABLE_RELAY "Enable Relay plugin" ON)
|
||||
option(ENABLE_SCRIPT "Enable Script plugin (scripts manager)" ON)
|
||||
option(ENABLE_SCRIPTS "Enable script plugins (perl, python, ...)" ON)
|
||||
option(ENABLE_PERL "Enable Perl scripting language" ON)
|
||||
option(ENABLE_PYTHON "Enable Python scripting language" ON)
|
||||
option(ENABLE_PYTHON3 "Use Python 3.x if found (NOT recommended)" OFF)
|
||||
option(ENABLE_RUBY "Enable Ruby scripting language" ON)
|
||||
option(ENABLE_LUA "Enable Lua scripting language" ON)
|
||||
option(ENABLE_TCL "Enable Tcl scripting language" ON)
|
||||
option(ENABLE_GUILE "Enable Scheme (guile) scripting language" ON)
|
||||
option(ENABLE_JAVASCRIPT "Enable JavaScript scripting language" ON)
|
||||
option(ENABLE_TRIGGER "Enable Trigger plugin" ON)
|
||||
option(ENABLE_XFER "Enable Xfer plugin" ON)
|
||||
option(ENABLE_MAN "Enable build of man page" OFF)
|
||||
option(ENABLE_DOC "Enable build of documentation" OFF)
|
||||
option(ENABLE_TESTS "Enable tests" OFF)
|
||||
|
||||
# option WEECHAT_HOME
|
||||
if(NOT DEFINED WEECHAT_HOME OR "${WEECHAT_HOME}" STREQUAL "")
|
||||
|
||||
@@ -59,6 +59,7 @@ EXTRA_DIST = AUTHORS.asciidoc \
|
||||
cmake/FindRuby.cmake \
|
||||
cmake/FindSourcehighlight.cmake \
|
||||
cmake/FindTCL.cmake \
|
||||
cmake/FindV8.cmake \
|
||||
cmake/FindZLIB.cmake \
|
||||
cmake/cmake_uninstall.cmake.in \
|
||||
po/CMakeLists.txt \
|
||||
|
||||
+3
-2
@@ -19,7 +19,8 @@ image:https://travis-ci.org/weechat/weechat.svg?branch=master["Build Status", li
|
||||
* Multi-protocols architecture (mainly IRC).
|
||||
* Compliant with IRC RFCs 1459, 2810, 2811, 2812 and 2813.
|
||||
* Small, fast and very light.
|
||||
* Customizable and extensible with plugins (C, Perl, Python, Ruby, Lua, Tcl, Guile).
|
||||
* Customizable and extensible with plugins (C, Perl, Python, Ruby, Lua, Tcl,
|
||||
Guile, Javascript).
|
||||
* Fully documented and translated into several languages.
|
||||
* Developed from scratch.
|
||||
* Free software, released under GPLv3.
|
||||
@@ -43,7 +44,7 @@ Following packages are optional:
|
||||
* for i18n: gettext
|
||||
* for SSL: gnutls, ca-certificates
|
||||
* for spell checking: aspell
|
||||
* for scripting: python, perl, ruby, lua, tcl, guile
|
||||
* for scripting: python, perl, ruby, lua, tcl, guile, libv8 (javascript)
|
||||
* for building doc: asciidoc, source-highlight
|
||||
(for man page: xsltproc, docbook-xml, docbook-xsl)
|
||||
* for building tests: C++ compiler, CppUTest
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#
|
||||
# Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
|
||||
#
|
||||
# This file is part of WeeChat, the extensible chat client.
|
||||
#
|
||||
# WeeChat 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# - Find Aspell
|
||||
# This module finds if libaspell is installed and determines where
|
||||
# the include files and libraries are.
|
||||
#
|
||||
# This code sets the following variables:
|
||||
#
|
||||
# V8_INCLUDE_DIR = path to where v8.h can be found
|
||||
# V8_LIBRARY = path to where libv8.so* can be found
|
||||
|
||||
if(V8_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(V8_FIND_QUIETLY TRUE)
|
||||
endif()
|
||||
|
||||
set(V8_INC_PATHS
|
||||
/usr/include
|
||||
${CMAKE_INCLUDE_PATH}
|
||||
)
|
||||
find_path(V8_INCLUDE_DIR v8.h PATHS ${V8_INC_PATHS})
|
||||
find_library(V8_LIBRARY
|
||||
NAMES v8
|
||||
PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(V8 DEFAULT_MSG V8_LIBRARY V8_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(
|
||||
V8_INCLUDE_DIR
|
||||
V8_LIBRARY
|
||||
)
|
||||
@@ -119,6 +119,7 @@ AH_VERBATIM([PLUGIN_RUBY], [#undef PLUGIN_RUBY])
|
||||
AH_VERBATIM([PLUGIN_LUA], [#undef PLUGIN_LUA])
|
||||
AH_VERBATIM([PLUGIN_TCL], [#undef PLUGIN_TCL])
|
||||
AH_VERBATIM([PLUGIN_GUILE], [#undef PLUGIN_GUILE])
|
||||
AH_VERBATIM([PLUGIN_JAVASCRIPT], [#undef PLUGIN_JAVASCRIPT])
|
||||
AH_VERBATIM([PLUGIN_TRIGGER], [#undef PLUGIN_TRIGGER])
|
||||
AH_VERBATIM([PLUGIN_XFER], [#undef PLUGIN_XFER])
|
||||
AH_VERBATIM([TESTS], [#undef TESTS])
|
||||
@@ -150,6 +151,7 @@ AC_ARG_ENABLE(ruby, [ --disable-ruby turn off Ruby script plug
|
||||
AC_ARG_ENABLE(lua, [ --disable-lua turn off Lua script plugin (default=compiled if found)],enable_lua=$enableval,enable_lua=yes)
|
||||
AC_ARG_ENABLE(tcl, [ --disable-tcl turn off Tcl script plugin (default=compiled if found)],enable_tcl=$enableval,enable_tcl=yes)
|
||||
AC_ARG_ENABLE(guile, [ --disable-guile turn off Guile (scheme) script plugin (default=compiled if found)],enable_guile=$enableval,enable_guile=yes)
|
||||
AC_ARG_ENABLE(javascript, [ --disable-javascript turn off Javascript script plugin (default=compiled if found)],enable_javascript=$enableval,enable_javascript=yes)
|
||||
AC_ARG_ENABLE(trigger, [ --disable-trigger turn off Trigger plugin (default=compiled)],enable_trigger=$enableval,enable_trigger=yes)
|
||||
AC_ARG_ENABLE(xfer, [ --disable-xfer turn off Xfer (file transfer) plugin (default=compiled if found)],enable_xfer=$enableval,enable_xfer=yes)
|
||||
AC_ARG_WITH(tclconfig, [ --with-tclconfig=DIR directory containing tcl configuration (tclConfig.sh)],tclconfig=$withval,tclconfig='')
|
||||
@@ -282,6 +284,7 @@ if test "x$enable_scripts" = "xno" ; then
|
||||
enable_lua="no"
|
||||
enable_tcl="no"
|
||||
enable_guile="no"
|
||||
enable_javascript="no"
|
||||
fi
|
||||
|
||||
# ---------------------------------- alias -------------------------------------
|
||||
@@ -783,6 +786,8 @@ if test "x$enable_tcl" = "xyes" ; then
|
||||
enable_tcl="no"
|
||||
not_found="$not_found tcl"
|
||||
fi
|
||||
else
|
||||
not_asked="$not_asked tcl"
|
||||
fi
|
||||
|
||||
if test "x$enable_tcl" = "xyes" ; then
|
||||
@@ -836,6 +841,8 @@ if test "x$enable_guile" = "xyes" ; then
|
||||
enable_guile="no"
|
||||
not_found="$not_found guile"
|
||||
fi
|
||||
else
|
||||
not_asked="$not_asked guile"
|
||||
fi
|
||||
|
||||
if test "x$enable_guile" = "xyes" ; then
|
||||
@@ -844,6 +851,60 @@ if test "x$enable_guile" = "xyes" ; then
|
||||
AC_DEFINE(PLUGIN_GUILE)
|
||||
fi
|
||||
|
||||
# ------------------------------ javascript -----------------------------------
|
||||
|
||||
AC_LANG_PUSH([C++])
|
||||
|
||||
if test "x$enable_javascript" = "xyes" ; then
|
||||
enable_plugins="yes"
|
||||
|
||||
v8_found="no"
|
||||
AC_CHECK_HEADER(v8.h,ac_found_v8_header="yes",ac_found_v8_header="no")
|
||||
if test "x$ac_found_v8_header" = "xyes" ; then
|
||||
#AC_CHECK_LIB(v8,v8,ac_found_v8_lib="yes",ac_found_v8_lib="no")
|
||||
ac_save_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS -lv8"
|
||||
AC_MSG_CHECKING(for v8 usability in programs)
|
||||
AC_TRY_RUN([
|
||||
#include <v8.h>
|
||||
using namespace v8;
|
||||
int main(int argc, char **argv) {
|
||||
const char *version = V8::GetVersion();
|
||||
return 0;
|
||||
}],ac_found_v8_lib="yes", ac_found_v8_lib="no", ac_found_v8_lib="assume-yes")
|
||||
LDFLAGS="$ac_save_LDFLAGS"
|
||||
if test "x$ac_found_v8_lib" = "xyes" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
v8_found="yes"
|
||||
V8_CFLAGS=""
|
||||
V8_LFLAGS="-lv8"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_WARN([
|
||||
*** V8 library couldn't be found on your system.
|
||||
*** WeeChat will be built without Javascript support.])
|
||||
enable_javascript="no"
|
||||
not_found="$not_found javascript/v8"
|
||||
fi
|
||||
else
|
||||
AC_MSG_WARN([
|
||||
*** V8 header files couldn't be found on your system.
|
||||
*** WeeChat will be built without Javascript support.])
|
||||
enable_javascript="no"
|
||||
not_found="$not_found javascript/v8"
|
||||
fi
|
||||
else
|
||||
not_asked="$not_asked javascript"
|
||||
fi
|
||||
|
||||
if test "x$enable_javascript" = "xyes" ; then
|
||||
AC_SUBST(V8_CFLAGS)
|
||||
AC_SUBST(V8_LFLAGS)
|
||||
AC_DEFINE(PLUGIN_JAVASCRIPT)
|
||||
fi
|
||||
|
||||
AC_LANG_POP
|
||||
|
||||
# --------------------------------- trigger ------------------------------------
|
||||
|
||||
if test "x$enable_trigger" = "xyes" ; then
|
||||
@@ -1188,6 +1249,7 @@ gnu*)
|
||||
esac
|
||||
|
||||
CFLAGS="$CFLAGS -DWEECHAT_VERSION=\\\"$VERSION\\\" -DWEECHAT_LICENSE=\\\"$LICENSE\\\""
|
||||
CPPFLAGS="$CPPFLAGS -DWEECHAT_VERSION=\\\"$VERSION\\\" -DWEECHAT_LICENSE=\\\"$LICENSE\\\""
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# output Makefiles
|
||||
@@ -1212,6 +1274,7 @@ AM_CONDITIONAL(PLUGIN_RUBY, test "$enable_ruby" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_LUA, test "$enable_lua" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_TCL, test "$enable_tcl" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_GUILE, test "$enable_guile" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_JAVASCRIPT, test "$enable_javascript" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_TRIGGER, test "$enable_trigger" = "yes")
|
||||
AM_CONDITIONAL(PLUGIN_XFER, test "$enable_xfer" = "yes")
|
||||
AM_CONDITIONAL(TESTS, test "$enable_tests" = "yes")
|
||||
@@ -1246,6 +1309,7 @@ AC_OUTPUT([Makefile
|
||||
src/plugins/lua/Makefile
|
||||
src/plugins/tcl/Makefile
|
||||
src/plugins/guile/Makefile
|
||||
src/plugins/javascript/Makefile
|
||||
src/plugins/trigger/Makefile
|
||||
src/plugins/xfer/Makefile
|
||||
src/gui/Makefile
|
||||
@@ -1315,6 +1379,9 @@ fi
|
||||
if test "x$enable_guile" = "xyes"; then
|
||||
listplugins="$listplugins guile($GUILE_VERSION)"
|
||||
fi
|
||||
if test "x$enable_javascript" = "xyes"; then
|
||||
listplugins="$listplugins javascript/v8"
|
||||
fi
|
||||
if test "x$enable_trigger" = "xyes"; then
|
||||
listplugins="$listplugins trigger"
|
||||
fi
|
||||
|
||||
Vendored
+1
@@ -18,6 +18,7 @@ Build-Depends:
|
||||
liblua5.1-0-dev,
|
||||
tcl8.5-dev,
|
||||
guile-2.0-dev,
|
||||
libv8-dev,
|
||||
libcurl4-gnutls-dev,
|
||||
libgcrypt20-dev,
|
||||
libgnutls28-dev,
|
||||
|
||||
Vendored
+5
-4
@@ -2,11 +2,12 @@ usr/lib/weechat/plugins/aspell.so
|
||||
usr/lib/weechat/plugins/exec.so
|
||||
usr/lib/weechat/plugins/fifo.so
|
||||
usr/lib/weechat/plugins/guile.so
|
||||
usr/lib/weechat/plugins/javascript.so
|
||||
usr/lib/weechat/plugins/lua.so
|
||||
usr/lib/weechat/plugins/perl.so
|
||||
usr/lib/weechat/plugins/python.so
|
||||
usr/lib/weechat/plugins/ruby.so
|
||||
usr/lib/weechat/plugins/lua.so
|
||||
usr/lib/weechat/plugins/tcl.so
|
||||
usr/lib/weechat/plugins/script.so
|
||||
usr/lib/weechat/plugins/relay.so
|
||||
usr/lib/weechat/plugins/ruby.so
|
||||
usr/lib/weechat/plugins/script.so
|
||||
usr/lib/weechat/plugins/tcl.so
|
||||
usr/lib/weechat/plugins/trigger.so
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
|
||||
| irc | nick | Liste der Nicks im aktuellen Channel
|
||||
|
||||
| javascript | javascript_script | Liste der Skripten
|
||||
|
||||
| lua | lua_script | Liste der Skripten
|
||||
|
||||
| perl | perl_script | Liste der Skripten
|
||||
|
||||
@@ -222,6 +222,40 @@
|
||||
** Listen:
|
||||
*** 'irc_servers'
|
||||
*** 'last_irc_server'
|
||||
* 'javascript_callback': Callback eines Skripts
|
||||
** Erweiterung: javascript
|
||||
** Variablen:
|
||||
*** 'script' (pointer, hdata: "javascript_script")
|
||||
*** 'function' (string)
|
||||
*** 'data' (string)
|
||||
*** 'config_file' (pointer, hdata: "config_file")
|
||||
*** 'config_section' (pointer, hdata: "config_section")
|
||||
*** 'config_option' (pointer, hdata: "config_option")
|
||||
*** 'hook' (pointer)
|
||||
*** 'buffer' (pointer, hdata: "buffer")
|
||||
*** 'bar_item' (pointer, hdata: "bar_item")
|
||||
*** 'upgrade_file' (pointer)
|
||||
*** 'prev_callback' (pointer, hdata: "javascript_callback")
|
||||
*** 'next_callback' (pointer, hdata: "javascript_callback")
|
||||
* 'javascript_script': Liste der Skripten
|
||||
** Erweiterung: javascript
|
||||
** Variablen:
|
||||
*** 'filename' (string)
|
||||
*** 'interpreter' (pointer)
|
||||
*** 'name' (string)
|
||||
*** 'author' (string)
|
||||
*** 'version' (string)
|
||||
*** 'license' (string)
|
||||
*** 'description' (string)
|
||||
*** 'shutdown_func' (string)
|
||||
*** 'charset' (string)
|
||||
*** 'callbacks' (pointer, hdata: "javascript_callback")
|
||||
*** 'unloading' (integer)
|
||||
*** 'prev_script' (pointer, hdata: "javascript_script")
|
||||
*** 'next_script' (pointer, hdata: "javascript_script")
|
||||
** Listen:
|
||||
*** 'last_script'
|
||||
*** 'scripts'
|
||||
* 'lua_callback': Callback eines Skripts
|
||||
** Erweiterung: lua
|
||||
** Variablen:
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
| irc | irc_server | Liste der IRC-Server | Server Pointer (optional) | Servername (Platzhalter "*" kann verwendet werden) (optional)
|
||||
|
||||
| javascript | javascript_script | Liste der Skripten | Skript Pointer (optional) | Name des Skriptes (Platzhalter "*" kann verwendet werden) (optional)
|
||||
|
||||
| logger | logger_buffer | Auflistung der protokollierten Buffer | Logger-Pointer (optional) | -
|
||||
|
||||
| lua | lua_script | Liste der Skripten | Skript Pointer (optional) | Name des Skriptes (Platzhalter "*" kann verwendet werden) (optional)
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
. xfer (6000)
|
||||
. irc (5000)
|
||||
. relay (4000)
|
||||
. guile, lua, perl, python, ruby, tcl (3000)
|
||||
. guile, javascript, lua, perl, python, ruby, tcl (3000)
|
||||
. script (2000)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
[[command_javascript_javascript]]
|
||||
[command]*`javascript`* auflisten/installieren/beenden von Skripten::
|
||||
|
||||
----
|
||||
/javascript list|listfull [<name>]
|
||||
load [-q] <filename>
|
||||
autoload
|
||||
reload|unload [-q] [<name>]
|
||||
|
||||
list: installierte Skripten werden aufgelistet
|
||||
listfull: detaillierte Auflistung aller installierten Skripten
|
||||
load: installiert ein Skript
|
||||
autoload: startet automatisch alle Skripten aus dem "autoload" Verzeichnis
|
||||
reload: ein Skript wird erneut gestartet (wird kein Name angegeben, dann werden alle Skripten beendet und erneut gestartet)
|
||||
unload: beendet ein Skript (wird kein Name angegeben, dann werden alle Skripten beendet)
|
||||
filename: Skript (Datei) welches geladen werden soll
|
||||
name: Name eines Skriptes (der Name der in der "register" Funktion der Skript-API genutzt wird)
|
||||
-q: unterdrückter Modus: Es werden keine Nachrichten ausgegeben
|
||||
|
||||
Ohne Angabe eines Argumentes listet dieser Befehl alle geladenen Skripten auf.
|
||||
----
|
||||
|
||||
@@ -772,7 +772,8 @@ Damit WeeChat weniger Speicher benötigt, solltest Du folgende Tipps umsetzen:
|
||||
* nutze die aktuelle Version (man kann davon ausgehen das eine aktuelle Version
|
||||
weniger Speicherlecks besitzt, als eine vorherige Version)
|
||||
* lade keine Erweiterungen die Du nicht benötigst. Zum Beispiel: ASpell, Fifo,
|
||||
Logger, Perl, Python, Ruby, Lua, Tcl, Guile, Xfer (wird für DCC benötigst)
|
||||
Logger, Perl, Python, Ruby, Lua, Tcl, Guile, Javascript, Xfer (wird für DCC
|
||||
benötigst)
|
||||
* installiere ausschließlich Skripten die Du auch nutzt
|
||||
* falls man SSL *NICHT* nutzt, sollte kein Zertifikat geladen werden. In diesem
|
||||
Fall, einfach den Eintrag in folgender Option leer lassen:
|
||||
|
||||
@@ -33,6 +33,7 @@ werden folgende Programmiersprachen unterstützt:
|
||||
* lua
|
||||
* tcl
|
||||
* guile (scheme)
|
||||
* javascript
|
||||
|
||||
[NOTE]
|
||||
Beinahe alle Beispiele in dieser Dokumentation beziehen sich auf Python.
|
||||
@@ -87,6 +88,10 @@ Weechat.config_new_option(config, section, "name", "string", "description of opt
|
||||
** config_new_option
|
||||
** bar_new
|
||||
|
||||
==== Javascript
|
||||
|
||||
* Funktionen werden im Format `weechat.xxx(arg1, arg2, ...);` ausgeführt
|
||||
|
||||
[[register_function]]
|
||||
=== Die "Register" Funktion
|
||||
|
||||
@@ -164,7 +169,15 @@ weechat::print "" "Hallo, von einem tcl Skript!"
|
||||
[source,lisp]
|
||||
----
|
||||
(weechat:register "test_scheme" "FlashCode" "1.0" "GPL3" "Test script" "" "")
|
||||
(weechat:print "" "Hello, from scheme script!")
|
||||
(weechat:print "" "Hallo, von einem scheme Skript!")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test Skript", "", "");
|
||||
weechat.print("", "Hallo, von einem javascript Skript!");
|
||||
----
|
||||
|
||||
[[load_script]]
|
||||
@@ -180,18 +193,20 @@ nutzen, zum Beispiel:
|
||||
/script load script.lua
|
||||
/script load script.tcl
|
||||
/script load script.scm
|
||||
/script load script.js
|
||||
----
|
||||
|
||||
Es besteht natürlich weiterhin die Möglichkeit, individuell für jede
|
||||
Skriptsprache, den entsprechenden Befehl zu nutzen:
|
||||
|
||||
----
|
||||
/python load python/skript.py
|
||||
/perl load perl/skript.pl
|
||||
/ruby load ruby/skript.rb
|
||||
/lua load lua/skript.lua
|
||||
/tcl load tcl/skript.tcl
|
||||
/guile load guile/skript.scm
|
||||
/python load script.py
|
||||
/perl load script.pl
|
||||
/ruby load script.rb
|
||||
/lua load script.lua
|
||||
/tcl load script.tcl
|
||||
/guile load script.scm
|
||||
/javascript load script.js
|
||||
----
|
||||
|
||||
Um Skripten automatisch beim Start von WeeChat zu laden sollte man einen Link
|
||||
@@ -355,6 +370,18 @@ weechat::hook_timer 1000 0 1 timer_cb test
|
||||
(weechat:hook_timer 1000 0 1 "timer_cb" "test")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
function timer_cb(data, remaining_calls) {
|
||||
weechat.print("", "timer! data=" + data);
|
||||
return weechat.WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
weechat.hook_timer(1000, 0, 1, "timer_cb", "test");
|
||||
----
|
||||
|
||||
[[script_api]]
|
||||
== Skript API
|
||||
|
||||
@@ -533,7 +560,8 @@ weechat.prnt(buffer, "Nachricht im #weechat Channel")
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
Die print Funktion heißt in Perl/Ruby/Lua/Tcl `print`. In Python lautet die Funktion `prnt`.
|
||||
Die print Funktion heißt in Perl/Ruby/Lua/Tcl/Guile/Javascript `print`.
|
||||
In Python lautet die Funktion `prnt`.
|
||||
|
||||
[[buffers_send_text]]
|
||||
==== Text in einen Buffer senden
|
||||
@@ -804,7 +832,7 @@ def config_cb(data, option, value):
|
||||
# ...
|
||||
|
||||
weechat.hook_config("plugins.var.python." + SKRIPT_NAME + ".*", "config_cb", "")
|
||||
# für die jeweilige Programmiersprache muss "python" durch "perl", "ruby", "lua" oder "tcl" ersetzt werden.
|
||||
# für die jeweilige Programmiersprache muss "python" durch perl/ruby/lua/tcl/guile/javascript ersetzt werden.
|
||||
----
|
||||
|
||||
[[config_options_weechat]]
|
||||
|
||||
@@ -147,6 +147,9 @@ zu kompilieren und welche Pakete optional genutzt werden können.
|
||||
| guile-2.0-dev | ≥ 2.0 | |
|
||||
Guile (scheme) Erweiterung
|
||||
|
||||
| libv8-dev | | |
|
||||
Javascript Erweiterung
|
||||
|
||||
| asciidoc | ≥ 8.5.0 | |
|
||||
Zum Erstellen der man page und der Dokumentation
|
||||
|
||||
@@ -254,6 +257,9 @@ Liste von häufig verwendeten Optionen:
|
||||
| ENABLE_IRC | `ON`, `OFF` | ON |
|
||||
kompiliert <<irc_plugin,IRC Erweiterung>>.
|
||||
|
||||
| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON |
|
||||
kompiliert <<scripts_plugins,Javascript Erweiterung>>.
|
||||
|
||||
| ENABLE_LARGEFILE | `ON`, `OFF` | ON |
|
||||
Unterstützung großer Dateien.
|
||||
|
||||
@@ -289,8 +295,8 @@ Liste von häufig verwendeten Optionen:
|
||||
kompiliert <<scripts_plugins,Script Erweiterung>>.
|
||||
|
||||
| ENABLE_SCRIPTS | `ON`, `OFF` | ON |
|
||||
kompiliert <<scripts_plugins,Skripten-Erweiterungen>> (Python, Perl, Ruby, Lua, Tcl,
|
||||
Guile).
|
||||
kompiliert <<scripts_plugins,Skripten-Erweiterungen>> (Python, Perl, Ruby,
|
||||
Lua, Tcl, Guile, Javascript).
|
||||
|
||||
| ENABLE_TCL | `ON`, `OFF` | ON |
|
||||
kompiliert <<scripts_plugins,Tcl Erweiterung>>.
|
||||
@@ -1816,7 +1822,7 @@ Beispiele wie man Erweiterungen lädt, entfernt und auflistet:
|
||||
|
||||
Standarderweiterungen:
|
||||
|
||||
[width="50%",cols="^1,5",options="header"]
|
||||
[width="100%",cols="^1,5",options="header"]
|
||||
|===
|
||||
| Erweiterung | Beschreibung
|
||||
| alias | definiert Alias für Befehle
|
||||
@@ -1834,6 +1840,7 @@ Standarderweiterungen:
|
||||
| lua | Lua-Skript API
|
||||
| tcl | Tcl-Skript API
|
||||
| guile | Guile(scheme)-Skript API
|
||||
| javascript | Javascript-Skript API
|
||||
| trigger | Veränderung von Text und Ausführen von Befehlen bei einem Ereignis, welche durch WeeChat oder eine Erweiterung ausgelöst werden
|
||||
| xfer | Datentransfer und Direktchat
|
||||
|===
|
||||
@@ -2931,8 +2938,8 @@ Die URI muss immer auf "/weechat" enden ('irc' und 'weechat' Protokoll).
|
||||
[[scripts_plugins]]
|
||||
=== Erweiterungen für Skripten
|
||||
|
||||
WeeChat unterstützt sechs Skript-Erweiterungen: Python, Perl, Ruby, Lua, Tcl und Guile
|
||||
(scheme).
|
||||
WeeChat unterstützt sechs Skript-Erweiterungen: Python, Perl, Ruby, Lua, Tcl,
|
||||
Guile (scheme) und Javascript.
|
||||
Mit diesen Erweiterungen kann für die jeweilige Skript-Sprache, Skripten geladen, ausgeführt
|
||||
und entfernt werden.
|
||||
|
||||
@@ -2996,6 +3003,11 @@ include::autogen/user/tcl_commands.asciidoc[]
|
||||
|
||||
include::autogen/user/guile_commands.asciidoc[]
|
||||
|
||||
[[javascript_commands]]
|
||||
==== Javascript Befehle
|
||||
|
||||
include::autogen/user/javascript_commands.asciidoc[]
|
||||
|
||||
[[trigger_plugin]]
|
||||
=== Trigger Erweiterung
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ PLUGIN_LIST = {
|
||||
'script': 'o',
|
||||
'perl': '',
|
||||
'python': '',
|
||||
'javascript': '',
|
||||
'ruby': '',
|
||||
'lua': '',
|
||||
'tcl': '',
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
|
||||
| irc | nick | nicks of current IRC channel
|
||||
|
||||
| javascript | javascript_script | list of scripts
|
||||
|
||||
| lua | lua_script | list of scripts
|
||||
|
||||
| perl | perl_script | list of scripts
|
||||
|
||||
@@ -222,6 +222,40 @@
|
||||
** lists:
|
||||
*** 'irc_servers'
|
||||
*** 'last_irc_server'
|
||||
* 'javascript_callback': callback of a script
|
||||
** plugin: javascript
|
||||
** variables:
|
||||
*** 'script' (pointer, hdata: "javascript_script")
|
||||
*** 'function' (string)
|
||||
*** 'data' (string)
|
||||
*** 'config_file' (pointer, hdata: "config_file")
|
||||
*** 'config_section' (pointer, hdata: "config_section")
|
||||
*** 'config_option' (pointer, hdata: "config_option")
|
||||
*** 'hook' (pointer)
|
||||
*** 'buffer' (pointer, hdata: "buffer")
|
||||
*** 'bar_item' (pointer, hdata: "bar_item")
|
||||
*** 'upgrade_file' (pointer)
|
||||
*** 'prev_callback' (pointer, hdata: "javascript_callback")
|
||||
*** 'next_callback' (pointer, hdata: "javascript_callback")
|
||||
* 'javascript_script': list of scripts
|
||||
** plugin: javascript
|
||||
** variables:
|
||||
*** 'filename' (string)
|
||||
*** 'interpreter' (pointer)
|
||||
*** 'name' (string)
|
||||
*** 'author' (string)
|
||||
*** 'version' (string)
|
||||
*** 'license' (string)
|
||||
*** 'description' (string)
|
||||
*** 'shutdown_func' (string)
|
||||
*** 'charset' (string)
|
||||
*** 'callbacks' (pointer, hdata: "javascript_callback")
|
||||
*** 'unloading' (integer)
|
||||
*** 'prev_script' (pointer, hdata: "javascript_script")
|
||||
*** 'next_script' (pointer, hdata: "javascript_script")
|
||||
** lists:
|
||||
*** 'last_script'
|
||||
*** 'scripts'
|
||||
* 'lua_callback': callback of a script
|
||||
** plugin: lua
|
||||
** variables:
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
| irc | irc_server | list of IRC servers | server pointer (optional) | server name (wildcard "*" is allowed) (optional)
|
||||
|
||||
| javascript | javascript_script | list of scripts | script pointer (optional) | script name (wildcard "*" is allowed) (optional)
|
||||
|
||||
| logger | logger_buffer | list of logger buffers | logger pointer (optional) | -
|
||||
|
||||
| lua | lua_script | list of scripts | script pointer (optional) | script name (wildcard "*" is allowed) (optional)
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
. xfer (6000)
|
||||
. irc (5000)
|
||||
. relay (4000)
|
||||
. guile, lua, perl, python, ruby, tcl (3000)
|
||||
. guile, javascript, lua, perl, python, ruby, tcl (3000)
|
||||
. script (2000)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
[[command_javascript_javascript]]
|
||||
[command]*`javascript`* list/load/unload scripts::
|
||||
|
||||
----
|
||||
/javascript list|listfull [<name>]
|
||||
load [-q] <filename>
|
||||
autoload
|
||||
reload|unload [-q] [<name>]
|
||||
|
||||
list: list loaded scripts
|
||||
listfull: list loaded scripts (verbose)
|
||||
load: load a script
|
||||
autoload: load all scripts in "autoload" directory
|
||||
reload: reload a script (if no name given, unload all scripts, then load all scripts in "autoload" directory)
|
||||
unload: unload a script (if no name given, unload all scripts)
|
||||
filename: script (file) to load
|
||||
name: a script name (name used in call to "register" function)
|
||||
-q: quiet mode: do not display messages
|
||||
|
||||
Without argument, this command lists all loaded scripts.
|
||||
----
|
||||
|
||||
@@ -46,35 +46,36 @@ The main WeeChat directories are:
|
||||
|
||||
[width="100%",cols="1v,5",options="header"]
|
||||
|===
|
||||
| Directory | Description
|
||||
| src/ | Root of sources
|
||||
| core/ | Core functions: entry point, internal structures
|
||||
| gui/ | Functions for buffers, windows, ... (used by all interfaces)
|
||||
| curses/ | Curses interface
|
||||
| plugins/ | Plugin and scripting API
|
||||
| alias/ | Alias plugin
|
||||
| aspell/ | Aspell plugin
|
||||
| charset/ | Charset plugin
|
||||
| exec/ | Exec plugin
|
||||
| fifo/ | Fifo plugin (FIFO pipe used to remotely send commands to WeeChat)
|
||||
| irc/ | IRC (Internet Relay Chat) plugin
|
||||
| logger/ | Logger plugin (write messages displayed to files)
|
||||
| relay/ | Relay plugin (irc proxy + relay for remote interfaces)
|
||||
| script/ | Scripts manager
|
||||
| python/ | Python scripting API
|
||||
| perl/ | Perl scripting API
|
||||
| ruby/ | Ruby scripting API
|
||||
| lua/ | Lua scripting API
|
||||
| tcl/ | Tcl scripting API
|
||||
| guile/ | Guile (scheme) scripting API
|
||||
| trigger/ | Trigger plugin
|
||||
| xfer/ | Xfer plugin (IRC DCC file/chat)
|
||||
| tests/ | Tests
|
||||
| unit/ | Unit tests
|
||||
| core/ | Unit tests for core functions
|
||||
| doc/ | Documentation
|
||||
| po/ | Translations files (gettext)
|
||||
| debian/ | Debian packaging
|
||||
| Directory | Description
|
||||
| src/ | Root of sources
|
||||
| core/ | Core functions: entry point, internal structures
|
||||
| gui/ | Functions for buffers, windows, ... (used by all interfaces)
|
||||
| curses/ | Curses interface
|
||||
| plugins/ | Plugin and scripting API
|
||||
| alias/ | Alias plugin
|
||||
| aspell/ | Aspell plugin
|
||||
| charset/ | Charset plugin
|
||||
| exec/ | Exec plugin
|
||||
| fifo/ | Fifo plugin (FIFO pipe used to remotely send commands to WeeChat)
|
||||
| irc/ | IRC (Internet Relay Chat) plugin
|
||||
| logger/ | Logger plugin (write messages displayed to files)
|
||||
| relay/ | Relay plugin (irc proxy + relay for remote interfaces)
|
||||
| script/ | Scripts manager
|
||||
| python/ | Python scripting API
|
||||
| perl/ | Perl scripting API
|
||||
| ruby/ | Ruby scripting API
|
||||
| lua/ | Lua scripting API
|
||||
| tcl/ | Tcl scripting API
|
||||
| guile/ | Guile (scheme) scripting API
|
||||
| javascript/ | Javascript scripting API
|
||||
| trigger/ | Trigger plugin
|
||||
| xfer/ | Xfer plugin (IRC DCC file/chat)
|
||||
| tests/ | Tests
|
||||
| unit/ | Unit tests
|
||||
| core/ | Unit tests for core functions
|
||||
| doc/ | Documentation
|
||||
| po/ | Translations files (gettext)
|
||||
| debian/ | Debian packaging
|
||||
|===
|
||||
|
||||
[[sources]]
|
||||
@@ -215,6 +216,10 @@ WeeChat "core" is located in following directories:
|
||||
| irc-sasl.c | SASL authentication with IRC server
|
||||
| irc-server.c | I/O communication with IRC server
|
||||
| irc-upgrade.c | Save/restore of IRC data when upgrading WeeChat
|
||||
| javascript/ | Javascript plugin
|
||||
| weechat-js.cpp | Main javascript functions (load/unload scripts, execute javascript code)
|
||||
| weechat-js-api.cpp | Javascript scripting API functions
|
||||
| weechat-js-v8.cpp | Javascript v8 functions
|
||||
| logger/ | Logger plugin
|
||||
| logger.c | Main logger functions
|
||||
| logger-buffer.c | Logger buffer list management
|
||||
@@ -1031,7 +1036,7 @@ Then you can load this script in your WeeChat, and setup path to your '/doc' dir
|
||||
Then create this alias to build files:
|
||||
|
||||
----
|
||||
/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /python load docgen.py; /wait 1ms /docgen
|
||||
/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /javascript unload; /python load docgen.py; /wait 1ms /docgen
|
||||
----
|
||||
|
||||
And use command `/doc` to build all files, for all languages.
|
||||
|
||||
@@ -728,7 +728,7 @@ You can try following tips to consume less memory:
|
||||
* use the latest stable version (it is supposed to have less memory leaks than
|
||||
older versions)
|
||||
* do not load some plugins if you don't use them, for example: aspell, fifo,
|
||||
logger, perl, python, ruby, lua, tcl, guile, xfer (used for DCC)
|
||||
logger, perl, python, ruby, lua, tcl, guile, javascript, xfer (used for DCC)
|
||||
* load only scripts that you really need
|
||||
* do not load certificates if SSL is *NOT* used: set empty string in option
|
||||
'weechat.network.gnutls_ca_file'
|
||||
|
||||
@@ -7985,6 +7985,26 @@ List of signals sent by WeeChat and plugins:
|
||||
String: server name + "," + nick |
|
||||
A nick in notify list is back (away status removed)
|
||||
|
||||
| javascript | javascript_script_loaded +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
String: path to script |
|
||||
Javascript script loaded
|
||||
|
||||
| javascript | javascript_script_unloaded +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
String: path to script |
|
||||
Javascript script unloaded
|
||||
|
||||
| javascript | javascript_script_installed +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
String: comma-separated list of paths to scripts installed |
|
||||
Javascript script(s) installed
|
||||
|
||||
| javascript | javascript_script_removed +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
String: comma-separated list of scripts removed |
|
||||
Javascript script(s) removed
|
||||
|
||||
| logger | logger_start |
|
||||
Pointer: buffer |
|
||||
Start logging for buffer
|
||||
@@ -8565,6 +8585,8 @@ Five signals can be sent to install a script, according to language:
|
||||
* 'ruby_script_install'
|
||||
* 'lua_script_install'
|
||||
* 'tcl_script_install'
|
||||
* 'guile_script_install'
|
||||
* 'javascript_script_install'
|
||||
|
||||
The callback will do following actions when receiving signal:
|
||||
|
||||
@@ -8603,6 +8625,8 @@ Five signals can be sent to remove list of scripts, according to language:
|
||||
* 'ruby_script_remove'
|
||||
* 'lua_script_remove'
|
||||
* 'tcl_script_remove'
|
||||
* 'guile_script_remove'
|
||||
* 'javascript_script_remove'
|
||||
|
||||
For each script in list, the callback will unload then remove script.
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ script languages:
|
||||
* lua
|
||||
* tcl
|
||||
* guile (scheme)
|
||||
* javascript
|
||||
|
||||
[NOTE]
|
||||
Almost all examples in this doc are written in Python, but API is the same for
|
||||
@@ -82,6 +83,10 @@ Weechat.config_new_option(config, section, "name", "string", "description of opt
|
||||
** config_new_option
|
||||
** bar_new
|
||||
|
||||
==== Javascript
|
||||
|
||||
* Functions are called with `weechat.xxx(arg1, arg2, ...);`
|
||||
|
||||
[[register_function]]
|
||||
=== Register function
|
||||
|
||||
@@ -162,6 +167,14 @@ weechat::print "" "Hello, from tcl script!"
|
||||
(weechat:print "" "Hello, from scheme script!")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", "");
|
||||
weechat.print("", "Hello, from javascript script!");
|
||||
----
|
||||
|
||||
[[load_script]]
|
||||
=== Load script
|
||||
|
||||
@@ -174,17 +187,19 @@ It is recommended to use the "script" plugin to load scripts, for example:
|
||||
/script load script.lua
|
||||
/script load script.tcl
|
||||
/script load script.scm
|
||||
/script load script.js
|
||||
----
|
||||
|
||||
Each language has also its own command:
|
||||
|
||||
----
|
||||
/python load python/script.py
|
||||
/perl load perl/script.pl
|
||||
/ruby load ruby/script.rb
|
||||
/lua load lua/script.lua
|
||||
/tcl load tcl/script.tcl
|
||||
/guile load guile/script.scm
|
||||
/python load script.py
|
||||
/perl load script.pl
|
||||
/ruby load script.rb
|
||||
/lua load script.lua
|
||||
/tcl load script.tcl
|
||||
/guile load script.scm
|
||||
/javascript load script.js
|
||||
----
|
||||
|
||||
You can make link in directory 'language/autoload' to autoload script when
|
||||
@@ -343,6 +358,18 @@ weechat::hook_timer 1000 0 1 timer_cb test
|
||||
(weechat:hook_timer 1000 0 1 "timer_cb" "test")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
function timer_cb(data, remaining_calls) {
|
||||
weechat.print("", "timer! data=" + data);
|
||||
return weechat.WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
weechat.hook_timer(1000, 0, 1, "timer_cb", "test");
|
||||
----
|
||||
|
||||
[[script_api]]
|
||||
== Script API
|
||||
|
||||
@@ -520,7 +547,8 @@ weechat.prnt(buffer, "message on #weechat channel")
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
Print function is called `print` in Perl/Ruby/Lua/Tcl and `prnt` in Python.
|
||||
Print function is called `print` in Perl/Ruby/Lua/Tcl/Guile/Javascript and
|
||||
`prnt` in Python.
|
||||
|
||||
[[buffers_send_text]]
|
||||
==== Send text to buffer
|
||||
@@ -783,7 +811,7 @@ def config_cb(data, option, value):
|
||||
# ...
|
||||
|
||||
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "")
|
||||
# for other languages, change "python" with your language ("perl", "ruby", "lua" or "tcl")
|
||||
# for other languages, change "python" with your language (perl/ruby/lua/tcl/guile/javascript)
|
||||
----
|
||||
|
||||
[[config_options_weechat]]
|
||||
|
||||
@@ -139,6 +139,9 @@ compile WeeChat.
|
||||
| guile-2.0-dev | ≥ 2.0 | |
|
||||
Guile (scheme) plugin
|
||||
|
||||
| libv8-dev | | |
|
||||
Javascript plugin
|
||||
|
||||
| asciidoc | ≥ 8.5.0 | |
|
||||
Build man page and documentation
|
||||
|
||||
@@ -245,6 +248,9 @@ List of commonly used options:
|
||||
| ENABLE_IRC | `ON`, `OFF` | ON |
|
||||
Compile <<irc_plugin,IRC plugin>>.
|
||||
|
||||
| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON |
|
||||
Compile <<scripts_plugins,Javascript plugin>>.
|
||||
|
||||
| ENABLE_LARGEFILE | `ON`, `OFF` | ON |
|
||||
Support of large files.
|
||||
|
||||
@@ -281,7 +287,7 @@ List of commonly used options:
|
||||
|
||||
| ENABLE_SCRIPTS | `ON`, `OFF` | ON |
|
||||
Compile <<scripts_plugins,script plugins>> (Python, Perl, Ruby, Lua, Tcl,
|
||||
Guile).
|
||||
Guile, Javascript).
|
||||
|
||||
| ENABLE_TCL | `ON`, `OFF` | ON |
|
||||
Compile <<scripts_plugins,Tcl plugin>>.
|
||||
@@ -1773,26 +1779,27 @@ Examples to load, unload or list plugins:
|
||||
|
||||
Default plugins are:
|
||||
|
||||
[width="50%",cols="^1,5",options="header"]
|
||||
[width="100%",cols="^1,5",options="header"]
|
||||
|===
|
||||
| Plugin | Description
|
||||
| alias | Define alias for commands
|
||||
| aspell | Spell checking for command line
|
||||
| charset | Charset decoding/encoding for buffers
|
||||
| exec | Execution of external commands in WeeChat
|
||||
| fifo | FIFO pipe used to remotely send commands to WeeChat
|
||||
| irc | IRC chat protocol
|
||||
| logger | Log buffers to files
|
||||
| relay | Relay data via network
|
||||
| script | Scripts manager
|
||||
| python | Python scripting API
|
||||
| perl | Perl scripting API
|
||||
| ruby | Ruby scripting API
|
||||
| lua | Lua scripting API
|
||||
| tcl | Tcl scripting API
|
||||
| guile | Guile (scheme) scripting API
|
||||
| trigger | Text replacement and command execution on events triggered by WeeChat/plugins
|
||||
| xfer | File transfer and direct chat
|
||||
| Plugin | Description
|
||||
| alias | Define alias for commands
|
||||
| aspell | Spell checking for command line
|
||||
| charset | Charset decoding/encoding for buffers
|
||||
| exec | Execution of external commands in WeeChat
|
||||
| fifo | FIFO pipe used to remotely send commands to WeeChat
|
||||
| irc | IRC chat protocol
|
||||
| logger | Log buffers to files
|
||||
| relay | Relay data via network
|
||||
| script | Scripts manager
|
||||
| python | Python scripting API
|
||||
| perl | Perl scripting API
|
||||
| ruby | Ruby scripting API
|
||||
| lua | Lua scripting API
|
||||
| tcl | Tcl scripting API
|
||||
| guile | Guile (scheme) scripting API
|
||||
| javascript | Javascript scripting API
|
||||
| trigger | Text replacement and command execution on events triggered by WeeChat/plugins
|
||||
| xfer | File transfer and direct chat
|
||||
|===
|
||||
|
||||
To learn more about plugin or script development (through API), please read
|
||||
@@ -2857,8 +2864,8 @@ The URI must always end with "/weechat" (for 'irc' and 'weechat' protocols).
|
||||
[[scripts_plugins]]
|
||||
=== Scripts plugins
|
||||
|
||||
WeeChat provides 6 scripting plugins: Python, Perl, Ruby, Lua, Tcl and Guile
|
||||
(scheme).
|
||||
WeeChat provides 7 scripting plugins: Python, Perl, Ruby, Lua, Tcl, Guile
|
||||
(scheme) and Javascript.
|
||||
These plugins can load, execute and unload scripts for these languages.
|
||||
|
||||
Another plugin called "script" is a scripts manager and is used to load/unload
|
||||
@@ -2920,6 +2927,11 @@ include::autogen/user/tcl_commands.asciidoc[]
|
||||
|
||||
include::autogen/user/guile_commands.asciidoc[]
|
||||
|
||||
[[javascript_commands]]
|
||||
==== Javascript commands
|
||||
|
||||
include::autogen/user/javascript_commands.asciidoc[]
|
||||
|
||||
[[trigger_plugin]]
|
||||
=== Trigger plugin
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
|
||||
| irc | nick | pseudos du canal IRC courant
|
||||
|
||||
| javascript | javascript_script | liste des scripts
|
||||
|
||||
| lua | lua_script | liste des scripts
|
||||
|
||||
| perl | perl_script | liste des scripts
|
||||
|
||||
@@ -222,6 +222,40 @@
|
||||
** listes:
|
||||
*** 'irc_servers'
|
||||
*** 'last_irc_server'
|
||||
* 'javascript_callback': callback d'un script
|
||||
** extension: javascript
|
||||
** variables:
|
||||
*** 'script' (pointer, hdata: "javascript_script")
|
||||
*** 'function' (string)
|
||||
*** 'data' (string)
|
||||
*** 'config_file' (pointer, hdata: "config_file")
|
||||
*** 'config_section' (pointer, hdata: "config_section")
|
||||
*** 'config_option' (pointer, hdata: "config_option")
|
||||
*** 'hook' (pointer)
|
||||
*** 'buffer' (pointer, hdata: "buffer")
|
||||
*** 'bar_item' (pointer, hdata: "bar_item")
|
||||
*** 'upgrade_file' (pointer)
|
||||
*** 'prev_callback' (pointer, hdata: "javascript_callback")
|
||||
*** 'next_callback' (pointer, hdata: "javascript_callback")
|
||||
* 'javascript_script': liste des scripts
|
||||
** extension: javascript
|
||||
** variables:
|
||||
*** 'filename' (string)
|
||||
*** 'interpreter' (pointer)
|
||||
*** 'name' (string)
|
||||
*** 'author' (string)
|
||||
*** 'version' (string)
|
||||
*** 'license' (string)
|
||||
*** 'description' (string)
|
||||
*** 'shutdown_func' (string)
|
||||
*** 'charset' (string)
|
||||
*** 'callbacks' (pointer, hdata: "javascript_callback")
|
||||
*** 'unloading' (integer)
|
||||
*** 'prev_script' (pointer, hdata: "javascript_script")
|
||||
*** 'next_script' (pointer, hdata: "javascript_script")
|
||||
** listes:
|
||||
*** 'last_script'
|
||||
*** 'scripts'
|
||||
* 'lua_callback': callback d'un script
|
||||
** extension: lua
|
||||
** variables:
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
| irc | irc_server | liste des serveurs IRC | pointeur vers le serveur (optionnel) | nom de serveur (le caractère joker "*" est autorisé) (optionnel)
|
||||
|
||||
| javascript | javascript_script | liste des scripts | pointeur vers le script (optionnel) | nom de script (le caractère joker "*" est autorisé) (optionnel)
|
||||
|
||||
| logger | logger_buffer | liste des enregistreurs de tampons (loggers) | pointeur vers le logger (optionnel) | -
|
||||
|
||||
| lua | lua_script | liste des scripts | pointeur vers le script (optionnel) | nom de script (le caractère joker "*" est autorisé) (optionnel)
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
. xfer (6000)
|
||||
. irc (5000)
|
||||
. relay (4000)
|
||||
. guile, lua, perl, python, ruby, tcl (3000)
|
||||
. guile, javascript, lua, perl, python, ruby, tcl (3000)
|
||||
. script (2000)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
[[command_javascript_javascript]]
|
||||
[command]*`javascript`* lister/charger/décharger des scripts::
|
||||
|
||||
----
|
||||
/javascript list|listfull [<nom>]
|
||||
load [-q] <fichier>
|
||||
autoload
|
||||
reload|unload [-q] [<nom>]
|
||||
|
||||
list : lister les scripts chargés
|
||||
listfull : lister les scripts chargés (verbeux)
|
||||
load : charger un script
|
||||
autoload : charger tous les scripts dans le répertoire "autoload"
|
||||
reload : recharger un script (si pas de nom donné, décharger tous les scripts puis charger tous les scripts dans le répertoire "autoload")
|
||||
unload : décharger un script (si pas de nom donné, décharger tous les scripts)
|
||||
fichier : script (fichier) à charger
|
||||
nom : nom de script (nom utilisé dans l'appel à la fonction "register")
|
||||
-q : mode silencieux : ne pas afficher de messages
|
||||
|
||||
Sans paramètre, cette commande liste les scripts chargés.
|
||||
----
|
||||
|
||||
@@ -47,35 +47,36 @@ Les répertoires principaux de WeeChat sont :
|
||||
|
||||
[width="100%",cols="1v,5",options="header"]
|
||||
|===
|
||||
| Répertoire | Description
|
||||
| src/ | Racine des sources
|
||||
| core/ | Fonctions du cœur : point d'entrée, structures internes
|
||||
| gui/ | Fonctions pour les tampons, fenêtres, ... (utilisées par toutes les interfaces)
|
||||
| curses/ | Interface Curses
|
||||
| plugins/ | API extension/script
|
||||
| alias/ | Extension Alias
|
||||
| aspell/ | Extension Aspell
|
||||
| charset/ | Extension Charset
|
||||
| exec/ | Extension Exec
|
||||
| fifo/ | Extension Fifo (tube FIFO utilisé pour envoyer des commandes à WeeChat)
|
||||
| irc/ | Extension IRC (Internet Relay Chat)
|
||||
| logger/ | Extension Logger (enregistrer les messages affichés dans des fichiers)
|
||||
| relay/ | Extension Relay (proxy IRC + relai pour interfaces distantes)
|
||||
| script/ | Gestionnaire de scripts
|
||||
| python/ | API script Python
|
||||
| perl/ | API script Perl
|
||||
| ruby/ | API script Ruby
|
||||
| lua/ | API script Lua
|
||||
| tcl/ | API script Tcl
|
||||
| guile/ | API script Guile (scheme)
|
||||
| trigger/ | Extension Trigger
|
||||
| xfer/ | Extension Xfer (IRC DCC fichier/discussion)
|
||||
| tests/ | Tests
|
||||
| unit/ | Tests unitaires
|
||||
| core/ | Tests unitaires pour les fonctions du cœur
|
||||
| doc/ | Documentation
|
||||
| po/ | Fichiers de traductions (gettext)
|
||||
| debian/ | Empaquetage Debian
|
||||
| Répertoire | Description
|
||||
| src/ | Racine des sources
|
||||
| core/ | Fonctions du cœur : point d'entrée, structures internes
|
||||
| gui/ | Fonctions pour les tampons, fenêtres, ... (utilisées par toutes les interfaces)
|
||||
| curses/ | Interface Curses
|
||||
| plugins/ | API extension/script
|
||||
| alias/ | Extension Alias
|
||||
| aspell/ | Extension Aspell
|
||||
| charset/ | Extension Charset
|
||||
| exec/ | Extension Exec
|
||||
| fifo/ | Extension Fifo (tube FIFO utilisé pour envoyer des commandes à WeeChat)
|
||||
| irc/ | Extension IRC (Internet Relay Chat)
|
||||
| logger/ | Extension Logger (enregistrer les messages affichés dans des fichiers)
|
||||
| relay/ | Extension Relay (proxy IRC + relai pour interfaces distantes)
|
||||
| script/ | Gestionnaire de scripts
|
||||
| python/ | API script Python
|
||||
| perl/ | API script Perl
|
||||
| ruby/ | API script Ruby
|
||||
| lua/ | API script Lua
|
||||
| tcl/ | API script Tcl
|
||||
| guile/ | API script Guile (scheme)
|
||||
| javascript/ | API script Javascript
|
||||
| trigger/ | Extension Trigger
|
||||
| xfer/ | Extension Xfer (IRC DCC fichier/discussion)
|
||||
| tests/ | Tests
|
||||
| unit/ | Tests unitaires
|
||||
| core/ | Tests unitaires pour les fonctions du cœur
|
||||
| doc/ | Documentation
|
||||
| po/ | Fichiers de traductions (gettext)
|
||||
| debian/ | Empaquetage Debian
|
||||
|===
|
||||
|
||||
[[sources]]
|
||||
@@ -216,6 +217,10 @@ Le cœur de WeeChat est situé dans les répertoires suivants :
|
||||
| irc-sasl.c | Authentification SASL avec le serveur IRC
|
||||
| irc-server.c | Communication avec le serveur IRC
|
||||
| irc-upgrade.c | Sauvegarde/restauration des données IRC lors de la mise à jour de WeeChat
|
||||
| javascript/ | Extension Javascript
|
||||
| weechat-js.cpp | Fonctions principales pour Javascript (chargement/déchargement des scripts, exécution de code Javascript)
|
||||
| weechat-js-api.cpp | Fonctions de l'API script Javascript
|
||||
| weechat-js-v8.cpp | Fonctions Javascript v8
|
||||
| logger/ | Extension Logger
|
||||
| logger.c | Fonctions principales pour Logger
|
||||
| logger-buffer.c | Gestion des listes de tampons pour Logger
|
||||
@@ -1051,7 +1056,7 @@ vers votre répertoire '/doc' :
|
||||
Créez alors cet alias pour construire les fichiers :
|
||||
|
||||
----
|
||||
/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /python load docgen.py; /wait 1ms /docgen
|
||||
/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /javascript unload; /python load docgen.py; /wait 1ms /docgen
|
||||
----
|
||||
|
||||
Et utilisez la commande `/doc` pour construire tous les fichiers, pour toutes
|
||||
|
||||
@@ -759,8 +759,8 @@ Vous pouvez essayer les astuces suivantes pour consommer moins de mémoire :
|
||||
* utiliser la dernière version stable (elle est supposée avoir moins de fuites
|
||||
de mémoire que les versions plus anciennes)
|
||||
* ne pas charger les extensions si vous ne les utilisez pas, par exemple :
|
||||
aspell, fifo, logger, perl, python, ruby, lua, tcl, guile, xfer (utilisé pour
|
||||
les DCC)
|
||||
aspell, fifo, logger, perl, python, ruby, lua, tcl, guile, javascript,
|
||||
xfer (utilisé pour les DCC)
|
||||
* charger uniquement les scripts dont vous avez vraiment besoin
|
||||
* ne pas charger les certificats si SSL n'est *PAS* utilisé : affecter une
|
||||
chaîne vide pour l'option 'weechat.network.gnutls_ca_file'
|
||||
|
||||
@@ -8132,6 +8132,26 @@ Liste des signaux envoyés par WeeChat et les extensions :
|
||||
Un pseudo dans la liste de notifications est de retour (statut d'absence
|
||||
supprimé)
|
||||
|
||||
| javascript | javascript_script_loaded +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
Chaîne : chemin vers le script |
|
||||
Script javascript chargé
|
||||
|
||||
| javascript | javascript_script_unloaded +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
Chaîne : chemin vers le script |
|
||||
Script javascript déchargé
|
||||
|
||||
| javascript | javascript_script_installed +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
Chaîne : liste de chemins vers scripts installés (séparés par des virgules) |
|
||||
Script(s) javascript installé(s)
|
||||
|
||||
| javascript | javascript_script_removed +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
Chaîne : liste de scripts supprimés (séparés par des virgules) |
|
||||
Script(s) javascript supprimé(s)
|
||||
|
||||
| logger | logger_start |
|
||||
Pointeur : tampon |
|
||||
Démarrage de l'enregistrement sur disque pour le tampon
|
||||
@@ -8713,6 +8733,8 @@ Cinq signaux peuvent être envoyés pour installer un script, selon le langage :
|
||||
* 'ruby_script_install'
|
||||
* 'lua_script_install'
|
||||
* 'tcl_script_install'
|
||||
* 'guile_script_install'
|
||||
* 'javascript_script_install'
|
||||
|
||||
Le "callback" effectuera les actions suivantes lorsqu'il recevra le signal :
|
||||
|
||||
@@ -8754,6 +8776,8 @@ langage :
|
||||
* 'ruby_script_remove'
|
||||
* 'lua_script_remove'
|
||||
* 'tcl_script_remove'
|
||||
* 'guile_script_remove'
|
||||
* 'javascript_script_remove'
|
||||
|
||||
Pour chaque script dans la liste, le "callback" déchargera et supprimera le
|
||||
script.
|
||||
|
||||
@@ -29,6 +29,7 @@ l'un des langages de script supportés :
|
||||
* lua
|
||||
* tcl
|
||||
* guile (scheme)
|
||||
* javascript
|
||||
|
||||
[NOTE]
|
||||
La majorité des exemples de cette documentation sont écrits en Python, mais
|
||||
@@ -84,6 +85,10 @@ Weechat.config_new_option(config, section, "name", "string", "description of opt
|
||||
** config_new_option
|
||||
** bar_new
|
||||
|
||||
==== Javascript
|
||||
|
||||
* Les fonctions sont appelées par `weechat.xxx(arg1, arg2, ...);`
|
||||
|
||||
[[register_function]]
|
||||
=== Fonction register
|
||||
|
||||
@@ -165,6 +170,14 @@ weechat::print "" "Bonjour, du script tcl !"
|
||||
(weechat:print "" "Bonjour, du script scheme !")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", "");
|
||||
weechat.print("", "Bonjour, du script javascript !");
|
||||
----
|
||||
|
||||
[[load_script]]
|
||||
=== Chargement du script
|
||||
|
||||
@@ -178,17 +191,19 @@ par exemple :
|
||||
/script load script.lua
|
||||
/script load script.tcl
|
||||
/script load script.scm
|
||||
/script load script.js
|
||||
----
|
||||
|
||||
Chaque langage a également sa propre commande :
|
||||
|
||||
----
|
||||
/python load python/script.py
|
||||
/perl load perl/script.pl
|
||||
/ruby load ruby/script.rb
|
||||
/lua load lua/script.lua
|
||||
/tcl load tcl/script.tcl
|
||||
/guile load guile/script.scm
|
||||
/python load script.py
|
||||
/perl load script.pl
|
||||
/ruby load script.rb
|
||||
/lua load script.lua
|
||||
/tcl load script.tcl
|
||||
/guile load script.scm
|
||||
/javascript load script.js
|
||||
----
|
||||
|
||||
Vous pouvez faire un lien dans le répertoire 'langage/autoload' pour charger
|
||||
@@ -353,6 +368,18 @@ weechat::hook_timer 1000 0 1 timer_cb test
|
||||
(weechat:hook_timer 1000 0 1 "timer_cb" "test")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
function timer_cb(data, remaining_calls) {
|
||||
weechat.print("", "timer! data=" + data);
|
||||
return weechat.WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
weechat.hook_timer(1000, 0, 1, "timer_cb", "test");
|
||||
----
|
||||
|
||||
[[script_api]]
|
||||
== API script
|
||||
|
||||
@@ -531,8 +558,8 @@ weechat.prnt(buffer, "message sur le canal #weechat")
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
La fonction d'affichage est appelée `print` en Perl/Ruby/Lua/Tcl et `prnt` en
|
||||
Python.
|
||||
La fonction d'affichage est appelée `print` en
|
||||
Perl/Ruby/Lua/Tcl/Guile/Javascript et `prnt` en Python.
|
||||
|
||||
[[buffers_send_text]]
|
||||
==== Envoyer du texte au tampon
|
||||
@@ -804,7 +831,7 @@ def config_cb(data, option, value):
|
||||
# ...
|
||||
|
||||
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "")
|
||||
# pour les autres langages, remplacez "python" par le langage ("perl", "ruby", "lua" ou "tcl")
|
||||
# pour les autres langages, remplacez "python" par le langage (perl/ruby/lua/tcl/guile/javascript)
|
||||
----
|
||||
|
||||
[[config_options_weechat]]
|
||||
|
||||
@@ -144,6 +144,9 @@ compiler WeeChat.
|
||||
| guile-2.0-dev | ≥ 2.0 | |
|
||||
Extension guile (scheme)
|
||||
|
||||
| libv8-dev | | |
|
||||
Extension javascript
|
||||
|
||||
| asciidoc | ≥ 8.5.0 | |
|
||||
Construction de la page man et de la documentation
|
||||
|
||||
@@ -250,6 +253,9 @@ Liste des options couramment utilisées :
|
||||
| ENABLE_IRC | `ON`, `OFF` | ON |
|
||||
Compiler <<irc_plugin,l'extension IRC>>.
|
||||
|
||||
| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON |
|
||||
Compiler <<scripts_plugins,l'extension Javascript>>.
|
||||
|
||||
| ENABLE_LARGEFILE | `ON`, `OFF` | ON |
|
||||
Support des gros fichiers.
|
||||
|
||||
@@ -286,7 +292,7 @@ Liste des options couramment utilisées :
|
||||
|
||||
| ENABLE_SCRIPTS | `ON`, `OFF` | ON |
|
||||
Compiler <<scripts_plugins,les extensions de script>> (Python, Perl, Ruby,
|
||||
Lua, Tcl, Guile).
|
||||
Lua, Tcl, Guile, Javascript).
|
||||
|
||||
| ENABLE_TCL | `ON`, `OFF` | ON |
|
||||
Compiler <<scripts_plugins,l'extension Tcl>>.
|
||||
@@ -1829,26 +1835,27 @@ Exemples pour charger, décharger et afficher les extensions :
|
||||
|
||||
Les extensions par défaut sont :
|
||||
|
||||
[width="50%",cols="^1,5",options="header"]
|
||||
[width="100%",cols="^1,5",options="header"]
|
||||
|===
|
||||
| Extension | Description
|
||||
| alias | Définir des alias pour les commandes
|
||||
| aspell | Vérification orthographique de la ligne de commande
|
||||
| charset | Encodage/encodage avec jeu de caractère sur les tampons
|
||||
| exec | Exécution de commandes externes dans WeeChat
|
||||
| fifo | Tube FIFO pour envoyer des commandes à distance vers WeeChat
|
||||
| irc | Discussion avec le protocole IRC
|
||||
| logger | Enregistrement des tampons dans des fichiers
|
||||
| relay | Relai de données via le réseau
|
||||
| script | Gestionnaire de scripts
|
||||
| python | Interface (API) pour scripts Python
|
||||
| perl | Interface (API) pour scripts Perl
|
||||
| ruby | Interface (API) pour scripts Ruby
|
||||
| lua | Interface (API) pour scripts Lua
|
||||
| tcl | Interface (API) pour scripts Tcl
|
||||
| guile | Interface (API) pour scripts Guile (scheme)
|
||||
| trigger | Remplacement de texte et exécution de commande sur des évènements de WeeChat ou des extensions
|
||||
| xfer | Transfert de fichier et discussion directe
|
||||
| Extension | Description
|
||||
| alias | Définir des alias pour les commandes
|
||||
| aspell | Vérification orthographique de la ligne de commande
|
||||
| charset | Encodage/encodage avec jeu de caractère sur les tampons
|
||||
| exec | Exécution de commandes externes dans WeeChat
|
||||
| fifo | Tube FIFO pour envoyer des commandes à distance vers WeeChat
|
||||
| irc | Discussion avec le protocole IRC
|
||||
| logger | Enregistrement des tampons dans des fichiers
|
||||
| relay | Relai de données via le réseau
|
||||
| script | Gestionnaire de scripts
|
||||
| python | Interface (API) pour scripts Python
|
||||
| perl | Interface (API) pour scripts Perl
|
||||
| ruby | Interface (API) pour scripts Ruby
|
||||
| lua | Interface (API) pour scripts Lua
|
||||
| tcl | Interface (API) pour scripts Tcl
|
||||
| guile | Interface (API) pour scripts Guile (scheme)
|
||||
| javascript | Interface (API) pour scripts Javascript
|
||||
| trigger | Remplacement de texte et exécution de commande sur des évènements de WeeChat ou des extensions
|
||||
| xfer | Transfert de fichier et discussion directe
|
||||
|===
|
||||
|
||||
Pour en apprendre plus sur le développement d'extension ou de script (via
|
||||
@@ -2951,8 +2958,8 @@ L'URI doit toujours se terminer par "/weechat" (pour les protocoles 'irc' et
|
||||
[[scripts_plugins]]
|
||||
=== Extensions Scripts
|
||||
|
||||
WeeChat fournit 6 extensions pour scripts : Python, Perl, Ruby, Lua, Tcl et
|
||||
Guile (scheme).
|
||||
WeeChat fournit 7 extensions pour scripts : Python, Perl, Ruby, Lua, Tcl,
|
||||
Guile (scheme) et Javascript.
|
||||
Ces extensions peuvent charger, exécuter et décharger des scripts pour ces
|
||||
langages.
|
||||
|
||||
@@ -3016,6 +3023,11 @@ include::autogen/user/tcl_commands.asciidoc[]
|
||||
|
||||
include::autogen/user/guile_commands.asciidoc[]
|
||||
|
||||
[[javascript_commands]]
|
||||
==== Commandes Javascript
|
||||
|
||||
include::autogen/user/javascript_commands.asciidoc[]
|
||||
|
||||
[[trigger_plugin]]
|
||||
=== Extension Trigger
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
|
||||
| irc | nick | nick del canale IRC corrente
|
||||
|
||||
| javascript | javascript_script | elenco degli script
|
||||
|
||||
| lua | lua_script | elenco degli script
|
||||
|
||||
| perl | perl_script | elenco degli script
|
||||
|
||||
@@ -222,6 +222,40 @@
|
||||
** lists:
|
||||
*** 'irc_servers'
|
||||
*** 'last_irc_server'
|
||||
* 'javascript_callback': callback di uno script
|
||||
** plugin: javascript
|
||||
** variables:
|
||||
*** 'script' (pointer, hdata: "javascript_script")
|
||||
*** 'function' (string)
|
||||
*** 'data' (string)
|
||||
*** 'config_file' (pointer, hdata: "config_file")
|
||||
*** 'config_section' (pointer, hdata: "config_section")
|
||||
*** 'config_option' (pointer, hdata: "config_option")
|
||||
*** 'hook' (pointer)
|
||||
*** 'buffer' (pointer, hdata: "buffer")
|
||||
*** 'bar_item' (pointer, hdata: "bar_item")
|
||||
*** 'upgrade_file' (pointer)
|
||||
*** 'prev_callback' (pointer, hdata: "javascript_callback")
|
||||
*** 'next_callback' (pointer, hdata: "javascript_callback")
|
||||
* 'javascript_script': elenco degli script
|
||||
** plugin: javascript
|
||||
** variables:
|
||||
*** 'filename' (string)
|
||||
*** 'interpreter' (pointer)
|
||||
*** 'name' (string)
|
||||
*** 'author' (string)
|
||||
*** 'version' (string)
|
||||
*** 'license' (string)
|
||||
*** 'description' (string)
|
||||
*** 'shutdown_func' (string)
|
||||
*** 'charset' (string)
|
||||
*** 'callbacks' (pointer, hdata: "javascript_callback")
|
||||
*** 'unloading' (integer)
|
||||
*** 'prev_script' (pointer, hdata: "javascript_script")
|
||||
*** 'next_script' (pointer, hdata: "javascript_script")
|
||||
** lists:
|
||||
*** 'last_script'
|
||||
*** 'scripts'
|
||||
* 'lua_callback': callback di uno script
|
||||
** plugin: lua
|
||||
** variables:
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
| irc | irc_server | elenco di server IRC | puntatore al server (opzionale) | server name (wildcard "*" is allowed) (optional)
|
||||
|
||||
| javascript | javascript_script | elenco degli script | puntatore allo script (opzionale) | script name (wildcard "*" is allowed) (optional)
|
||||
|
||||
| logger | logger_buffer | elenco dei buffer logger | puntatore al logger (opzionale) | -
|
||||
|
||||
| lua | lua_script | elenco degli script | puntatore allo script (opzionale) | script name (wildcard "*" is allowed) (optional)
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
. xfer (6000)
|
||||
. irc (5000)
|
||||
. relay (4000)
|
||||
. guile, lua, perl, python, ruby, tcl (3000)
|
||||
. guile, javascript, lua, perl, python, ruby, tcl (3000)
|
||||
. script (2000)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
[[command_javascript_javascript]]
|
||||
[command]*`javascript`* elenca/carica/scarica script::
|
||||
|
||||
----
|
||||
/javascript list|listfull [<nome>]
|
||||
load [-q] <nomefile>
|
||||
autoload
|
||||
reload|unload [-q][<nome>]
|
||||
|
||||
list: elenca i plugin caricati
|
||||
listfull: elenca i plugin caricati (dettagliato)
|
||||
load: carica un plugin
|
||||
autoload: carica automaticamente i plugin nella directory utente o di sistema
|
||||
reload: ricarica un plugin (se non specificato, scarica i plugin e li ricarica automaticamente)
|
||||
unload: scarica uno o tutti i plugin
|
||||
nome_file: (file) script da caricare
|
||||
nome: il nome di uno script (usato nella chiamata alla funzione "register")
|
||||
-q: modalità silenziosa: non mostra messaggi
|
||||
|
||||
Senza argomento, questo comando elenca tutti i plugin caricati.
|
||||
----
|
||||
|
||||
@@ -772,7 +772,7 @@ Esistono diversi trucchi per ottimizzare l'uso della memoria:
|
||||
* utilizzare l'ultima versione stabile (si suppone che abbia meno falle di memoria
|
||||
rispetto le versioni precedenti)
|
||||
* non caricare alcuni plugin se non vengono utilizzati, ad esempio: aspell, fifo,
|
||||
logger, perl, python, ruby, lua, tcl, guile, xfer (usato per DCC)
|
||||
logger, perl, python, ruby, lua, tcl, guile, javascript, xfer (usato per DCC)
|
||||
* caricare solo gli script veramente necessari
|
||||
* non caricare i certificati se SSL *NON* viene usato: usare una stringa vuota nell'opzione
|
||||
'weechat.network.gnutls_ca_file'
|
||||
|
||||
@@ -8165,6 +8165,30 @@ List of signals sent by WeeChat and plugins:
|
||||
String: nome server + "," + nick |
|
||||
Un nick nella lista notifiche è tornato (messaggio di assenza rimosso)
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| javascript | javascript_script_loaded +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
String: path to script |
|
||||
Javascript script loaded
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| javascript | javascript_script_unloaded +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
String: path to script |
|
||||
Javascript script unloaded
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| javascript | javascript_script_installed +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
String: comma-separated list of paths to scripts installed |
|
||||
Javascript script(s) installed
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| javascript | javascript_script_removed +
|
||||
_(WeeChat ≥ 1.2)_ |
|
||||
String: comma-separated list of scripts removed |
|
||||
Javascript script(s) removed
|
||||
|
||||
| logger | logger_start |
|
||||
Puntatore: buffer |
|
||||
Avvia il logging per il buffer
|
||||
@@ -8808,6 +8832,8 @@ del linguaggio:
|
||||
* 'ruby_script_install'
|
||||
* 'lua_script_install'
|
||||
* 'tcl_script_install'
|
||||
* 'guile_script_install'
|
||||
* 'javascript_script_install'
|
||||
|
||||
La callback compirà le seguenti azioni alla ricezione del segnale:
|
||||
|
||||
@@ -8849,6 +8875,8 @@ seconda del linguaggio:
|
||||
* 'ruby_script_remove'
|
||||
* 'lua_script_remove'
|
||||
* 'tcl_script_remove'
|
||||
* 'guile_script_remove'
|
||||
* 'javascript_script_remove'
|
||||
|
||||
Per ogni script nella lista, la callback scaricherà e rimuoverà lo script.
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ linguaggi di scripting supportati:
|
||||
* lua
|
||||
* tcl
|
||||
* guile (scheme)
|
||||
* javascript
|
||||
|
||||
[NOTE]
|
||||
Quasi tutti gli esempi in questo manuale sono scritti in Python, ma l'API
|
||||
@@ -90,6 +91,10 @@ Weechat.config_new_option(config, section, "name", "string", "description of opt
|
||||
** config_new_option
|
||||
** bar_new
|
||||
|
||||
==== Javascript
|
||||
|
||||
* Le funzioni sono chiamate con `weechat.xxx(arg1, arg2, ...);`
|
||||
|
||||
[[register_function]]
|
||||
=== Registrare una funzione
|
||||
|
||||
@@ -170,6 +175,14 @@ weechat::print "" "Hello, from tcl script!"
|
||||
(weechat:print "" "Hello, from scheme script!")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", "");
|
||||
weechat.print("", "Hello, from javascript script!");
|
||||
----
|
||||
|
||||
[[load_script]]
|
||||
=== Caricare uno script
|
||||
|
||||
@@ -182,17 +195,19 @@ Si raccomanda di usare il plugin "script" per caricare gli script, ad esempio:
|
||||
/script load script.lua
|
||||
/script load script.tcl
|
||||
/script load script.scm
|
||||
/script load script.js
|
||||
----
|
||||
|
||||
Ogni linguaggio ha anche il suo comando specifico:
|
||||
|
||||
----
|
||||
/python load python/script.py
|
||||
/perl load perl/script.pl
|
||||
/ruby load ruby/script.rb
|
||||
/lua load lua/script.lua
|
||||
/tcl load tcl/script.tcl
|
||||
/guile load guile/script.scm
|
||||
/python load script.py
|
||||
/perl load script.pl
|
||||
/ruby load script.rb
|
||||
/lua load script.lua
|
||||
/tcl load script.tcl
|
||||
/guile load script.scm
|
||||
/javascript load script.js
|
||||
----
|
||||
|
||||
È possibile creare un link nella directory 'linguaggio/autoload' per caricare
|
||||
@@ -357,6 +372,18 @@ weechat::hook_timer 1000 0 1 timer_cb test
|
||||
(weechat:hook_timer 1000 0 1 "timer_cb" "test")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
function timer_cb(data, remaining_calls) {
|
||||
weechat.print("", "timer! data=" + data);
|
||||
return weechat.WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
weechat.hook_timer(1000, 0, 1, "timer_cb", "test");
|
||||
----
|
||||
|
||||
[[script_api]]
|
||||
== Script API
|
||||
|
||||
@@ -536,7 +563,8 @@ weechat.prnt(buffer, "message on #weechat channel")
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
La funzione print si chiama `print` in Perl/Ruby/Lua/Tcl e `prnt` in Python.
|
||||
La funzione print si chiama `print` in Perl/Ruby/Lua/Tcl/Guile/Javascript e
|
||||
`prnt` in Python.
|
||||
|
||||
[[buffers_send_text]]
|
||||
==== Invia testo al buffer
|
||||
@@ -808,7 +836,7 @@ def config_cb(data, option, value):
|
||||
# ...
|
||||
|
||||
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "")
|
||||
# for other languages, change "python" with your language ("perl", "ruby", "lua" or "tcl")
|
||||
# for other languages, change "python" with your language (perl/ruby/lua/tcl/guile/javascript)
|
||||
----
|
||||
|
||||
[[config_options_weechat]]
|
||||
|
||||
@@ -156,6 +156,9 @@ compilare WeeChat.
|
||||
| guile-2.0-dev | ≥ 2.0 | |
|
||||
Plugin guile (scheme)
|
||||
|
||||
| libv8-dev | | |
|
||||
Plugin Javascript
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| asciidoc | ≥ 8.5.0 | |
|
||||
Build man page and documentation
|
||||
@@ -269,6 +272,9 @@ List of commonly used options:
|
||||
| ENABLE_IRC | `ON`, `OFF` | ON |
|
||||
Compile <<irc_plugin,IRC plugin>>.
|
||||
|
||||
| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON |
|
||||
Compile <<scripts_plugins,Javascript plugin>>.
|
||||
|
||||
| ENABLE_LARGEFILE | `ON`, `OFF` | ON |
|
||||
Support of large files.
|
||||
|
||||
@@ -305,7 +311,7 @@ List of commonly used options:
|
||||
|
||||
| ENABLE_SCRIPTS | `ON`, `OFF` | ON |
|
||||
Compile <<scripts_plugins,script plugins>> (Python, Perl, Ruby, Lua, Tcl,
|
||||
Guile).
|
||||
Guile, Javascript).
|
||||
|
||||
| ENABLE_TCL | `ON`, `OFF` | ON |
|
||||
Compile <<scripts_plugins,Tcl plugin>>.
|
||||
@@ -1857,28 +1863,29 @@ Esempi per caricare, scaricare oppure elencare i plugin:
|
||||
|
||||
I plugin predefiniti sono:
|
||||
|
||||
[width="50%",cols="^1,5",options="header"]
|
||||
[width="100%",cols="^1,5",options="header"]
|
||||
|===
|
||||
| Plugin | Descrizione
|
||||
| alias | Definisce gli alias per i comandi
|
||||
| aspell | Controllo ortografico per la riga di comando
|
||||
| charset | Set di caratteri per la codifica/decodifica nei buffer
|
||||
| Plugin | Descrizione
|
||||
| alias | Definisce gli alias per i comandi
|
||||
| aspell | Controllo ortografico per la riga di comando
|
||||
| charset | Set di caratteri per la codifica/decodifica nei buffer
|
||||
// TRANSLATION MISSING
|
||||
| exec | Execution of external commands in WeeChat
|
||||
| fifo | pipe FIFO utilizzata per inviare comandi da remoto su WeeChat
|
||||
| irc | protocollo chat per IRC
|
||||
| logger | Registra i buffer su file
|
||||
| relay | Relay dei dati via rete
|
||||
| script | Gestore script
|
||||
| python | API per lo scripting in Python
|
||||
| perl | API per lo scripting in Perl
|
||||
| ruby | API per lo scripting in Ruby
|
||||
| lua | API per lo scripting in Lua
|
||||
| tcl | API per lo scripting in TCL
|
||||
| guile | API per lo scripting in Guile (scheme)
|
||||
| exec | Execution of external commands in WeeChat
|
||||
| fifo | pipe FIFO utilizzata per inviare comandi da remoto su WeeChat
|
||||
| irc | protocollo chat per IRC
|
||||
| logger | Registra i buffer su file
|
||||
| relay | Relay dei dati via rete
|
||||
| script | Gestore script
|
||||
| python | API per lo scripting in Python
|
||||
| perl | API per lo scripting in Perl
|
||||
| ruby | API per lo scripting in Ruby
|
||||
| lua | API per lo scripting in Lua
|
||||
| tcl | API per lo scripting in TCL
|
||||
| guile | API per lo scripting in Guile (scheme)
|
||||
| javascript | API per lo scripting in Javascript
|
||||
// TRANSLATION MISSING
|
||||
| trigger | Text replacement and command execution on events triggered by WeeChat/plugins
|
||||
| xfer | Trasferimento file e chat diretta
|
||||
| trigger | Text replacement and command execution on events triggered by WeeChat/plugins
|
||||
| xfer | Trasferimento file e chat diretta
|
||||
|===
|
||||
|
||||
Per saperne di più riguardo lo sviluppo di plugin o script (tramite le API), per
|
||||
@@ -3007,8 +3014,8 @@ The URI must always end with "/weechat" (for 'irc' and 'weechat' protocols).
|
||||
[[scripts_plugins]]
|
||||
=== Plugin per gli script
|
||||
|
||||
WeeChat fornisce 6 plugin per lo scripting: Python, Perl, Ruby, Lua, Tcl, Guile
|
||||
(scheme).
|
||||
WeeChat fornisce 7 plugin per lo scripting: Python, Perl, Ruby, Lua, Tcl, Guile
|
||||
(scheme), Javascript.
|
||||
Questi plugin possono caricare, eseguire e scaricare gli script per questi
|
||||
linguaggi.
|
||||
|
||||
@@ -3076,6 +3083,11 @@ include::autogen/user/tcl_commands.asciidoc[]
|
||||
|
||||
include::autogen/user/guile_commands.asciidoc[]
|
||||
|
||||
[[javascript_commands]]
|
||||
==== Comandi Javascript
|
||||
|
||||
include::autogen/user/javascript_commands.asciidoc[]
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[[trigger_plugin]]
|
||||
=== Trigger plugin
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
|
||||
| irc | nick | 現在の IRC チャンネルにいるニックネーム
|
||||
|
||||
| javascript | javascript_script | スクリプトのリスト
|
||||
|
||||
| lua | lua_script | スクリプトのリスト
|
||||
|
||||
| perl | perl_script | スクリプトのリスト
|
||||
|
||||
@@ -222,6 +222,40 @@
|
||||
** リスト:
|
||||
*** 'irc_servers'
|
||||
*** 'last_irc_server'
|
||||
* 'javascript_callback': スクリプトのコールバック
|
||||
** プラグイン: javascript
|
||||
** 変数:
|
||||
*** 'script' (pointer, hdata: "javascript_script")
|
||||
*** 'function' (string)
|
||||
*** 'data' (string)
|
||||
*** 'config_file' (pointer, hdata: "config_file")
|
||||
*** 'config_section' (pointer, hdata: "config_section")
|
||||
*** 'config_option' (pointer, hdata: "config_option")
|
||||
*** 'hook' (pointer)
|
||||
*** 'buffer' (pointer, hdata: "buffer")
|
||||
*** 'bar_item' (pointer, hdata: "bar_item")
|
||||
*** 'upgrade_file' (pointer)
|
||||
*** 'prev_callback' (pointer, hdata: "javascript_callback")
|
||||
*** 'next_callback' (pointer, hdata: "javascript_callback")
|
||||
* 'javascript_script': スクリプトのリスト
|
||||
** プラグイン: javascript
|
||||
** 変数:
|
||||
*** 'filename' (string)
|
||||
*** 'interpreter' (pointer)
|
||||
*** 'name' (string)
|
||||
*** 'author' (string)
|
||||
*** 'version' (string)
|
||||
*** 'license' (string)
|
||||
*** 'description' (string)
|
||||
*** 'shutdown_func' (string)
|
||||
*** 'charset' (string)
|
||||
*** 'callbacks' (pointer, hdata: "javascript_callback")
|
||||
*** 'unloading' (integer)
|
||||
*** 'prev_script' (pointer, hdata: "javascript_script")
|
||||
*** 'next_script' (pointer, hdata: "javascript_script")
|
||||
** リスト:
|
||||
*** 'last_script'
|
||||
*** 'scripts'
|
||||
* 'lua_callback': スクリプトのコールバック
|
||||
** プラグイン: lua
|
||||
** 変数:
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
| irc | irc_server | IRC サーバのリスト | サーバポインタ (任意) | サーバ名 (ワイルドカード "*" を使うことができます) (任意)
|
||||
|
||||
| javascript | javascript_script | スクリプトのリスト | スクリプトポインタ (任意) | スクリプト名 (ワイルドカード "*" を使うことができます) (任意)
|
||||
|
||||
| logger | logger_buffer | logger バッファのリスト | logger ポインタ (任意) | -
|
||||
|
||||
| lua | lua_script | スクリプトのリスト | スクリプトポインタ (任意) | スクリプト名 (ワイルドカード "*" を使うことができます) (任意)
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
. xfer (6000)
|
||||
. irc (5000)
|
||||
. relay (4000)
|
||||
. guile, lua, perl, python, ruby, tcl (3000)
|
||||
. guile, javascript, lua, perl, python, ruby, tcl (3000)
|
||||
. script (2000)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
[[command_javascript_javascript]]
|
||||
[command]*`javascript`* スクリプトをリストアップ/ロード/アンロード::
|
||||
|
||||
----
|
||||
/javascript list|listfull [<name>]
|
||||
load [-q] <filename>
|
||||
autoload
|
||||
reload|unload [-q] [<name>]
|
||||
|
||||
list: ロード済みスクリプトをリストアップ
|
||||
listfull: ロード済みスクリプトをリストアップ (詳細)
|
||||
load: スクリプトをロード
|
||||
autoload: "autoload" ディレクトリに含まれる全てのスクリプトをロード
|
||||
reload: スクリプトのリロード (名前を指定しなかった場合、全てのスクリプトをアンロードし、"autoload" ディレクトリに含まれる全てのスクリプトをロード)
|
||||
unload: スクリプトのアンロード (名前を指定しなかった場合、全てのスクリプトをアンロード)
|
||||
filename: ロードするスクリプト (ファイル)
|
||||
name: スクリプト名 (名前は "register" 関数を呼び出すために使われる)
|
||||
-q: 出力抑制モード: メッセージを表示しない
|
||||
|
||||
引数無しの場合、全てのロード済みスクリプトをリストアップします。
|
||||
----
|
||||
|
||||
@@ -51,35 +51,36 @@ WeeChat の主要なリポジトリは 2 つあります:
|
||||
|
||||
[width="100%",cols="1v,5",options="header"]
|
||||
|===
|
||||
| ディレクトリ | 説明
|
||||
| src/ | ソースコードのルートディレクトリ
|
||||
| core/ | コア関数: エントリポイント、内部構造体
|
||||
| gui/ | バッファ、ウィンドウ、... を操作する関数 (全てのインターフェイスで使う)
|
||||
| curses/ | curses インターフェイス
|
||||
| plugins/ | プラグインとスクリプト向け API
|
||||
| alias/ | alias プラグイン
|
||||
| aspell/ | aspell プラグイン
|
||||
| charset/ | charset プラグイン
|
||||
| exec/ | exec プラグイン
|
||||
| fifo/ | fifo プラグイン (WeeChat にコマンドを送信する FIFO パイプ)
|
||||
| irc/ | IRC (Internet Relay Chat) プラグイン
|
||||
| logger/ | logger プラグイン (表示されたメッセージをファイルに書き込む)
|
||||
| relay/ | relay プラグイン (irc プロキシ + リモートインターフェイス用の中継)
|
||||
| script/ | スクリプトマネージャ
|
||||
| python/ | python スクリプト用 API
|
||||
| perl/ | perl スクリプト用 API
|
||||
| ruby/ | ruby スクリプト用 API
|
||||
| lua/ | lua スクリプト用 API
|
||||
| tcl/ | tcl スクリプト用 API
|
||||
| guile/ | guile (scheme) スクリプト用 API
|
||||
| trigger/ | trigger プラグイン
|
||||
| xfer/ | xfer (IRC DCC ファイル/チャット)
|
||||
| tests/ | テスト
|
||||
| unit/ | 単体テスト
|
||||
| core/ | コア関数の単体テスト
|
||||
| doc/ | 文書
|
||||
| po/ | 翻訳ファイル (gettext)
|
||||
| debian/ | Debian パッケージ用
|
||||
| ディレクトリ | 説明
|
||||
| src/ | ソースコードのルートディレクトリ
|
||||
| core/ | コア関数: エントリポイント、内部構造体
|
||||
| gui/ | バッファ、ウィンドウ、... を操作する関数 (全てのインターフェイスで使う)
|
||||
| curses/ | curses インターフェイス
|
||||
| plugins/ | プラグインとスクリプト向け API
|
||||
| alias/ | alias プラグイン
|
||||
| aspell/ | aspell プラグイン
|
||||
| charset/ | charset プラグイン
|
||||
| exec/ | exec プラグイン
|
||||
| fifo/ | fifo プラグイン (WeeChat にコマンドを送信する FIFO パイプ)
|
||||
| irc/ | IRC (Internet Relay Chat) プラグイン
|
||||
| logger/ | logger プラグイン (表示されたメッセージをファイルに書き込む)
|
||||
| relay/ | relay プラグイン (irc プロキシ + リモートインターフェイス用の中継)
|
||||
| script/ | スクリプトマネージャ
|
||||
| python/ | python スクリプト用 API
|
||||
| perl/ | perl スクリプト用 API
|
||||
| ruby/ | ruby スクリプト用 API
|
||||
| lua/ | lua スクリプト用 API
|
||||
| tcl/ | tcl スクリプト用 API
|
||||
| guile/ | guile (scheme) スクリプト用 API
|
||||
| javascript/ | javascript スクリプト用 API
|
||||
| trigger/ | trigger プラグイン
|
||||
| xfer/ | xfer (IRC DCC ファイル/チャット)
|
||||
| tests/ | テスト
|
||||
| unit/ | 単体テスト
|
||||
| core/ | コア関数の単体テスト
|
||||
| doc/ | 文書
|
||||
| po/ | 翻訳ファイル (gettext)
|
||||
| debian/ | Debian パッケージ用
|
||||
|===
|
||||
|
||||
[[sources]]
|
||||
@@ -220,6 +221,11 @@ WeeChat "core" は以下のディレクトリに配置されています:
|
||||
| irc-sasl.c | IRC サーバに対する SASL 認証
|
||||
| irc-server.c | IRC サーバとの入出力通信
|
||||
| irc-upgrade.c | WeeChat をアップグレードする際の IRC データの保存および読み込み
|
||||
| javascript/ | javascript プラグイン
|
||||
| weechat-js.cpp | javascript の主要関数 (スクリプトのロード/アンロード、javascript コードの実行)
|
||||
| weechat-js-api.cpp | javascript スクリプト作成 API 関数
|
||||
// TRANSLATION MISSING
|
||||
| weechat-js-v8.cpp | javascript v8 functions
|
||||
| logger/ | logger プラグイン
|
||||
| logger.c | logger の主要関数
|
||||
| logger-buffer.c | logger バッファリスト管理
|
||||
@@ -1028,7 +1034,7 @@ $ msgcheck.py xx.po
|
||||
ファイルを生成するエイリアスを作ってください:
|
||||
|
||||
----
|
||||
/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /python load docgen.py; /wait 1ms /docgen
|
||||
/alias doc /perl unload; /python unload; /ruby unload; /lua unload; /tcl unload; /guile unload; /javascript unload; /python load docgen.py; /wait 1ms /docgen
|
||||
----
|
||||
|
||||
コマンド `/doc` を使って全ての (全てのプログラミング言語について) 自動生成するファイルを作成してください。
|
||||
|
||||
@@ -730,7 +730,7 @@ OpenBSD では、プラグインファイル名の末尾が ".so.0.0" です (Li
|
||||
* 最新の安定版を使う
|
||||
(古いバージョンよりもメモリリークの可能性が減ると思われます)
|
||||
* 使わないプラグインのロードを禁止する、例えば: aspell、fifo、
|
||||
logger、perl、python、ruby、lua、tcl、guile、xfer (DCC で使用)
|
||||
logger、perl、python、ruby、lua、tcl、guile、javascript、xfer (DCC で使用)
|
||||
* 本当に必要なスクリプトだけをロード
|
||||
* SSL を*使わない*なら、証明書を読み込まないでください: オプション
|
||||
'weechat.network.gnutls_ca_file' に空文字列を設定してください。
|
||||
|
||||
@@ -7984,6 +7984,26 @@ WeeChat とプラグインが送信するシグナルのリスト:
|
||||
String: サーバ名 + "," + ニックネーム |
|
||||
通知リストに入っているニックネームが着席状態に (離席状態を解除)
|
||||
|
||||
| javascript | javascript_script_loaded +
|
||||
_(WeeChat バージョン 1.2 以上で利用可)_ |
|
||||
String: スクリプトへのパス |
|
||||
Javascript スクリプトを読み込み
|
||||
|
||||
| javascript | javascript_script_unloaded +
|
||||
_(WeeChat バージョン 1.2 以上で利用可)_ |
|
||||
String: スクリプトへのパス |
|
||||
Javascript スクリプトを再読み込み
|
||||
|
||||
| javascript | javascript_script_installed +
|
||||
_(WeeChat バージョン 1.2 以上で利用可)_ |
|
||||
String: インストールされたスクリプトへのパスのコンマ区切りリスト |
|
||||
Javascript スクリプトをインストール
|
||||
|
||||
| javascript | javascript_script_removed +
|
||||
_(WeeChat バージョン 1.2 以上で利用可)_ |
|
||||
String: 削除されたスクリプトへのパスのコンマ区切りリスト |
|
||||
Javascript スクリプトを削除
|
||||
|
||||
| logger | logger_start |
|
||||
Pointer: バッファ |
|
||||
バッファのログ保存を開始
|
||||
@@ -8564,6 +8584,8 @@ weechat.hook_signal_send("logger_backlog", weechat.WEECHAT_HOOK_SIGNAL_POINTER,
|
||||
* 'ruby_script_install'
|
||||
* 'lua_script_install'
|
||||
* 'tcl_script_install'
|
||||
* 'guile_script_install'
|
||||
* 'javascript_script_install'
|
||||
|
||||
シグナルを受け取ったらコールバックは以下のように働きます:
|
||||
|
||||
@@ -8602,6 +8624,8 @@ weechat.hook_signal_send("python_script_install", WEECHAT_HOOK_SIGNAL_STRING,
|
||||
* 'ruby_script_remove'
|
||||
* 'lua_script_remove'
|
||||
* 'tcl_script_remove'
|
||||
* 'guile_script_remove'
|
||||
* 'javascript_script_remove'
|
||||
|
||||
リスト文字列に含まれるそれぞれのスクリプトについて、コールバックはスクリプトを再読み込みして削除します。
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ WeeChat (Wee Enhanced Environment for Chat) はフリー、高速、軽量な
|
||||
* lua
|
||||
* tcl
|
||||
* guile (scheme)
|
||||
* javascript
|
||||
|
||||
[NOTE]
|
||||
この文書に含まれるほぼすべての例は Python
|
||||
@@ -168,6 +169,14 @@ weechat::print "" "Hello, from tcl script!"
|
||||
(weechat:print "" "Hello, from scheme script!")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", "");
|
||||
weechat.print("", "Hello, from javascript script!");
|
||||
----
|
||||
|
||||
[[load_script]]
|
||||
=== スクリプトのロード
|
||||
|
||||
@@ -180,17 +189,19 @@ weechat::print "" "Hello, from tcl script!"
|
||||
/script load script.lua
|
||||
/script load script.tcl
|
||||
/script load script.scm
|
||||
/script load script.js
|
||||
----
|
||||
|
||||
プログラミング言語ごとの固有コマンドを利用することもできます:
|
||||
|
||||
----
|
||||
/python load python/script.py
|
||||
/perl load perl/script.pl
|
||||
/ruby load ruby/script.rb
|
||||
/lua load lua/script.lua
|
||||
/tcl load tcl/script.tcl
|
||||
/guile load guile/script.scm
|
||||
/python load script.py
|
||||
/perl load script.pl
|
||||
/ruby load script.rb
|
||||
/lua load script.lua
|
||||
/tcl load script.tcl
|
||||
/guile load script.scm
|
||||
/javascript load script.js
|
||||
----
|
||||
|
||||
WeeChat の開始時にスクリプトを自動ロードするには
|
||||
@@ -351,6 +362,18 @@ weechat::hook_timer 1000 0 1 timer_cb test
|
||||
(weechat:hook_timer 1000 0 1 "timer_cb" "test")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
function timer_cb(data, remaining_calls) {
|
||||
weechat.print("", "timer! data=" + data);
|
||||
return weechat.WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
weechat.hook_timer(1000, 0, 1, "timer_cb", "test");
|
||||
----
|
||||
|
||||
[[script_api]]
|
||||
== スクリプト API
|
||||
|
||||
@@ -528,7 +551,7 @@ weechat.prnt(buffer, "message on #weechat channel")
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
Print 関数は Perl/Ruby/Lua/Tcl では `print` で、Python では `prnt` です。
|
||||
Print 関数は Perl/Ruby/Lua/Tcl/Guile/Javascript では `print` で、Python では `prnt` です。
|
||||
|
||||
[[buffers_send_text]]
|
||||
==== バッファにテキストを送信
|
||||
@@ -791,7 +814,7 @@ def config_cb(data, option, value):
|
||||
# ...
|
||||
|
||||
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "")
|
||||
# 他のスクリプト言語の場合は "python" を適当なもの ("perl"、"ruby"、"lua"、"tcl") に変更してください。
|
||||
# 他のスクリプト言語の場合は "python" を適当なもの (perl/ruby/lua/tcl/guile/javascript) に変更してください。
|
||||
----
|
||||
|
||||
[[config_options_weechat]]
|
||||
|
||||
@@ -143,6 +143,9 @@ OS X では、http://brew.sh/[Homebrew] を使ってください:
|
||||
| guile-2.0-dev | ≥ 2.0 | |
|
||||
guile (scheme) プラグイン
|
||||
|
||||
| libv8-dev | | |
|
||||
javascript プラグイン
|
||||
|
||||
| asciidoc | ≥ 8.5.0 | |
|
||||
man ページと文書のビルド
|
||||
|
||||
@@ -248,6 +251,9 @@ cmake に対するオプションを指定するには、以下のフォーマ
|
||||
| ENABLE_IRC | `ON`, `OFF` | ON |
|
||||
<<irc_plugin,IRC プラグイン>>のコンパイル
|
||||
|
||||
| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON |
|
||||
<<scripts_plugins,Javascript プラグイン>>のコンパイル。
|
||||
|
||||
| ENABLE_LARGEFILE | `ON`, `OFF` | ON |
|
||||
巨大ファイルのサポート。
|
||||
|
||||
@@ -284,7 +290,7 @@ cmake に対するオプションを指定するには、以下のフォーマ
|
||||
|
||||
| ENABLE_SCRIPTS | `ON`, `OFF` | ON |
|
||||
すべての<<scripts_plugins,スクリプトプラグイン>>
|
||||
(Python、Perl、Ruby、Lua、Tcl、Guile) のコンパイル
|
||||
(Python、Perl、Ruby、Lua、Tcl、Guile、Javascript) のコンパイル
|
||||
|
||||
| ENABLE_TCL | `ON`, `OFF` | ON |
|
||||
<<scripts_plugins,Tcl プラグイン>>のコンパイル
|
||||
@@ -1776,7 +1782,7 @@ GNU/Linux の場合、プラグインファイルは ".so" という拡張子を
|
||||
|
||||
デフォルトプラグインのリスト:
|
||||
|
||||
[width="50%",cols="^1,5",options="header"]
|
||||
[width="100%",cols="^1,5",options="header"]
|
||||
|===
|
||||
| プラグイン | 説明
|
||||
| alias | コマンドの別名を定義
|
||||
@@ -1794,6 +1800,7 @@ GNU/Linux の場合、プラグインファイルは ".so" という拡張子を
|
||||
| lua | Lua スクリプト API
|
||||
| tcl | Tcl スクリプト API
|
||||
| guile | Guile (scheme) スクリプト API
|
||||
| javascript | Javascript スクリプト API
|
||||
| trigger | WeeChat およびプラグインが発生させたイベントに対するテキスト置換とコマンド実行
|
||||
| xfer | ファイル転送とダイレクトチャット
|
||||
|===
|
||||
@@ -2860,8 +2867,8 @@ websocket = new WebSocket("ws://server.com:9000/weechat");
|
||||
[[scripts_plugins]]
|
||||
=== スクリプトプラグイン
|
||||
|
||||
WeeChat は 6 種類のスクリプトプラグインを備えています: Python、Perl、Ruby、Lua、Tcl、Guile
|
||||
(scheme)。
|
||||
WeeChat は 7 種類のスクリプトプラグインを備えています: Python、Perl、Ruby、Lua、Tcl、Guile
|
||||
(scheme)、Javascript。
|
||||
これらのプラグインでそれぞれの言語で書かれたスクリプトのロード、実行、アンロードができます。
|
||||
|
||||
"スクリプト" と呼ばれるほかのプラグインはスクリプトマネージャで、任意の言語で書かれたスクリプトをロード
|
||||
@@ -2923,6 +2930,11 @@ include::autogen/user/tcl_commands.asciidoc[]
|
||||
|
||||
include::autogen/user/guile_commands.asciidoc[]
|
||||
|
||||
[[javascript_commands]]
|
||||
==== Javascript コマンド
|
||||
|
||||
include::autogen/user/javascript_commands.asciidoc[]
|
||||
|
||||
[[trigger_plugin]]
|
||||
=== トリガプラグイン
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
|
||||
| irc | nick | użytkownicy obecnego kanału IRC
|
||||
|
||||
| javascript | javascript_script | lista skryptów
|
||||
|
||||
| lua | lua_script | lista skryptów
|
||||
|
||||
| perl | perl_script | lista skryptów
|
||||
|
||||
@@ -222,6 +222,40 @@
|
||||
** listy:
|
||||
*** 'irc_servers'
|
||||
*** 'last_irc_server'
|
||||
* 'javascript_callback': callback skryptu
|
||||
** wtyczka: javascript
|
||||
** zmienne:
|
||||
*** 'script' (pointer, hdata: "javascript_script")
|
||||
*** 'function' (string)
|
||||
*** 'data' (string)
|
||||
*** 'config_file' (pointer, hdata: "config_file")
|
||||
*** 'config_section' (pointer, hdata: "config_section")
|
||||
*** 'config_option' (pointer, hdata: "config_option")
|
||||
*** 'hook' (pointer)
|
||||
*** 'buffer' (pointer, hdata: "buffer")
|
||||
*** 'bar_item' (pointer, hdata: "bar_item")
|
||||
*** 'upgrade_file' (pointer)
|
||||
*** 'prev_callback' (pointer, hdata: "javascript_callback")
|
||||
*** 'next_callback' (pointer, hdata: "javascript_callback")
|
||||
* 'javascript_script': lista skryptów
|
||||
** wtyczka: javascript
|
||||
** zmienne:
|
||||
*** 'filename' (string)
|
||||
*** 'interpreter' (pointer)
|
||||
*** 'name' (string)
|
||||
*** 'author' (string)
|
||||
*** 'version' (string)
|
||||
*** 'license' (string)
|
||||
*** 'description' (string)
|
||||
*** 'shutdown_func' (string)
|
||||
*** 'charset' (string)
|
||||
*** 'callbacks' (pointer, hdata: "javascript_callback")
|
||||
*** 'unloading' (integer)
|
||||
*** 'prev_script' (pointer, hdata: "javascript_script")
|
||||
*** 'next_script' (pointer, hdata: "javascript_script")
|
||||
** listy:
|
||||
*** 'last_script'
|
||||
*** 'scripts'
|
||||
* 'lua_callback': callback skryptu
|
||||
** wtyczka: lua
|
||||
** zmienne:
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
| irc | irc_server | lista serwerów IRC | wskaźnik serwera (opcjonalny) | nazwa serwera (wildcard "*" jest dozwolony) (opcjonalne)
|
||||
|
||||
| javascript | javascript_script | lista skryptów | wskaźnik skryptu (opcjonalne) | nazwa skryptu (wildcard "*" jest dozwolony) (opcjonalne)
|
||||
|
||||
| logger | logger_buffer | lista logowanych buforów | wskaźnik logger (opcjonalny) | -
|
||||
|
||||
| lua | lua_script | lista skryptów | wskaźnik skryptu (opcjonalne) | nazwa skryptu (wildcard "*" jest dozwolony) (opcjonalne)
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
. xfer (6000)
|
||||
. irc (5000)
|
||||
. relay (4000)
|
||||
. guile, lua, perl, python, ruby, tcl (3000)
|
||||
. guile, javascript, lua, perl, python, ruby, tcl (3000)
|
||||
. script (2000)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
[[command_javascript_javascript]]
|
||||
[command]*`javascript`* list/load/unload skrypt::
|
||||
|
||||
----
|
||||
/javascript list|listfull [<nazwa>]
|
||||
load [-q] <nazwapliku>
|
||||
autoload
|
||||
reload|unload [-q] [<nazwa>]
|
||||
|
||||
list: lista załadowanych wtyczek
|
||||
listfull: lista załadowanych wtyczek (szczegółowa)
|
||||
load: ładuje wtyczkę
|
||||
autoload: automatycznie ładuje wtyczki w katalogu systemowym lub użytkownika
|
||||
reload: przeładuje pojedynczą wtyczkę (jeśli nie podano nazwy, wyładuje wszystkie wtyczki, następnie automatycznie załaduje wtyczki)
|
||||
unload: wyładowuje jedną albo wszystkie wtyczki
|
||||
nazwa_pliku: skrypt (plik) do załadowania
|
||||
nazwa: nazwa skryptu (nazwa użyta do wywołania funkcji "register")
|
||||
-q: tryb cichy: nie wyświetla wiadomości
|
||||
|
||||
Bez argumentów ta komenda wyświetli wszystkie załadowane wtyczki.
|
||||
----
|
||||
|
||||
@@ -738,7 +738,7 @@ W celu zmniejszenia używanej pamięci możesz zastosować się do poniższych r
|
||||
* używać najnowsze stabilnej wersji (powinna mieć mniej wycieków pamięci
|
||||
niż starsze wersje)
|
||||
* nie ładuj nieużywanych pluginów, np: aspell, fifo, logger, perl, python,
|
||||
ruby, lua, tcl, guile, xfer (używana do DCC)
|
||||
ruby, lua, tcl, guile, javascript, xfer (używana do DCC)
|
||||
* ładować tylko naprawdę używane skrypty
|
||||
* nie ładuj certyfikatów jeśli SSL *NIE* jest używany: ustaw pusty ciąg w opcji
|
||||
'weechat.network.gnutls_ca_file'
|
||||
|
||||
@@ -34,6 +34,7 @@ wspieranych języków skryptowych:
|
||||
* lua
|
||||
* tcl
|
||||
* guile (scheme)
|
||||
* javascript
|
||||
|
||||
[NOTE]
|
||||
Prawie wszystkie przykłady umieszczone w tym dokumencie są napisane w Pythonie,
|
||||
@@ -88,6 +89,10 @@ Weechat.config_new_option(config, section, "nazwa", "ciąg", "opis opcji", "", 0
|
||||
** config_new_option
|
||||
** bar_new
|
||||
|
||||
==== Javascript
|
||||
|
||||
* Funkcje są wywoływane za pomocą `weechat.xxx(arg1, arg2, ...);`
|
||||
|
||||
[[register_function]]
|
||||
=== Funkcja rejestrująca
|
||||
|
||||
@@ -168,6 +173,14 @@ weechat::print "" "Witaj ze skryptu tcl!"
|
||||
(weechat:print "" "Witaj ze skryptu scheme!")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", "");
|
||||
weechat.print("", "Witaj ze skryptu javascript!");
|
||||
----
|
||||
|
||||
[[load_script]]
|
||||
=== Ładowanie skryptu
|
||||
|
||||
@@ -180,17 +193,19 @@ Zaleca się używanie wtyczki "script" do ładowania skryptów, na przykład:
|
||||
/script load script.lua
|
||||
/script load script.tcl
|
||||
/script load script.scm
|
||||
/script load script.js
|
||||
----
|
||||
|
||||
Każdy język posiada również swoją własną komendę:
|
||||
|
||||
----
|
||||
/python load python/skrypt.py
|
||||
/perl load perl/skrypt.pl
|
||||
/ruby load ruby/skrypt.rb
|
||||
/lua load lua/skrypt.lua
|
||||
/tcl load tcl/skrypt.tcl
|
||||
/guile load guile/skrypt.scm
|
||||
/python load skrypt.py
|
||||
/perl load skrypt.pl
|
||||
/ruby load skrypt.rb
|
||||
/lua load skrypt.lua
|
||||
/tcl load skrypt.tcl
|
||||
/guile load skrypt.scm
|
||||
/javascript load skrypt.js
|
||||
----
|
||||
|
||||
Możesz zrobić dowiązanie w katalogu 'język/autoload' jeśli chcesz automatycznie
|
||||
@@ -348,6 +363,18 @@ weechat::hook_timer 1000 0 1 timer_cb test
|
||||
(weechat:hook_timer 1000 0 1 "timer_cb" "test")
|
||||
----
|
||||
|
||||
* javascript:
|
||||
|
||||
[source,javascript]
|
||||
----
|
||||
function timer_cb(data, remaining_calls) {
|
||||
weechat.print("", "timer! data=" + data);
|
||||
return weechat.WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
weechat.hook_timer(1000, 0, 1, "timer_cb", "test");
|
||||
----
|
||||
|
||||
[[script_api]]
|
||||
== API skryptów
|
||||
|
||||
@@ -524,7 +551,8 @@ weechat.prnt(buffer, "wiadomość na kanale #weechat")
|
||||
----
|
||||
|
||||
[NOTE]
|
||||
Funkcja drukująca nazywa się `print` w Perl/Ruby/Lua/Tcl i `prnt` w Pythonie.
|
||||
Funkcja drukująca nazywa się `print` w Perl/Ruby/Lua/Tcl/Guile/Javascript i
|
||||
`prnt` w Pythonie.
|
||||
|
||||
[[buffers_send_text]]
|
||||
==== Wysyłanie tekstu do bufora
|
||||
@@ -787,7 +815,7 @@ def config_cb(data, option, value):
|
||||
# ...
|
||||
|
||||
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "")
|
||||
# dla innych języków, zmień "python" na swój język ("perl", "ruby", "lua" or "tcl")
|
||||
# dla innych języków, zmień "python" na swój język (perl/ruby/lua/tcl/guile/javascript)
|
||||
----
|
||||
|
||||
[[config_options_weechat]]
|
||||
|
||||
@@ -146,6 +146,9 @@ WeeChat.
|
||||
| guile-2.0-dev | ≥ 2.0 | |
|
||||
Wtyczka guile (scheme)
|
||||
|
||||
| libv8-dev | | |
|
||||
Wtyczka javascript
|
||||
|
||||
| asciidoc | ≥ 8.5.0 | |
|
||||
Tworzenie strony man i dokumentacji
|
||||
|
||||
@@ -253,6 +256,9 @@ Lista popularnych opcji:
|
||||
| ENABLE_IRC | `ON`, `OFF` | ON |
|
||||
Kompilacja <<irc_plugin,wtyczki IRC>>.
|
||||
|
||||
| ENABLE_JAVASCRIPT | `ON`, `OFF` | ON |
|
||||
Kompilacja <<scripts_plugins,wtyczki javascript>>.
|
||||
|
||||
| ENABLE_LARGEFILE | `ON`, `OFF` | ON |
|
||||
Wsparcie dla dużych plików.
|
||||
|
||||
@@ -289,7 +295,7 @@ Lista popularnych opcji:
|
||||
|
||||
| ENABLE_SCRIPTS | `ON`, `OFF` | ON |
|
||||
Kompilacja <<scripts_plugins,wtyczek skryptowych>> (Python, Perl, Ruby, Lua,
|
||||
Tcl, Guile).
|
||||
Tcl, Guile, Javascript).
|
||||
|
||||
| ENABLE_TCL | `ON`, `OFF` | ON |
|
||||
Kompilacja <<scripts_plugins,wtyczki tcl>>.
|
||||
@@ -1792,26 +1798,27 @@ Przykłady ładowania, wyładowywania i wyświetlania załadowanych wtyczek:
|
||||
|
||||
Domyślne wtyczki:
|
||||
|
||||
[width="50%",cols="^1,5",options="header"]
|
||||
[width="100%",cols="^1,5",options="header"]
|
||||
|===
|
||||
| Wtyczka | Opis
|
||||
| alias | Definiuje aliasy dla komend
|
||||
| aspell | Sprawdzanie pisowni w linii poleceń
|
||||
| charset | Ustawianie kodowania dla buforów
|
||||
| exec | Wykonuje zewnętrzną komendę z poziomu WeeChat
|
||||
| fifo | Kolejka FIFO używana do zdalnego wysyłania poleceń dla WeeChat
|
||||
| irc | Protokół IRC
|
||||
| logger | Logowanie zawartości buforów do plików
|
||||
| relay | Przekazuje dane przez sieć
|
||||
| script | Zarządzanie skryptami
|
||||
| python | Wsparcie dla skryptów napisanych w Pythonie
|
||||
| perl | Wsparcie dla skryptów napisanych w Perlu
|
||||
| ruby | Wsparcie dla skryptów napisanych w Ruby
|
||||
| lua | Wsparcie dla skryptów napisanych w Lua
|
||||
| tcl | Wsparcie dla skryptów napisanych w Tcl
|
||||
| guile | Wsparcie dla skryptów napisanych w Guile (scheme)
|
||||
| trigger | Zamiana tekstu i wykonywanie komend dla zdarzeń wywołanych przez WeeChat/wtyczki
|
||||
| xfer | Przesyłanie plików i bezpośredni chat
|
||||
| Wtyczka | Opis
|
||||
| alias | Definiuje aliasy dla komend
|
||||
| aspell | Sprawdzanie pisowni w linii poleceń
|
||||
| charset | Ustawianie kodowania dla buforów
|
||||
| exec | Wykonuje zewnętrzną komendę z poziomu WeeChat
|
||||
| fifo | Kolejka FIFO używana do zdalnego wysyłania poleceń dla WeeChat
|
||||
| irc | Protokół IRC
|
||||
| logger | Logowanie zawartości buforów do plików
|
||||
| relay | Przekazuje dane przez sieć
|
||||
| script | Zarządzanie skryptami
|
||||
| python | Wsparcie dla skryptów napisanych w Pythonie
|
||||
| perl | Wsparcie dla skryptów napisanych w Perlu
|
||||
| ruby | Wsparcie dla skryptów napisanych w Ruby
|
||||
| lua | Wsparcie dla skryptów napisanych w Lua
|
||||
| tcl | Wsparcie dla skryptów napisanych w Tcl
|
||||
| guile | Wsparcie dla skryptów napisanych w Guile (scheme)
|
||||
| javascript | Wsparcie dla skryptów napisanych w Javascript
|
||||
| trigger | Zamiana tekstu i wykonywanie komend dla zdarzeń wywołanych przez WeeChat/wtyczki
|
||||
| xfer | Przesyłanie plików i bezpośredni chat
|
||||
|===
|
||||
|
||||
Więcej informacji o wtyczkach i tworzeniu skryptów (przez API), można znaleźć w
|
||||
@@ -2891,8 +2898,8 @@ Adres URL musi się zawsze kończyć "/weechat" (dla protokołów 'irc' i 'weech
|
||||
[[scripts_plugins]]
|
||||
=== Wtyczki skryptowe
|
||||
|
||||
WeeChat posiada 6 wtyczek skryptowych: Python, Perl, Ruby, Lua, Tcl i Guile
|
||||
(scheme).
|
||||
WeeChat posiada 7 wtyczek skryptowych: Python, Perl, Ruby, Lua, Tcl, Guile
|
||||
(scheme) i Javascript.
|
||||
Wtyczki te potrafią ładować, wykonywać i wyładowywać skrypty w tych językach.
|
||||
|
||||
Inna wtyczka nazwana "script" jest managerem skryptów i jest używana do
|
||||
@@ -2955,6 +2962,11 @@ include::autogen/user/tcl_commands.asciidoc[]
|
||||
|
||||
include::autogen/user/guile_commands.asciidoc[]
|
||||
|
||||
[[javascript_commands]]
|
||||
==== Komendy wtyczki javascript
|
||||
|
||||
include::autogen/user/javascript_commands.asciidoc[]
|
||||
|
||||
[[trigger_plugin]]
|
||||
=== Wtyczka trigger
|
||||
|
||||
|
||||
@@ -180,6 +180,12 @@
|
||||
./src/plugins/irc/irc-sasl.h
|
||||
./src/plugins/irc/irc-server.c
|
||||
./src/plugins/irc/irc-server.h
|
||||
./src/plugins/javascript/weechat-js-api.cpp
|
||||
./src/plugins/javascript/weechat-js-api.h
|
||||
./src/plugins/javascript/weechat-js-v8.cpp
|
||||
./src/plugins/javascript/weechat-js-v8.h
|
||||
./src/plugins/javascript/weechat-js.cpp
|
||||
./src/plugins/javascript/weechat-js.h
|
||||
./src/plugins/logger/logger-buffer.c
|
||||
./src/plugins/logger/logger-buffer.h
|
||||
./src/plugins/logger/logger.c
|
||||
|
||||
@@ -181,6 +181,12 @@ SET(WEECHAT_SOURCES
|
||||
./src/plugins/irc/irc-sasl.h
|
||||
./src/plugins/irc/irc-server.c
|
||||
./src/plugins/irc/irc-server.h
|
||||
./src/plugins/javascript/weechat-js-api.cpp
|
||||
./src/plugins/javascript/weechat-js-api.h
|
||||
./src/plugins/javascript/weechat-js-v8.cpp
|
||||
./src/plugins/javascript/weechat-js-v8.h
|
||||
./src/plugins/javascript/weechat-js.cpp
|
||||
./src/plugins/javascript/weechat-js.h
|
||||
./src/plugins/logger/logger-buffer.c
|
||||
./src/plugins/logger/logger-buffer.h
|
||||
./src/plugins/logger/logger.c
|
||||
|
||||
@@ -141,6 +141,13 @@ if(ENABLE_SCRIPTS AND ENABLE_GUILE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_SCRIPTS AND ENABLE_JAVASCRIPT)
|
||||
find_package(V8)
|
||||
if(V8_FOUND)
|
||||
add_subdirectory(javascript)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_TRIGGER)
|
||||
add_subdirectory(trigger)
|
||||
endif()
|
||||
|
||||
@@ -99,6 +99,10 @@ if PLUGIN_GUILE
|
||||
guile_dir = guile
|
||||
endif
|
||||
|
||||
if PLUGIN_JAVASCRIPT
|
||||
javascript_dir = javascript
|
||||
endif
|
||||
|
||||
if PLUGIN_TRIGGER
|
||||
trigger_dir = trigger
|
||||
endif
|
||||
@@ -110,7 +114,7 @@ endif
|
||||
SUBDIRS = . $(alias_dir) $(aspell_dir) $(charset_dir) $(exec_dir) $(fifo_dir) \
|
||||
$(irc_dir) $(logger_dir) $(relay_dir) $(script_dir) $(perl_dir) \
|
||||
$(python_dir) $(ruby_dir) $(lua_dir) $(tcl_dir) $(guile_dir) \
|
||||
$(trigger_dir) $(xfer_dir)
|
||||
$(javascript_dir) $(trigger_dir) $(xfer_dir)
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
|
||||
#
|
||||
# This file is part of WeeChat, the extensible chat client.
|
||||
#
|
||||
# WeeChat 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
enable_language(CXX)
|
||||
|
||||
add_library(javascript MODULE weechat-js.cpp weechat-js.h
|
||||
weechat-js-v8.cpp weechat-js-v8.h
|
||||
weechat-js-api.cpp weechat-js-api.h)
|
||||
|
||||
set_target_properties(javascript PROPERTIES PREFIX "")
|
||||
|
||||
if(V8_FOUND)
|
||||
include_directories(${V8_INCLUDE_DIR})
|
||||
target_link_libraries(javascript ${V8_LIBRARY} weechat_plugins_scripts)
|
||||
endif()
|
||||
|
||||
install(TARGETS javascript LIBRARY DESTINATION ${LIBDIR}/plugins)
|
||||
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
|
||||
#
|
||||
# This file is part of WeeChat, the extensible chat client.
|
||||
#
|
||||
# WeeChat 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\" $(V8_CFLAGS)
|
||||
|
||||
libdir = ${weechat_libdir}/plugins
|
||||
|
||||
lib_LTLIBRARIES = javascript.la
|
||||
|
||||
javascript_la_SOURCES = weechat-js.cpp \
|
||||
weechat-js.h \
|
||||
weechat-js-v8.cpp \
|
||||
weechat-js-v8.h \
|
||||
weechat-js-api.cpp \
|
||||
weechat-js-api.h
|
||||
javascript_la_LDFLAGS = -module -no-undefined
|
||||
javascript_la_LIBADD = ../lib_weechat_plugins_scripts.la $(V8_LFLAGS)
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Koka El Kiwi <admin@kokabsolu.com>
|
||||
* Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
|
||||
*
|
||||
* This file is part of WeeChat, the extensible chat client.
|
||||
*
|
||||
* WeeChat 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WEECHAT_JS_API_H
|
||||
#define WEECHAT_JS_API_H 1
|
||||
|
||||
extern int weechat_js_api_buffer_input_data_cb (void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
const char *input_data);
|
||||
extern int weechat_js_api_buffer_close_cb (void *data,
|
||||
struct t_gui_buffer *buffer);
|
||||
|
||||
#endif /* WEECHAT_JS_API_H */
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* weechat-js-v8.cpp - v8 javascript functions
|
||||
*
|
||||
* Copyright (C) 2013 Koka El Kiwi <admin@kokabsolu.com>
|
||||
* Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
|
||||
*
|
||||
* This file is part of WeeChat, the extensible chat client.
|
||||
*
|
||||
* WeeChat 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#undef _
|
||||
#include <cstdio>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../weechat-plugin.h"
|
||||
#include "../plugin-script.h"
|
||||
}
|
||||
|
||||
#include "weechat-js.h"
|
||||
#include "weechat-js-v8.h"
|
||||
|
||||
#define PRINT_EXCEPTION \
|
||||
Local<Value> exception = trycatch.Exception(); \
|
||||
String::Utf8Value str_exception(exception); \
|
||||
weechat_printf (NULL, \
|
||||
weechat_gettext ("%s%s: exception: %s"), \
|
||||
weechat_prefix ("error"), JS_PLUGIN_NAME, \
|
||||
*str_exception);
|
||||
|
||||
using namespace v8;
|
||||
|
||||
|
||||
/*
|
||||
* Constructor.
|
||||
*/
|
||||
|
||||
WeechatJsV8::WeechatJsV8()
|
||||
{
|
||||
this->global = ObjectTemplate::New();
|
||||
}
|
||||
|
||||
/*
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
WeechatJsV8::~WeechatJsV8()
|
||||
{
|
||||
this->context.Dispose();
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads a javascript script.
|
||||
*/
|
||||
|
||||
bool
|
||||
WeechatJsV8::load(Handle<String> source)
|
||||
{
|
||||
this->source = source;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads a javascript script.
|
||||
*/
|
||||
|
||||
bool
|
||||
WeechatJsV8::load(const char *source)
|
||||
{
|
||||
Handle<String> src = String::New(source);
|
||||
|
||||
return this->load(src);
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes a javascript script.
|
||||
*/
|
||||
|
||||
bool
|
||||
WeechatJsV8::execScript()
|
||||
{
|
||||
v8::TryCatch trycatch;
|
||||
|
||||
this->context = Context::New(NULL, this->global);
|
||||
Context::Scope context_scope(this->context);
|
||||
Handle<Script> script = Script::Compile(this->source);
|
||||
|
||||
if (script.IsEmpty())
|
||||
{
|
||||
PRINT_EXCEPTION;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Local<Value> value = script->Run();
|
||||
if (value.IsEmpty())
|
||||
{
|
||||
PRINT_EXCEPTION;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks if a function with given name exists in script.
|
||||
*/
|
||||
|
||||
bool
|
||||
WeechatJsV8::functionExists(const char *function)
|
||||
{
|
||||
Context::Scope context_scope(this->context);
|
||||
|
||||
Handle<Object> global = this->context->Global();
|
||||
Handle<Value> value = global->Get(String::New(function));
|
||||
return value->IsFunction();
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes a function in a javascript script.
|
||||
*/
|
||||
|
||||
Handle<Value>
|
||||
WeechatJsV8::execFunction(const char *function, int argc, Handle<Value> *argv)
|
||||
{
|
||||
v8::TryCatch trycatch;
|
||||
|
||||
Context::Scope context_scope(this->context);
|
||||
|
||||
Handle<Object> global = this->context->Global();
|
||||
Handle<Value> value = global->Get(String::New(function));
|
||||
Handle<Function> func = Handle<Function>::Cast(value);
|
||||
|
||||
Handle<Value> res = func->Call(global, argc, argv);
|
||||
if (res.IsEmpty())
|
||||
{
|
||||
PRINT_EXCEPTION;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets something in the global.
|
||||
*/
|
||||
|
||||
void
|
||||
WeechatJsV8::addGlobal(Handle<String> key, Handle<Template> val)
|
||||
{
|
||||
this->global->Set(key, val);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets something in the global.
|
||||
*/
|
||||
|
||||
void
|
||||
WeechatJsV8::addGlobal(const char *key, Handle<Template> val)
|
||||
{
|
||||
this->addGlobal(String::New(key), val);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Koka El Kiwi <admin@kokabsolu.com>
|
||||
* Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
|
||||
*
|
||||
* This file is part of WeeChat, the extensible chat client.
|
||||
*
|
||||
* WeeChat 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WEECHAT_JS_V8_H
|
||||
#define WEECHAT_JS_V8_H 1
|
||||
|
||||
#include <cstdio>
|
||||
#include <v8.h>
|
||||
|
||||
class WeechatJsV8
|
||||
{
|
||||
public:
|
||||
WeechatJsV8(void);
|
||||
~WeechatJsV8(void);
|
||||
|
||||
bool load(v8::Handle<v8::String>);
|
||||
bool load(const char *);
|
||||
|
||||
bool execScript(void);
|
||||
bool functionExists(const char *);
|
||||
v8::Handle<v8::Value> execFunction(const char *,
|
||||
int argc, v8::Handle<v8::Value> *);
|
||||
|
||||
void addGlobal(v8::Handle<v8::String>, v8::Handle<v8::Template>);
|
||||
void addGlobal(const char *, v8::Handle<v8::Template>);
|
||||
|
||||
void loadLibs(void);
|
||||
|
||||
private:
|
||||
v8::HandleScope handle_scope;
|
||||
v8::Handle<v8::ObjectTemplate> global;
|
||||
v8::Persistent<Context> context;
|
||||
|
||||
v8::Handle<v8::String> source;
|
||||
};
|
||||
|
||||
#endif /* WEECHAT_JS_V8_H */
|
||||
@@ -0,0 +1,868 @@
|
||||
/*
|
||||
* weechat-js.cpp - javascript plugin for WeeChat
|
||||
*
|
||||
* Copyright (C) 2013 Koka El Kiwi <admin@kokabsolu.com>
|
||||
* Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
|
||||
*
|
||||
* This file is part of WeeChat, the extensible chat client.
|
||||
*
|
||||
* WeeChat 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../weechat-plugin.h"
|
||||
#include "../plugin-script.h"
|
||||
}
|
||||
|
||||
#include "weechat-js.h"
|
||||
#include "weechat-js-api.h"
|
||||
#include "weechat-js-v8.h"
|
||||
|
||||
WEECHAT_PLUGIN_NAME(JS_PLUGIN_NAME);
|
||||
WEECHAT_PLUGIN_DESCRIPTION("Support of javascript scripts");
|
||||
WEECHAT_PLUGIN_AUTHOR("Koka El Kiwi <admin@kokabsolu.com>");
|
||||
WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION);
|
||||
WEECHAT_PLUGIN_LICENSE(WEECHAT_LICENSE);
|
||||
WEECHAT_PLUGIN_PRIORITY(3000);
|
||||
|
||||
struct t_weechat_plugin *weechat_js_plugin;
|
||||
|
||||
int js_quiet = 0;
|
||||
struct t_plugin_script *js_scripts = NULL;
|
||||
struct t_plugin_script *last_js_script = NULL;
|
||||
struct t_plugin_script *js_current_script = NULL;
|
||||
struct t_plugin_script *js_registered_script = NULL;
|
||||
const char *js_current_script_filename = NULL;
|
||||
WeechatJsV8 *js_current_interpreter = NULL;
|
||||
|
||||
/*
|
||||
* string used to execute action "install":
|
||||
* when signal "js_script_install" is received, name of string
|
||||
* is added to this string, to be installed later by a timer (when nothing is
|
||||
* running in script)
|
||||
*/
|
||||
char *js_action_install_list = NULL;
|
||||
|
||||
/*
|
||||
* string used to execute action "remove":
|
||||
* when signal "js_script_remove" is received, name of string
|
||||
* is added to this string, to be removed later by a timer (when nothing is
|
||||
* running in script)
|
||||
*/
|
||||
char *js_action_remove_list = NULL;
|
||||
|
||||
/*
|
||||
* string used to execute action "autoload":
|
||||
* when signal "js_script_autoload" is received, name of string
|
||||
* is added to this string, to autoload or disable autoload later by a timer
|
||||
* (when nothing is running in script)
|
||||
*/
|
||||
char *js_action_autoload_list = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Callback called for each key/value in a hashtable.
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_js_hashtable_map_cb (void *data,
|
||||
struct t_hashtable *hashtable,
|
||||
const char *key,
|
||||
const char *value)
|
||||
{
|
||||
/* make C++ compiler happy */
|
||||
(void) hashtable;
|
||||
|
||||
Handle<Object> *obj = (Handle<Object> *)data;
|
||||
|
||||
(*obj)->Set(String::New(key), String::New(value));
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts a WeeChat hashtable to a javascript hashtable.
|
||||
*/
|
||||
|
||||
Handle<Object>
|
||||
weechat_js_hashtable_to_object (struct t_hashtable *hashtable)
|
||||
{
|
||||
Handle<Object> obj = Object::New();
|
||||
|
||||
weechat_hashtable_map_string (hashtable,
|
||||
&weechat_js_hashtable_map_cb,
|
||||
&obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts a javascript hashtable to a WeeChat hashtable.
|
||||
*
|
||||
* Note: hashtable must be freed after use.
|
||||
*/
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_js_object_to_hashtable (Handle<Object> obj,
|
||||
int size,
|
||||
const char *type_keys,
|
||||
const char *type_values)
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
unsigned int i;
|
||||
Handle<Array> keys;
|
||||
Handle<Value> key, value;
|
||||
|
||||
hashtable = weechat_hashtable_new (size, type_keys, type_values,
|
||||
NULL, NULL);
|
||||
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
keys = obj->GetPropertyNames();
|
||||
for (i = 0; i < keys->Length(); i++)
|
||||
{
|
||||
key = keys->Get(i);
|
||||
value = obj->Get(key);
|
||||
String::Utf8Value str_key(key);
|
||||
String::Utf8Value str_value(value);
|
||||
if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
|
||||
{
|
||||
weechat_hashtable_set (hashtable, *str_key, *str_value);
|
||||
}
|
||||
else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
|
||||
{
|
||||
weechat_hashtable_set (hashtable, *str_key,
|
||||
plugin_script_str2ptr (weechat_js_plugin,
|
||||
NULL, NULL,
|
||||
*str_value));
|
||||
}
|
||||
}
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes a javascript function.
|
||||
*/
|
||||
|
||||
void *
|
||||
weechat_js_exec (struct t_plugin_script *script,
|
||||
int ret_type, const char *function,
|
||||
const char *format, void **argv)
|
||||
{
|
||||
struct t_plugin_script *old_js_current_script;
|
||||
WeechatJsV8 *js_v8;
|
||||
void *ret_value;
|
||||
Handle<Value> argv2[16], ret_js;
|
||||
int i, argc, *ret_int;
|
||||
|
||||
ret_value = NULL;
|
||||
|
||||
old_js_current_script = js_current_script;
|
||||
js_current_script = script;
|
||||
js_v8 = (WeechatJsV8 *)(script->interpreter);
|
||||
|
||||
if (!js_v8->functionExists(function))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to run function \"%s\""),
|
||||
weechat_prefix ("error"), JS_PLUGIN_NAME, function);
|
||||
goto end;
|
||||
}
|
||||
|
||||
argc = 0;
|
||||
if (format && format[0])
|
||||
{
|
||||
argc = strlen (format);
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
switch (format[i])
|
||||
{
|
||||
case 's': /* string */
|
||||
argv2[i] = v8::String::New((const char *)argv[i]);
|
||||
break;
|
||||
case 'i': /* integer */
|
||||
argv2[i] = v8::Integer::New(*((int *)argv[i]));
|
||||
break;
|
||||
case 'h': /* hash */
|
||||
argv2[i] = weechat_js_hashtable_to_object (
|
||||
(struct t_hashtable *)argv[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret_js = js_v8->execFunction(function,
|
||||
argc,
|
||||
(argc > 0) ? argv2 : NULL);
|
||||
|
||||
if (!ret_js.IsEmpty())
|
||||
{
|
||||
if ((ret_type == WEECHAT_SCRIPT_EXEC_STRING) && (ret_js->IsString()))
|
||||
{
|
||||
String::Utf8Value temp_str(ret_js);
|
||||
ret_value = *temp_str;
|
||||
}
|
||||
else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (ret_js->IsInt32()))
|
||||
{
|
||||
ret_int = (int *)malloc (sizeof (*ret_int));
|
||||
if (ret_int)
|
||||
*ret_int = (int)(ret_js->IntegerValue());
|
||||
ret_value = ret_int;
|
||||
}
|
||||
else if ((ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE)
|
||||
&& (ret_js->IsObject()))
|
||||
{
|
||||
ret_value = (struct t_hashtable *)weechat_js_object_to_hashtable (
|
||||
ret_js->ToObject(),
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"%s\" must "
|
||||
"return a valid value"),
|
||||
weechat_prefix ("error"), JS_PLUGIN_NAME,
|
||||
function);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret_value)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: error in function \"%s\""),
|
||||
weechat_prefix ("error"), JS_PLUGIN_NAME, function);
|
||||
}
|
||||
|
||||
end:
|
||||
js_current_script = old_js_current_script;
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads a javascript script.
|
||||
*
|
||||
* Returns:
|
||||
* 1: OK
|
||||
* 0: error
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_js_load (const char *filename)
|
||||
{
|
||||
char *source;
|
||||
|
||||
source = weechat_file_get_content (filename);
|
||||
if (!source)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: script \"%s\" not found"),
|
||||
weechat_prefix ("error"), JS_PLUGIN_NAME, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((weechat_js_plugin->debug >= 2) || !js_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: loading script \"%s\""),
|
||||
JS_PLUGIN_NAME, filename);
|
||||
}
|
||||
|
||||
js_current_script = NULL;
|
||||
js_registered_script = NULL;
|
||||
|
||||
js_current_interpreter = new WeechatJsV8();
|
||||
|
||||
if (!js_current_interpreter)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to create new"
|
||||
"sub-interpreter"),
|
||||
weechat_prefix ("error"), JS_PLUGIN_NAME);
|
||||
free (source);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* load libs */
|
||||
js_current_interpreter->loadLibs();
|
||||
|
||||
js_current_script_filename = filename;
|
||||
|
||||
if (!js_current_interpreter->load(source))
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to load file \"%s\""),
|
||||
weechat_prefix ("error"), JS_PLUGIN_NAME);
|
||||
delete js_current_interpreter;
|
||||
free (source);
|
||||
|
||||
/* if script was registered, remove it from list */
|
||||
if (js_current_script)
|
||||
{
|
||||
plugin_script_remove (weechat_js_plugin,
|
||||
&js_scripts, &last_js_script,
|
||||
js_current_script);
|
||||
js_current_script = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
free (source);
|
||||
|
||||
if (!js_current_interpreter->execScript())
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: unable to execute file "
|
||||
"\"%s\""),
|
||||
weechat_prefix ("error"), JS_PLUGIN_NAME, filename);
|
||||
delete js_current_interpreter;
|
||||
|
||||
/* if script was registered, remove it from list */
|
||||
if (js_current_script)
|
||||
{
|
||||
plugin_script_remove (weechat_js_plugin,
|
||||
&js_scripts, &last_js_script,
|
||||
js_current_script);
|
||||
js_current_script = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!js_registered_script)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: function \"register\" not "
|
||||
"found (or failed) in file \"%s\""),
|
||||
weechat_prefix ("error"), JS_PLUGIN_NAME, filename);
|
||||
delete js_current_interpreter;
|
||||
return 0;
|
||||
}
|
||||
|
||||
js_current_script = js_registered_script;
|
||||
|
||||
/*
|
||||
* set input/close callbacks for buffers created by this script
|
||||
* (to restore callbacks after upgrade)
|
||||
*/
|
||||
plugin_script_set_buffer_callbacks (weechat_js_plugin,
|
||||
js_scripts,
|
||||
js_current_script,
|
||||
&weechat_js_api_buffer_input_data_cb,
|
||||
&weechat_js_api_buffer_close_cb);
|
||||
|
||||
weechat_hook_signal_send ("javascript_script_loaded",
|
||||
WEECHAT_HOOK_SIGNAL_STRING,
|
||||
js_current_script->filename);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for script_auto_load() function.
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_js_load_cb (void *data, const char *filename)
|
||||
{
|
||||
/* make C++ compiler happy */
|
||||
(void) data;
|
||||
|
||||
weechat_js_load (filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unloads a javascript script.
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_js_unload (struct t_plugin_script *script)
|
||||
{
|
||||
int *rc;
|
||||
char *filename;
|
||||
void *interpreter;
|
||||
|
||||
if ((weechat_js_plugin->debug >= 2) || !js_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: unloading script \"%s\""),
|
||||
JS_PLUGIN_NAME, script->name);
|
||||
}
|
||||
|
||||
if (script->shutdown_func && script->shutdown_func[0])
|
||||
{
|
||||
rc = (int *)weechat_js_exec (script, WEECHAT_SCRIPT_EXEC_INT,
|
||||
script->shutdown_func, NULL, NULL);
|
||||
if (rc)
|
||||
free (rc);
|
||||
}
|
||||
|
||||
filename = strdup (script->filename);
|
||||
interpreter = script->interpreter;
|
||||
|
||||
if (js_current_script == script)
|
||||
{
|
||||
js_current_script = (js_current_script->prev_script) ?
|
||||
js_current_script->prev_script : js_current_script->next_script;
|
||||
}
|
||||
|
||||
plugin_script_remove (weechat_js_plugin,
|
||||
&js_scripts, &last_js_script, script);
|
||||
|
||||
if (interpreter)
|
||||
delete((WeechatJsV8 *)interpreter);
|
||||
|
||||
(void) weechat_hook_signal_send ("javascript_script_unloaded",
|
||||
WEECHAT_HOOK_SIGNAL_STRING, filename);
|
||||
if (filename)
|
||||
free (filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unloads a javascript script by name.
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_js_unload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
|
||||
ptr_script = plugin_script_search (weechat_js_plugin, js_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
weechat_js_unload (ptr_script);
|
||||
if (!js_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: script \"%s\" unloaded"),
|
||||
JS_PLUGIN_NAME, name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: script \"%s\" not loaded"),
|
||||
weechat_prefix ("error"), JS_PLUGIN_NAME, name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Unloads all javascript scripts.
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_js_unload_all ()
|
||||
{
|
||||
while (js_scripts)
|
||||
{
|
||||
weechat_js_unload (js_scripts);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Reloads a javascript script by name.
|
||||
*/
|
||||
|
||||
void
|
||||
weechat_js_reload_name (const char *name)
|
||||
{
|
||||
struct t_plugin_script *ptr_script;
|
||||
char *filename;
|
||||
|
||||
ptr_script = plugin_script_search (weechat_js_plugin, js_scripts, name);
|
||||
if (ptr_script)
|
||||
{
|
||||
filename = strdup (ptr_script->filename);
|
||||
if (filename)
|
||||
{
|
||||
weechat_js_unload (ptr_script);
|
||||
if (!js_quiet)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s: script \"%s\" unloaded"),
|
||||
JS_PLUGIN_NAME, name);
|
||||
}
|
||||
weechat_js_load (filename);
|
||||
free (filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
weechat_gettext ("%s%s: script \"%s\" not loaded"),
|
||||
weechat_prefix ("error"), JS_PLUGIN_NAME, name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for command "/javascript".
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_js_command_cb (void *data, struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
char *ptr_name, *path_script;
|
||||
|
||||
/* make C++ compiler happy */
|
||||
(void) data;
|
||||
(void) buffer;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
plugin_script_display_list (weechat_js_plugin, js_scripts,
|
||||
NULL, 0);
|
||||
}
|
||||
else if (argc == 2)
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "list") == 0)
|
||||
{
|
||||
plugin_script_display_list (weechat_js_plugin, js_scripts,
|
||||
NULL, 0);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "listfull") == 0)
|
||||
{
|
||||
plugin_script_display_list (weechat_js_plugin, js_scripts,
|
||||
NULL, 1);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "autoload") == 0)
|
||||
{
|
||||
plugin_script_auto_load (weechat_js_plugin, &weechat_js_load_cb);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "reload") == 0)
|
||||
{
|
||||
weechat_js_unload_all ();
|
||||
plugin_script_auto_load (weechat_js_plugin, &weechat_js_load_cb);
|
||||
}
|
||||
else if (weechat_strcasecmp(argv[1], "unload"))
|
||||
{
|
||||
weechat_js_unload_all ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (weechat_strcasecmp (argv[1], "list") == 0)
|
||||
{
|
||||
plugin_script_display_list (weechat_js_plugin, js_scripts,
|
||||
argv_eol[2], 0);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "listfull") == 0)
|
||||
{
|
||||
plugin_script_display_list (weechat_js_plugin, js_scripts,
|
||||
argv_eol[2], 1);
|
||||
}
|
||||
else if ((weechat_strcasecmp (argv[1], "load") == 0)
|
||||
|| (weechat_strcasecmp (argv[1], "reload") == 0)
|
||||
|| (weechat_strcasecmp (argv[1], "unload") == 0))
|
||||
{
|
||||
ptr_name = argv_eol[2];
|
||||
if (strncmp (ptr_name, "-q ", 3) == 0)
|
||||
{
|
||||
js_quiet = 1;
|
||||
ptr_name += 3;
|
||||
while (ptr_name[0] == ' ')
|
||||
{
|
||||
ptr_name++;
|
||||
}
|
||||
}
|
||||
if (weechat_strcasecmp (argv[1], "load") == 0)
|
||||
{
|
||||
/* load javascript script */
|
||||
path_script = plugin_script_search_path (weechat_js_plugin,
|
||||
ptr_name);
|
||||
weechat_js_load ((path_script) ? path_script : ptr_name);
|
||||
if (path_script)
|
||||
free (path_script);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "reload") == 0)
|
||||
{
|
||||
/* reload one javascript script */
|
||||
weechat_js_reload_name (ptr_name);
|
||||
}
|
||||
else if (weechat_strcasecmp (argv[1], "unload") == 0)
|
||||
{
|
||||
/* unload javascript script */
|
||||
weechat_js_unload_name (ptr_name);
|
||||
}
|
||||
js_quiet = 0;
|
||||
}
|
||||
else
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds javascript scripts to completion list.
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_js_completion_cb (void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
/* make C++ compiler happy */
|
||||
(void) data;
|
||||
(void) completion_item;
|
||||
(void) buffer;
|
||||
|
||||
plugin_script_completion (weechat_js_plugin, completion, js_scripts);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hdata for javascript scripts.
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
weechat_js_hdata_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
/* make C++ compiler happy */
|
||||
(void) data;
|
||||
|
||||
return plugin_script_hdata_script (weechat_plugin,
|
||||
&js_scripts, &last_js_script,
|
||||
hdata_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns infolist with javascript scripts.
|
||||
*/
|
||||
|
||||
struct t_infolist *
|
||||
weechat_js_infolist_cb (void *data, const char *infolist_name,
|
||||
void *pointer, const char *arguments)
|
||||
{
|
||||
/* make C++ compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (!infolist_name || !infolist_name[0])
|
||||
return NULL;
|
||||
|
||||
if (weechat_strcasecmp (infolist_name, "javascript_script") == 0)
|
||||
{
|
||||
return plugin_script_infolist_list_scripts (weechat_js_plugin,
|
||||
js_scripts, pointer,
|
||||
arguments);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dumps javascript plugin data in Weechat log file.
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_js_signal_debug_dump_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C++ compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
if (!signal_data
|
||||
|| (weechat_strcasecmp ((char *)signal_data, JS_PLUGIN_NAME) == 0))
|
||||
{
|
||||
plugin_script_print_log (weechat_js_plugin, js_scripts);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display infos about external libraries used.
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_js_signal_debug_libs_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C++ compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
weechat_printf (NULL, " %s (v8): %s", JS_PLUGIN_NAME, V8::GetVersion());
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback called when a buffer is closed.
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_js_signal_buffer_closed_cb (void *data, const char *signal,
|
||||
const char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C++ compiler happy */
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
|
||||
if (signal_data)
|
||||
{
|
||||
plugin_script_remove_buffer_callbacks (js_scripts,
|
||||
(struct t_gui_buffer *)signal_data);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer for executing actions.
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_js_timer_action_cb (void *data, int remaining_calls)
|
||||
{
|
||||
/* make C++ compiler happy */
|
||||
(void) remaining_calls;
|
||||
|
||||
if (data)
|
||||
{
|
||||
if (data == &js_action_install_list)
|
||||
{
|
||||
plugin_script_action_install (weechat_js_plugin,
|
||||
js_scripts,
|
||||
&weechat_js_unload,
|
||||
&weechat_js_load,
|
||||
&js_quiet,
|
||||
&js_action_install_list);
|
||||
}
|
||||
else if (data == &js_action_remove_list)
|
||||
{
|
||||
plugin_script_action_remove (weechat_js_plugin,
|
||||
js_scripts,
|
||||
&weechat_js_unload,
|
||||
&js_quiet,
|
||||
&js_action_remove_list);
|
||||
}
|
||||
else if (data == &js_action_autoload_list)
|
||||
{
|
||||
plugin_script_action_autoload (weechat_js_plugin,
|
||||
&js_quiet,
|
||||
&js_action_autoload_list);
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback called when a script action is asked (install/remove/autoload a
|
||||
* script).
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_js_signal_script_action_cb (void *data, const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C++ compiler happy */
|
||||
(void) data;
|
||||
|
||||
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
|
||||
{
|
||||
if (strcmp (signal, "javascript_script_install") == 0)
|
||||
{
|
||||
plugin_script_action_add (&js_action_install_list,
|
||||
(const char *)signal_data);
|
||||
weechat_hook_timer (1, 0, 1,
|
||||
&weechat_js_timer_action_cb,
|
||||
&js_action_install_list);
|
||||
}
|
||||
else if (strcmp (signal, "javascript_script_remove") == 0)
|
||||
{
|
||||
plugin_script_action_add (&js_action_remove_list,
|
||||
(const char *)signal_data);
|
||||
weechat_hook_timer (1, 0, 1,
|
||||
&weechat_js_timer_action_cb,
|
||||
&js_action_remove_list);
|
||||
}
|
||||
else if (strcmp (signal, "javascript_script_autoload") == 0)
|
||||
{
|
||||
plugin_script_action_add (&js_action_autoload_list,
|
||||
(const char *)signal_data);
|
||||
weechat_hook_timer (1, 0, 1,
|
||||
&weechat_js_timer_action_cb,
|
||||
&js_action_autoload_list);
|
||||
}
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes javascript plugin.
|
||||
*/
|
||||
|
||||
EXPORT int
|
||||
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
{
|
||||
struct t_plugin_script_init init;
|
||||
|
||||
weechat_js_plugin = plugin;
|
||||
|
||||
init.callback_command = &weechat_js_command_cb;
|
||||
init.callback_completion = &weechat_js_completion_cb;
|
||||
init.callback_hdata = &weechat_js_hdata_cb;
|
||||
init.callback_infolist = &weechat_js_infolist_cb;
|
||||
init.callback_signal_debug_dump = &weechat_js_signal_debug_dump_cb;
|
||||
init.callback_signal_debug_libs = &weechat_js_signal_debug_libs_cb;
|
||||
init.callback_signal_buffer_closed = &weechat_js_signal_buffer_closed_cb;
|
||||
init.callback_signal_script_action = &weechat_js_signal_script_action_cb;
|
||||
init.callback_load_file = &weechat_js_load_cb;
|
||||
|
||||
js_quiet = 1;
|
||||
plugin_script_init (plugin, argc, argv, &init);
|
||||
js_quiet = 0;
|
||||
|
||||
plugin_script_display_short_list (weechat_js_plugin, js_scripts);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Ends javascript plugin.
|
||||
*/
|
||||
|
||||
EXPORT int
|
||||
weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
js_quiet = 1;
|
||||
plugin_script_end (plugin, &js_scripts, &weechat_js_unload_all);
|
||||
js_quiet = 0;
|
||||
|
||||
/* free some data */
|
||||
if (js_action_install_list)
|
||||
free (js_action_install_list);
|
||||
if (js_action_remove_list)
|
||||
free (js_action_remove_list);
|
||||
if (js_action_autoload_list)
|
||||
free (js_action_autoload_list);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Koka El Kiwi <admin@kokabsolu.com>
|
||||
* Copyright (C) 2015 Sébastien Helleu <flashcode@flashtux.org>
|
||||
*
|
||||
* This file is part of WeeChat, the extensible chat client.
|
||||
*
|
||||
* WeeChat 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WEECHAT_JS_H
|
||||
#define WEECHAT_JS_H 1
|
||||
|
||||
#include <v8.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef _WIN32
|
||||
#define EXPORT extern "C" __declspec (dllexport)
|
||||
#else
|
||||
#define EXPORT extern "C"
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT
|
||||
#endif
|
||||
|
||||
#define weechat_plugin weechat_js_plugin
|
||||
#define JS_PLUGIN_NAME "javascript"
|
||||
|
||||
#define JS_CURRENT_SCRIPT_NAME ((js_current_script) ? js_current_script->name : "-")
|
||||
|
||||
using namespace v8;
|
||||
|
||||
class WeechatJsV8;
|
||||
|
||||
extern struct t_weechat_plugin *weechat_js_plugin;
|
||||
|
||||
extern int js_quiet;
|
||||
extern struct t_plugin_script *js_scripts;
|
||||
extern struct t_plugin_script *last_js_script;
|
||||
extern struct t_plugin_script *js_current_script;
|
||||
extern struct t_plugin_script *js_registered_script;
|
||||
extern const char *js_current_script_filename;
|
||||
extern WeechatJsV8 *js_current_interpreter;
|
||||
|
||||
extern Handle<Object> weechat_js_hashtable_to_object (struct t_hashtable *hashtable);
|
||||
extern struct t_hashtable *weechat_js_object_to_hashtable (Handle<Object> obj,
|
||||
int size,
|
||||
const char *type_keys,
|
||||
const char *type_values);
|
||||
extern void *weechat_js_exec (struct t_plugin_script *script,
|
||||
int ret_type, const char *function,
|
||||
const char *format, void **argv);
|
||||
|
||||
#endif /* WEECHAT_JS_H */
|
||||
@@ -370,9 +370,9 @@ script_command_init ()
|
||||
" || show %(script_scripts)"
|
||||
" || load %(script_files)|%*"
|
||||
" || unload %(python_script)|%(perl_script)|%(ruby_script)|"
|
||||
"%(tcl_script)|%(lua_script)|%(guile_script)|%*"
|
||||
"%(tcl_script)|%(lua_script)|%(guile_script)|%(javascript_script)|%*"
|
||||
" || reload %(python_script)|%(perl_script)|%(ruby_script)|"
|
||||
"%(tcl_script)|%(lua_script)|%(guile_script)|%*"
|
||||
"%(tcl_script)|%(lua_script)|%(guile_script)|%(javascript_script)|%*"
|
||||
" || autoload %(script_scripts_installed)|%*"
|
||||
" || noautoload %(script_scripts_installed)|%*"
|
||||
" || toggleautoload %(script_scripts_installed)|%*"
|
||||
|
||||
@@ -45,9 +45,9 @@ WEECHAT_PLUGIN_PRIORITY(2000);
|
||||
struct t_weechat_plugin *weechat_script_plugin = NULL;
|
||||
|
||||
char *script_language[SCRIPT_NUM_LANGUAGES] =
|
||||
{ "guile", "lua", "perl", "python", "ruby", "tcl" };
|
||||
{ "guile", "lua", "perl", "python", "ruby", "tcl", "javascript" };
|
||||
char *script_extension[SCRIPT_NUM_LANGUAGES] =
|
||||
{ "scm", "lua", "pl", "py", "rb", "tcl" };
|
||||
{ "scm", "lua", "pl", "py", "rb", "tcl", "js" };
|
||||
|
||||
int script_plugin_loaded[SCRIPT_NUM_LANGUAGES];
|
||||
struct t_hashtable *script_loaded = NULL;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#define weechat_plugin weechat_script_plugin
|
||||
#define SCRIPT_PLUGIN_NAME "script"
|
||||
|
||||
#define SCRIPT_NUM_LANGUAGES 6
|
||||
#define SCRIPT_NUM_LANGUAGES 7
|
||||
|
||||
extern struct t_weechat_plugin *weechat_script_plugin;
|
||||
|
||||
|
||||
+2
-1
@@ -56,9 +56,10 @@ lua perl pkg-config python ruby source-highlight tcl zlib-devel"
|
||||
# 2. enable build of man pages and documentation
|
||||
# 3. disable Guile plugin because WeeChat requires Guile >= 2.0,
|
||||
# which is not yet available in Cygwin
|
||||
# 4. disable Javascript plugin because libv8 is not available in Cygwin
|
||||
#
|
||||
CYGCMAKE_ARGS="-DPREFIX=/usr -DENABLE_MAN=ON -DENABLE_DOC=ON \
|
||||
-DENABLE_GUILE=OFF"
|
||||
-DENABLE_GUILE=OFF -DENABLE_JAVASCRIPT=OFF"
|
||||
|
||||
#
|
||||
# Build 8 Cygwin packages:
|
||||
|
||||
Reference in New Issue
Block a user