~ubuntu-branches/ubuntu/wily/weechat/wily

« back to all changes in this revision

Viewing changes to doc/it/weechat_scripting.it.asciidoc

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bouthenot
  • Date: 2015-08-19 18:34:17 UTC
  • mfrom: (29.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20150819183417-u026z5wo8knpcdqd
Tags: 1.3-1
* New upstream release
  - Remove backported patch to fix FTBFS with ruby 2.2
* Use dh-exec to build javascript plugin only on architectures which v8
  engine supports. Thanks to Mateusz Łukasik for the patch
  (Closes: #794584)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
:author: Sébastien Helleu
3
3
:email: flashcode@flashtux.org
4
4
:lang: it
5
 
:toc:
 
5
:toc2:
6
6
:toclevels: 3
 
7
:max-width: 100%
 
8
 
 
9
 
 
10
// TRANSLATION MISSING
 
11
Translators:
 
12
 
 
13
* Marco Paolone <marcopaolone@gmail.com>, 2010-2013
7
14
 
8
15
 
9
16
Questo manuale documenta il client di chat WeeChat, ed è parte
28
35
* lua
29
36
* tcl
30
37
* guile (scheme)
 
38
* javascript
31
39
 
32
40
[NOTE]
33
41
Quasi tutti gli esempi in questo manuale sono scritti in Python, ma l'API
83
91
** config_new_option
84
92
** bar_new
85
93
 
 
94
==== Javascript
 
95
 
 
96
* Le funzioni sono chiamate con `weechat.xxx(arg1, arg2, ...);`
 
97
 
86
98
[[register_function]]
87
99
=== Registrare una funzione
88
100
 
110
122
 
111
123
Esempio di script, per ogni linguaggio:
112
124
 
113
 
* python:
 
125
* Python:
114
126
 
115
127
[source,python]
116
128
----
120
132
weechat.prnt("", "Hello, from python script!")
121
133
----
122
134
 
123
 
* perl:
 
135
* Perl:
124
136
 
125
137
[source,perl]
126
138
----
128
140
weechat::print("", "Hello, from perl script!");
129
141
----
130
142
 
131
 
* ruby:
 
143
* Ruby:
132
144
 
133
145
[source,ruby]
134
146
----
139
151
end
140
152
----
141
153
 
142
 
* lua:
 
154
* Lua:
143
155
 
144
156
[source,lua]
145
157
----
147
159
weechat.print("", "Hello, from lua script!")
148
160
----
149
161
 
150
 
* tcl:
 
162
* Tcl:
151
163
 
152
164
[source,tcl]
153
165
----
155
167
weechat::print "" "Hello, from tcl script!"
156
168
----
157
169
 
158
 
* guile (scheme):
 
170
* Guile (scheme):
159
171
 
160
172
[source,lisp]
161
173
----
163
175
(weechat:print "" "Hello, from scheme script!")
164
176
----
165
177
 
 
178
* Javascript:
 
179
 
 
180
[source,javascript]
 
181
----
 
182
weechat.register("test_js", "FlashCode", "1.0", "GPL3", "Test script", "", "");
 
183
weechat.print("", "Hello, from javascript script!");
 
184
----
 
185
 
166
186
[[load_script]]
167
187
=== Caricare uno script
168
188
 
175
195
/script load script.lua
176
196
/script load script.tcl
177
197
/script load script.scm
 
198
/script load script.js
178
199
----
179
200
 
180
201
Ogni linguaggio ha anche il suo comando specifico:
181
202
 
182
203
----
183
 
/python load python/script.py
184
 
/perl load perl/script.pl
185
 
/ruby load ruby/script.rb
186
 
/lua load lua/script.lua
187
 
/tcl load tcl/script.tcl
188
 
/guile load guile/script.scm
 
204
/python load script.py
 
205
/perl load script.pl
 
206
/ruby load script.rb
 
207
/lua load script.lua
 
208
/tcl load script.tcl
 
209
/guile load script.scm
 
210
/javascript load script.js
189
211
----
190
212
 
191
213
È possibile creare un link nella directory 'linguaggio/autoload' per caricare
278
300
 
279
301
Esempio di callback, per ogni linguaggio:
280
302
 
281
 
* python:
 
303
* Python:
282
304
 
283
305
[source,python]
284
306
----
289
311
weechat.hook_timer(1000, 0, 1, "timer_cb", "test")
290
312
----
291
313
 
292
 
* perl:
 
314
* Perl:
293
315
 
294
316
[source,perl]
295
317
----
302
324
weechat::hook_timer(1000, 0, 1, "timer_cb", "test");
303
325
----
304
326
 
305
 
* ruby:
 
327
* Ruby:
306
328
 
307
329
[source,ruby]
308
330
----
314
336
Weechat.hook_timer(1000, 0, 1, "timer_cb", "test");
315
337
----
316
338
 
317
 
* lua:
 
339
* Lua:
318
340
 
319
341
[source,lua]
320
342
----
326
348
weechat.hook_timer(1000, 0, 1, "timer_cb", "test")
327
349
----
328
350
 
329
 
* tcl:
 
351
* Tcl:
330
352
 
331
353
[source,tcl]
332
354
----
338
360
weechat::hook_timer 1000 0 1 timer_cb test
339
361
----
340
362
 
341
 
* guile (scheme):
 
363
* Guile (scheme):
342
364
 
343
365
[source,lisp]
344
366
----
350
372
(weechat:hook_timer 1000 0 1 "timer_cb" "test")
351
373
----
352
374
 
 
375
* Javascript:
 
376
 
 
377
[source,javascript]
 
378
----
 
379
function timer_cb(data, remaining_calls) {
 
380
    weechat.print("", "timer! data=" + data);
 
381
    return weechat.WEECHAT_RC_OK;
 
382
}
 
383
 
 
384
weechat.hook_timer(1000, 0, 1, "timer_cb", "test");
 
385
----
 
386
 
353
387
[[script_api]]
354
388
== Script API
355
389
 
372
406
  charset_set, iconv_to_internal, iconv_from_internal, gettext, ngettext, +
373
407
  strlen_screen, string_match, string_has_highlight, string_has_highlight_regex,
374
408
  string_mask_to_regex, string_remove_color, string_is_command_char,
375
 
  string_input_for_buffer, string_eval_expression
 
409
  string_input_for_buffer, string_eval_expression, string_eval_path_home
376
410
| directory              |
377
411
  mkdir_home, mkdir, mkdir_parents
378
412
| liste ordinate         |
529
563
----
530
564
 
531
565
[NOTE]
532
 
La funzione print si chiama `print` in Perl/Ruby/Lua/Tcl e `prnt` in Python.
 
566
La funzione print si chiama `print` in Perl/Ruby/Lua/Tcl/Guile/Javascript e
 
567
`prnt` in Python.
533
568
 
534
569
[[buffers_send_text]]
535
570
==== Invia testo al buffer
801
836
# ...
802
837
 
803
838
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "")
804
 
# for other languages, change "python" with your language ("perl", "ruby", "lua" or "tcl")
 
839
# for other languages, change "python" with your language (perl/ruby/lua/tcl/guile/javascript)
805
840
----
806
841
 
807
842
[[config_options_weechat]]
892
927
È possibile verificare un messaggio irc con una info_hashtable chiamata
893
928
"irc_message_parse".
894
929
 
 
930
// TRANSLATION MISSING
 
931
The result is a hashtable with following keys
 
932
(the example values are built with this message:
 
933
`@time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello!`):
 
934
 
 
935
[width="100%",cols="1,^2,10,8",options="header"]
 
936
|===
 
937
| Key | WeeChat version | Description | Example
 
938
 
 
939
| tags | ≥ 0.4.0 |
 
940
  The tags in message (can be empty) |
 
941
  `time=2015-06-27T16:40:35.000Z`
 
942
 
 
943
| message_without_tags | ≥ 0.4.0 |
 
944
  The message without the tags (the same as message if there are no tags) |
 
945
  `:nick!user@host PRIVMSG #weechat :hello!`
 
946
 
 
947
| nick | ≥ 0.3.4 |
 
948
  The origin nick |
 
949
  `nick`
 
950
 
 
951
| host | ≥ 0.3.4 |
 
952
  The origin host (includes the nick) |
 
953
  `nick!user@host`
 
954
 
 
955
| command | ≥ 0.3.4 |
 
956
  The command ('PRIVMSG', 'NOTICE', ...) |
 
957
  `PRIVMSG`
 
958
 
 
959
| channel | ≥ 0.3.4 |
 
960
  The target channel |
 
961
  `#weechat`
 
962
 
 
963
| arguments | ≥ 0.3.4 |
 
964
  The command arguments (includes the channel) |
 
965
  `#weechat :hello!`
 
966
 
 
967
| text | ≥ 1.3 |
 
968
  The text (for example user message) |
 
969
  `hello!`
 
970
 
 
971
| pos_command | ≥ 1.3 |
 
972
  The index of 'command' in message ("-1" if 'command' was not found) |
 
973
  `47`
 
974
 
 
975
| pos_arguments | ≥ 1.3 |
 
976
  The index of 'arguments' in message ("-1" if 'arguments' was not found) |
 
977
  `55`
 
978
 
 
979
| pos_channel | ≥ 1.3 |
 
980
  The index of 'channel' in message ("-1" if 'channel' was not found) |
 
981
  `55`
 
982
 
 
983
| pos_text | ≥ 1.3 |
 
984
  The index of 'text' in message ("-1" if 'text' was not found) |
 
985
  `65`
 
986
|===
 
987
 
895
988
[source,python]
896
989
----
897
 
dict = weechat.info_get_hashtable("irc_message_parse",
898
 
                                  {"message": ":nick!user@host PRIVMSG #weechat :message here"})
899
 
weechat.prnt("", "dict: %s" % dict)
 
990
dict = weechat.info_get_hashtable(
 
991
    "irc_message_parse",
 
992
    {"message": "@time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello!"})
900
993
 
901
 
# output:
902
 
#   dict: {'nick': 'nick', 'host': 'nick!user@host', 'command': 'PRIVMSG', 'arguments': '#weechat :message here', 'channel': '#weechat'}
 
994
# dict == {
 
995
#     "tags": "time=2015-06-27T16:40:35.000Z",
 
996
#     "message_without_tags": ":nick!user@host PRIVMSG #weechat :hello!",
 
997
#     "nick": "nick",
 
998
#     "host": "nick!user@host",
 
999
#     "command": "PRIVMSG",
 
1000
#     "channel": "#weechat",
 
1001
#     "arguments": "#weechat :hello!",
 
1002
#     "text": "hello!",
 
1003
#     "pos_command": "47",
 
1004
#     "pos_arguments": "55",
 
1005
#     "pos_channel": "55",
 
1006
#     "pos_text": "65",
 
1007
# }
903
1008
----
904
1009
 
905
1010
[[infos]]