/usr/share/doc/weechat-doc/html/weechat_scripting.en.html is in weechat-doc 1.6-1+deb9u2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 1.5.4">
<meta name="author" content="Sébastien Helleu">
<title>WeeChat scripting guide</title>
<style>
/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */
/* Remove comment around @import statement below when using as a custom stylesheet */
/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700";*/
article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}
audio,canvas,video{display:inline-block}
audio:not([controls]){display:none;height:0}
[hidden],template{display:none}
script{display:none!important}
html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
body{margin:0}
a{background:transparent}
a:focus{outline:thin dotted}
a:active,a:hover{outline:0}
h1{font-size:2em;margin:.67em 0}
abbr[title]{border-bottom:1px dotted}
b,strong{font-weight:bold}
dfn{font-style:italic}
hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}
mark{background:#ff0;color:#000}
code,kbd,pre,samp{font-family:monospace;font-size:1em}
pre{white-space:pre-wrap}
q{quotes:"\201C" "\201D" "\2018" "\2019"}
small{font-size:80%}
sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
sup{top:-.5em}
sub{bottom:-.25em}
img{border:0}
svg:not(:root){overflow:hidden}
figure{margin:0}
fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
legend{border:0;padding:0}
button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
button,input{line-height:normal}
button,select{text-transform:none}
button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}
button[disabled],html input[disabled]{cursor:default}
input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}
input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}
input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}
button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
textarea{overflow:auto;vertical-align:top}
table{border-collapse:collapse;border-spacing:0}
*,*:before,*:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}
html,body{font-size:100%}
body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto}
a:hover{cursor:pointer}
img,object,embed{max-width:100%;height:auto}
object,embed{height:100%}
img{-ms-interpolation-mode:bicubic}
.left{float:left!important}
.right{float:right!important}
.text-left{text-align:left!important}
.text-right{text-align:right!important}
.text-center{text-align:center!important}
.text-justify{text-align:justify!important}
.hide{display:none}
body{-webkit-font-smoothing:antialiased}
img,object,svg{display:inline-block;vertical-align:middle}
textarea{height:auto;min-height:50px}
select{width:100%}
.center{margin-left:auto;margin-right:auto}
.spread{width:100%}
p.lead,.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{font-size:1.21875em;line-height:1.6}
.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}
a{color:#2156a5;text-decoration:underline;line-height:inherit}
a:hover,a:focus{color:#1d4b8f}
a img{border:none}
p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
p aside{font-size:.875em;line-height:1.35;font-style:italic}
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
h1{font-size:2.125em}
h2{font-size:1.6875em}
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
h4,h5{font-size:1.125em}
h6{font-size:1em}
hr{border:solid #ddddd8;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0}
em,i{font-style:italic;line-height:inherit}
strong,b{font-weight:bold;line-height:inherit}
small{font-size:60%;line-height:inherit}
code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
ul,ol,ul.no-bullet,ol.no-bullet{margin-left:1.5em}
ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em}
ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
ul.square{list-style-type:square}
ul.circle{list-style-type:circle}
ul.disc{list-style-type:disc}
ul.no-bullet{list-style:none}
ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
dl dt{margin-bottom:.3125em;font-weight:bold}
dl dd{margin-bottom:1.25em}
abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help}
abbr{text-transform:none}
blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)}
blockquote cite:before{content:"\2014 \0020"}
blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)}
blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
@media only screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
h1{font-size:2.75em}
h2{font-size:2.3125em}
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
h4{font-size:1.4375em}}
table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede}
table thead,table tfoot{background:#f7f8f7;font-weight:bold}
table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7}
table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6}
body{tab-size:4}
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
.clearfix:before,.clearfix:after,.float-group:before,.float-group:after{content:" ";display:table}
.clearfix:after,.float-group:after{clear:both}
*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed}
.keyseq{color:rgba(51,51,51,.8)}
kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
.keyseq kbd:first-child{margin-left:0}
.keyseq kbd:last-child{margin-right:0}
.menuseq,.menu{color:rgba(0,0,0,.8)}
b.button:before,b.button:after{position:relative;top:-1px;font-weight:400}
b.button:before{content:"[";padding:0 3px 0 2px}
b.button:after{content:"]";padding:0 2px 0 3px}
p a>code:hover{color:rgba(0,0,0,.9)}
#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
#header:before,#header:after,#content:before,#content:after,#footnotes:before,#footnotes:after,#footer:before,#footer:after{content:" ";display:table}
#header:after,#content:after,#footnotes:after,#footer:after{clear:both}
#content{margin-top:1.25em}
#content:before{content:none}
#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #ddddd8}
#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #ddddd8;padding-bottom:8px}
#header .details{border-bottom:1px solid #ddddd8;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap}
#header .details span:first-child{margin-left:-.125em}
#header .details span.email a{color:rgba(0,0,0,.85)}
#header .details br{display:none}
#header .details br+span:before{content:"\00a0\2013\00a0"}
#header .details br+span.author:before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
#header .details br+span#revremark:before{content:"\00a0|\00a0"}
#header #revnumber{text-transform:capitalize}
#header #revnumber:after{content:"\00a0"}
#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #ddddd8;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
#toc{border-bottom:1px solid #efefed;padding-bottom:.5em}
#toc>ul{margin-left:.125em}
#toc ul.sectlevel0>li>a{font-style:italic}
#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
#toc li{line-height:1.3334;margin-top:.3334em}
#toc a{text-decoration:none}
#toc a:active{text-decoration:underline}
#toctitle{color:#7a2518;font-size:1.2em}
@media only screen and (min-width:768px){#toctitle{font-size:1.375em}
body.toc2{padding-left:15em;padding-right:0}
#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #efefed;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
#toc.toc2>ul{font-size:.9em;margin-bottom:0}
#toc.toc2 ul ul{margin-left:0;padding-left:1em}
#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
body.toc2.toc-right{padding-left:0;padding-right:15em}
body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #efefed;left:auto;right:0}}
@media only screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
#toc.toc2{width:20em}
#toc.toc2 #toctitle{font-size:1.375em}
#toc.toc2>ul{font-size:.95em}
#toc.toc2 ul ul{padding-left:1.25em}
body.toc2.toc-right{padding-left:0;padding-right:20em}}
#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
#content #toc>:first-child{margin-top:0}
#content #toc>:last-child{margin-bottom:0}
#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em}
#footer-text{color:rgba(255,255,255,.8);line-height:1.44}
.sect1{padding-bottom:.625em}
@media only screen and (min-width:768px){.sect1{padding-bottom:1.25em}}
.sect1+.sect1{border-top:1px solid #efefed}
#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
#content h1>a.anchor:before,h2>a.anchor:before,h3>a.anchor:before,#toctitle>a.anchor:before,.sidebarblock>.content>.title>a.anchor:before,h4>a.anchor:before,h5>a.anchor:before,h6>a.anchor:before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
table.tableblock>caption.title{white-space:nowrap;overflow:visible;max-width:0}
.paragraph.lead>p,#preamble>.sectionbody>.paragraph:first-of-type p{color:rgba(0,0,0,.85)}
table.tableblock #preamble>.sectionbody>.paragraph:first-of-type p{font-size:inherit}
.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
.admonitionblock>table td.icon{text-align:center;width:80px}
.admonitionblock>table td.icon img{max-width:none}
.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #ddddd8;color:rgba(0,0,0,.6)}
.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px}
.exampleblock>.content>:first-child{margin-top:0}
.exampleblock>.content>:last-child{margin-bottom:0}
.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
.sidebarblock>:first-child{margin-top:0}
.sidebarblock>:last-child{margin-bottom:0}
.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8}
.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1}
.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;padding:1em;font-size:.8125em}
.literalblock pre.nowrap,.literalblock pre[class].nowrap,.listingblock pre.nowrap,.listingblock pre[class].nowrap{overflow-x:auto;white-space:pre;word-wrap:normal}
@media only screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}}
@media only screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}}
.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)}
.listingblock pre.highlightjs{padding:0}
.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px}
.listingblock pre.prettyprint{border-width:0}
.listingblock>.content{position:relative}
.listingblock code[data-lang]:before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999}
.listingblock:hover code[data-lang]:before{display:block}
.listingblock.terminal pre .command:before{content:attr(data-prompt);padding-right:.5em;color:#999}
.listingblock.terminal pre .command:not([data-prompt]):before{content:"$"}
table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none}
table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0;line-height:1.45}
table.pyhltable td.code{padding-left:.75em;padding-right:0}
pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #ddddd8}
pre.pygments .lineno{display:inline-block;margin-right:.25em}
table.pyhltable .linenodiv{background:none!important;padding-right:0!important}
.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em}
.quoteblock blockquote,.quoteblock blockquote p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
.quoteblock blockquote{margin:0;padding:0;border:0}
.quoteblock blockquote:before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
.quoteblock .attribution{margin-top:.5em;margin-right:.5ex;text-align:right}
.quoteblock .quoteblock{margin-left:0;margin-right:0;padding:.5em 0;border-left:3px solid rgba(0,0,0,.6)}
.quoteblock .quoteblock blockquote{padding:0 0 0 .75em}
.quoteblock .quoteblock blockquote:before{display:none}
.verseblock{margin:0 1em 1.25em 1em}
.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
.verseblock pre strong{font-weight:400}
.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
.quoteblock .attribution br,.verseblock .attribution br{display:none}
.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
.quoteblock.abstract{margin:0 0 1.25em 0;display:block}
.quoteblock.abstract blockquote,.quoteblock.abstract blockquote p{text-align:left;word-spacing:0}
.quoteblock.abstract blockquote:before,.quoteblock.abstract blockquote p:first-of-type:before{display:none}
table.tableblock{max-width:100%;border-collapse:separate}
table.tableblock td>.paragraph:last-child p>p:last-child,table.tableblock th>p:last-child,table.tableblock td>p:last-child{margin-bottom:0}
table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
table.grid-all th.tableblock,table.grid-all td.tableblock{border-width:0 1px 1px 0}
table.grid-all tfoot>tr>th.tableblock,table.grid-all tfoot>tr>td.tableblock{border-width:1px 1px 0 0}
table.grid-cols th.tableblock,table.grid-cols td.tableblock{border-width:0 1px 0 0}
table.grid-all *>tr>.tableblock:last-child,table.grid-cols *>tr>.tableblock:last-child{border-right-width:0}
table.grid-rows th.tableblock,table.grid-rows td.tableblock{border-width:0 0 1px 0}
table.grid-all tbody>tr:last-child>th.tableblock,table.grid-all tbody>tr:last-child>td.tableblock,table.grid-all thead:last-child>tr>th.tableblock,table.grid-rows tbody>tr:last-child>th.tableblock,table.grid-rows tbody>tr:last-child>td.tableblock,table.grid-rows thead:last-child>tr>th.tableblock{border-bottom-width:0}
table.grid-rows tfoot>tr>th.tableblock,table.grid-rows tfoot>tr>td.tableblock{border-width:1px 0 0 0}
table.frame-all{border-width:1px}
table.frame-sides{border-width:0 1px}
table.frame-topbot{border-width:1px 0}
th.halign-left,td.halign-left{text-align:left}
th.halign-right,td.halign-right{text-align:right}
th.halign-center,td.halign-center{text-align:center}
th.valign-top,td.valign-top{vertical-align:top}
th.valign-bottom,td.valign-bottom{vertical-align:bottom}
th.valign-middle,td.valign-middle{vertical-align:middle}
table thead th,table tfoot th{font-weight:bold}
tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7}
tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
p.tableblock>code:only-child{background:none;padding:0}
p.tableblock{font-size:1em}
td>div.verse{white-space:pre}
ol{margin-left:1.75em}
ul li ol{margin-left:1.5em}
dl dd{margin-left:1.125em}
dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
ul.unstyled,ol.unnumbered,ul.checklist,ul.none{list-style-type:none}
ul.unstyled,ol.unnumbered,ul.checklist{margin-left:.625em}
ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1em;font-size:.85em}
ul.checklist li>p:first-child>input[type="checkbox"]:first-child{width:1em;position:relative;top:1px}
ul.inline{margin:0 auto .625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden}
ul.inline>li{list-style:none;float:left;margin-left:1.375em;display:block}
ul.inline>li>*{display:block}
.unstyled dl dt{font-weight:400;font-style:normal}
ol.arabic{list-style-type:decimal}
ol.decimal{list-style-type:decimal-leading-zero}
ol.loweralpha{list-style-type:lower-alpha}
ol.upperalpha{list-style-type:upper-alpha}
ol.lowerroman{list-style-type:lower-roman}
ol.upperroman{list-style-type:upper-roman}
ol.lowergreek{list-style-type:lower-greek}
.hdlist>table,.colist>table{border:0;background:none}
.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
td.hdlist1{font-weight:bold;padding-bottom:1.25em}
.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
.colist>table tr>td:first-of-type{padding:0 .75em;line-height:1}
.colist>table tr>td:last-of-type{padding:.25em 0}
.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd}
.imageblock.left,.imageblock[style*="float: left"]{margin:.25em .625em 1.25em 0}
.imageblock.right,.imageblock[style*="float: right"]{margin:.25em 0 1.25em .625em}
.imageblock>.title{margin-bottom:0}
.imageblock.thumb,.imageblock.th{border-width:6px}
.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
.image.left{margin-right:.625em}
.image.right{margin-left:.625em}
a.image{text-decoration:none;display:inline-block}
a.image object{pointer-events:none}
sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
sup.footnote a,sup.footnoteref a{text-decoration:none}
sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em 0;border-width:1px 0 0 0}
#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;text-indent:-1.05em;margin-bottom:.2em}
#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none}
#footnotes .footnote:last-of-type{margin-bottom:0}
#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
.gist .file-data>table td.line-data{width:99%}
div.unbreakable{page-break-inside:avoid}
.big{font-size:larger}
.small{font-size:smaller}
.underline{text-decoration:underline}
.overline{text-decoration:overline}
.line-through{text-decoration:line-through}
.aqua{color:#00bfbf}
.aqua-background{background-color:#00fafa}
.black{color:#000}
.black-background{background-color:#000}
.blue{color:#0000bf}
.blue-background{background-color:#0000fa}
.fuchsia{color:#bf00bf}
.fuchsia-background{background-color:#fa00fa}
.gray{color:#606060}
.gray-background{background-color:#7d7d7d}
.green{color:#006000}
.green-background{background-color:#007d00}
.lime{color:#00bf00}
.lime-background{background-color:#00fa00}
.maroon{color:#600000}
.maroon-background{background-color:#7d0000}
.navy{color:#000060}
.navy-background{background-color:#00007d}
.olive{color:#606000}
.olive-background{background-color:#7d7d00}
.purple{color:#600060}
.purple-background{background-color:#7d007d}
.red{color:#bf0000}
.red-background{background-color:#fa0000}
.silver{color:#909090}
.silver-background{background-color:#bcbcbc}
.teal{color:#006060}
.teal-background{background-color:#007d7d}
.white{color:#bfbfbf}
.white-background{background-color:#fafafa}
.yellow{color:#bfbf00}
.yellow-background{background-color:#fafa00}
span.icon>.fa{cursor:default}
.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
.admonitionblock td.icon .icon-note:before{content:"\f05a";color:#19407c}
.admonitionblock td.icon .icon-tip:before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
.admonitionblock td.icon .icon-warning:before{content:"\f071";color:#bf6900}
.admonitionblock td.icon .icon-caution:before{content:"\f06d";color:#bf3400}
.admonitionblock td.icon .icon-important:before{content:"\f06a";color:#bf0000}
.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
.conum[data-value] *{color:#fff!important}
.conum[data-value]+b{display:none}
.conum[data-value]:after{content:attr(data-value)}
pre .conum[data-value]{position:relative;top:-.125em}
b.conum *{color:inherit!important}
.conum:not([data-value]):empty{display:none}
dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
h1,h2,p,td.content,span.alt{letter-spacing:-.01em}
p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
p,blockquote,dt,td.content,span.alt{font-size:1.0625rem}
p{margin-bottom:1.25rem}
.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
.print-only{display:none!important}
@media print{@page{margin:1.25cm .75cm}
*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important}
a{color:inherit!important;text-decoration:underline!important}
a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
a[href^="http:"]:not(.bare):after,a[href^="https:"]:not(.bare):after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
abbr[title]:after{content:" (" attr(title) ")"}
pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
thead{display:table-header-group}
svg{max-width:100%}
p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
#toc,.sidebarblock,.exampleblock>.content{background:none!important}
#toc{border-bottom:1px solid #ddddd8!important;padding-bottom:0!important}
.sect1{padding-bottom:0!important}
.sect1+.sect1{border:0!important}
#header>h1:first-child{margin-top:1.25rem}
body.book #header{text-align:center}
body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em 0}
body.book #header .details{border:0!important;display:block;padding:0!important}
body.book #header .details span:first-child{margin-left:0!important}
body.book #header .details br{display:block}
body.book #header .details br+span:before{content:none!important}
body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
.listingblock code[data-lang]:before{display:block}
#footer{background:none!important;padding:0 .9375em}
#footer-text{color:rgba(0,0,0,.6)!important;font-size:.9em}
.hide-on-print{display:none!important}
.print-only{display:block!important}
.hide-for-print{display:none!important}
.show-for-print{display:inherit!important}}
</style>
<style>
.listingblock .pygments .hll { background-color: #ffffcc }
.listingblock .pygments { background: #f8f8f8; }
.listingblock .pygments .tok-c { color: #408080; font-style: italic } /* Comment */
.listingblock .pygments .tok-err { border: 1px solid #FF0000 } /* Error */
.listingblock .pygments .tok-k { color: #008000; font-weight: bold } /* Keyword */
.listingblock .pygments .tok-o { color: #666666 } /* Operator */
.listingblock .pygments .tok-ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.listingblock .pygments .tok-cm { color: #408080; font-style: italic } /* Comment.Multiline */
.listingblock .pygments .tok-cp { color: #BC7A00 } /* Comment.Preproc */
.listingblock .pygments .tok-cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.listingblock .pygments .tok-c1 { color: #408080; font-style: italic } /* Comment.Single */
.listingblock .pygments .tok-cs { color: #408080; font-style: italic } /* Comment.Special */
.listingblock .pygments .tok-gd { color: #A00000 } /* Generic.Deleted */
.listingblock .pygments .tok-ge { font-style: italic } /* Generic.Emph */
.listingblock .pygments .tok-gr { color: #FF0000 } /* Generic.Error */
.listingblock .pygments .tok-gh { color: #000080; font-weight: bold } /* Generic.Heading */
.listingblock .pygments .tok-gi { color: #00A000 } /* Generic.Inserted */
.listingblock .pygments .tok-go { color: #888888 } /* Generic.Output */
.listingblock .pygments .tok-gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.listingblock .pygments .tok-gs { font-weight: bold } /* Generic.Strong */
.listingblock .pygments .tok-gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.listingblock .pygments .tok-gt { color: #0044DD } /* Generic.Traceback */
.listingblock .pygments .tok-kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.listingblock .pygments .tok-kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.listingblock .pygments .tok-kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.listingblock .pygments .tok-kp { color: #008000 } /* Keyword.Pseudo */
.listingblock .pygments .tok-kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.listingblock .pygments .tok-kt { color: #B00040 } /* Keyword.Type */
.listingblock .pygments .tok-m { color: #666666 } /* Literal.Number */
.listingblock .pygments .tok-s { color: #BA2121 } /* Literal.String */
.listingblock .pygments .tok-na { color: #7D9029 } /* Name.Attribute */
.listingblock .pygments .tok-nb { color: #008000 } /* Name.Builtin */
.listingblock .pygments .tok-nc { color: #0000FF; font-weight: bold } /* Name.Class */
.listingblock .pygments .tok-no { color: #880000 } /* Name.Constant */
.listingblock .pygments .tok-nd { color: #AA22FF } /* Name.Decorator */
.listingblock .pygments .tok-ni { color: #999999; font-weight: bold } /* Name.Entity */
.listingblock .pygments .tok-ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.listingblock .pygments .tok-nf { color: #0000FF } /* Name.Function */
.listingblock .pygments .tok-nl { color: #A0A000 } /* Name.Label */
.listingblock .pygments .tok-nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.listingblock .pygments .tok-nt { color: #008000; font-weight: bold } /* Name.Tag */
.listingblock .pygments .tok-nv { color: #19177C } /* Name.Variable */
.listingblock .pygments .tok-ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.listingblock .pygments .tok-w { color: #bbbbbb } /* Text.Whitespace */
.listingblock .pygments .tok-mb { color: #666666 } /* Literal.Number.Bin */
.listingblock .pygments .tok-mf { color: #666666 } /* Literal.Number.Float */
.listingblock .pygments .tok-mh { color: #666666 } /* Literal.Number.Hex */
.listingblock .pygments .tok-mi { color: #666666 } /* Literal.Number.Integer */
.listingblock .pygments .tok-mo { color: #666666 } /* Literal.Number.Oct */
.listingblock .pygments .tok-sa { color: #BA2121 } /* Literal.String.Affix */
.listingblock .pygments .tok-sb { color: #BA2121 } /* Literal.String.Backtick */
.listingblock .pygments .tok-sc { color: #BA2121 } /* Literal.String.Char */
.listingblock .pygments .tok-dl { color: #BA2121 } /* Literal.String.Delimiter */
.listingblock .pygments .tok-sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.listingblock .pygments .tok-s2 { color: #BA2121 } /* Literal.String.Double */
.listingblock .pygments .tok-se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.listingblock .pygments .tok-sh { color: #BA2121 } /* Literal.String.Heredoc */
.listingblock .pygments .tok-si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.listingblock .pygments .tok-sx { color: #008000 } /* Literal.String.Other */
.listingblock .pygments .tok-sr { color: #BB6688 } /* Literal.String.Regex */
.listingblock .pygments .tok-s1 { color: #BA2121 } /* Literal.String.Single */
.listingblock .pygments .tok-ss { color: #19177C } /* Literal.String.Symbol */
.listingblock .pygments .tok-bp { color: #008000 } /* Name.Builtin.Pseudo */
.listingblock .pygments .tok-fm { color: #0000FF } /* Name.Function.Magic */
.listingblock .pygments .tok-vc { color: #19177C } /* Name.Variable.Class */
.listingblock .pygments .tok-vg { color: #19177C } /* Name.Variable.Global */
.listingblock .pygments .tok-vi { color: #19177C } /* Name.Variable.Instance */
.listingblock .pygments .tok-vm { color: #19177C } /* Name.Variable.Magic */
.listingblock .pygments .tok-il { color: #666666 } /* Literal.Number.Integer.Long */
</style>
<!--
Custom styles for Asciidoctor
(C) 2016 Sébastien Helleu <flashcode@flashtux.org>
-->
<style>
#header,#content,#footnotes,#footer {
max-width: none;
padding-left: 3em;
padding-right: 3em;
}
#header #revnumber {
text-transform: none;
}
h1,h2,h3,h4,h5 {
font-weight: bold;
}
.literalblock pre {
font-family: monospace, 'Courier New', Courier;
line-height: normal;
font-size: .95em;
}
.keyseq kbd {
font-size: .7em;
}
.tableblock kbd {
font-size: .7438em;
}
.hex {
padding: 0 .2em;
border: 1px solid #88b;
margin: 0 .2em;
font-family: monospace;
}
</style>
</head>
<body class="article toc2 toc-left">
<div id="header">
<h1>WeeChat scripting guide</h1>
<div class="details">
<span id="author" class="author">Sébastien Helleu</span><br>
<span id="email" class="email"><a href="mailto:flashcode@flashtux.org">flashcode@flashtux.org</a></span><br>
<span id="revnumber">version 1.6</span>
</div>
<div id="toc" class="toc2">
<div id="toctitle">Table of Contents</div>
<ul class="sectlevel1">
<li><a href="#introduction">1. Introduction</a></li>
<li><a href="#scripts_in_weechat">2. Scripts in WeeChat</a>
<ul class="sectlevel2">
<li><a href="#languages_specificities">2.1. Languages specificities</a>
<ul class="sectlevel3">
<li><a href="#_python">2.1.1. Python</a></li>
<li><a href="#_perl">2.1.2. Perl</a></li>
<li><a href="#_ruby">2.1.3. Ruby</a></li>
<li><a href="#_lua">2.1.4. Lua</a></li>
<li><a href="#_tcl">2.1.5. Tcl</a></li>
<li><a href="#_guile_scheme">2.1.6. Guile (scheme)</a></li>
<li><a href="#_javascript">2.1.7. Javascript</a></li>
</ul>
</li>
<li><a href="#register_function">2.2. Register function</a></li>
<li><a href="#load_script">2.3. Load script</a></li>
</ul>
</li>
<li><a href="#differences_with_c_api">3. Differences with C API</a>
<ul class="sectlevel2">
<li><a href="#pointers">3.1. Pointers</a></li>
<li><a href="#callbacks">3.2. Callbacks</a></li>
</ul>
</li>
<li><a href="#script_api">4. Script API</a>
<ul class="sectlevel2">
<li><a href="#script_api_functions">4.1. Functions</a></li>
<li><a href="#script_api_constants">4.2. Constants</a></li>
</ul>
</li>
<li><a href="#common_tasks">5. Common tasks</a>
<ul class="sectlevel2">
<li><a href="#buffers">5.1. Buffers</a>
<ul class="sectlevel3">
<li><a href="#buffers_display_messages">5.1.1. Display messages</a></li>
<li><a href="#buffers_send_text">5.1.2. Send text to buffer</a></li>
<li><a href="#buffers_new">5.1.3. Create new buffer</a></li>
<li><a href="#buffers_properties">5.1.4. Buffer properties</a></li>
</ul>
</li>
<li><a href="#hooks">5.2. Hooks</a>
<ul class="sectlevel3">
<li><a href="#hook_command">5.2.1. Add new command</a></li>
<li><a href="#hook_timer">5.2.2. Add a timer</a></li>
<li><a href="#hook_process">5.2.3. Run a background process</a></li>
<li><a href="#url_transfer">5.2.4. URL transfer</a></li>
</ul>
</li>
<li><a href="#config_options">5.3. Config / options</a>
<ul class="sectlevel3">
<li><a href="#config_options_set_script">5.3.1. Set options for script</a></li>
<li><a href="#config_options_detect_changes">5.3.2. Detect changes</a></li>
<li><a href="#config_options_weechat">5.3.3. Read WeeChat options</a></li>
</ul>
</li>
<li><a href="#irc">5.4. IRC</a>
<ul class="sectlevel3">
<li><a href="#irc_catch_messages">5.4.1. Catch messages</a></li>
<li><a href="#irc_modify_messages">5.4.2. Modify messages</a></li>
<li><a href="#irc_message_parse">5.4.3. Parse message</a></li>
</ul>
</li>
<li><a href="#infos">5.5. Infos</a>
<ul class="sectlevel3">
<li><a href="#infos_weechat_version">5.5.1. WeeChat version</a></li>
<li><a href="#infos_other">5.5.2. Other infos</a></li>
</ul>
</li>
<li><a href="#infolists">5.6. Infolists</a>
<ul class="sectlevel3">
<li><a href="#infolists_read">5.6.1. Read an infolist</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>This manual documents WeeChat chat client, it is part of WeeChat.</p>
</div>
<div class="paragraph">
<p>Latest version of this document can be found on this page:
<a href="https://weechat.org/doc" class="bare">https://weechat.org/doc</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="introduction"><a class="anchor" href="#introduction"></a>1. Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>WeeChat (Wee Enhanced Environment for Chat) is a free chat client, fast and
light, designed for many operating systems.</p>
</div>
<div class="paragraph">
<p>This manual documents way to write scripts for WeeChat, using one of supported
script languages:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>python</p>
</li>
<li>
<p>perl</p>
</li>
<li>
<p>ruby</p>
</li>
<li>
<p>lua</p>
</li>
<li>
<p>tcl</p>
</li>
<li>
<p>guile (scheme)</p>
</li>
<li>
<p>javascript</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
Almost all examples in this doc are written in Python, but API is the same for
other languages.
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="scripts_in_weechat"><a class="anchor" href="#scripts_in_weechat"></a>2. Scripts in WeeChat</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="languages_specificities"><a class="anchor" href="#languages_specificities"></a>2.1. Languages specificities</h3>
<div class="sect3">
<h4 id="_python"><a class="anchor" href="#_python"></a>2.1.1. Python</h4>
<div class="ulist">
<ul>
<li>
<p>You have to <code>import weechat</code></p>
</li>
<li>
<p>Functions <code>print*</code> are called <code>prnt*</code> in python (because <em>print</em> is reserved
keyword)</p>
</li>
<li>
<p>Functions are called with <code>weechat.xxx(arg1, arg2, …​)</code></p>
</li>
</ul>
</div>
</div>
<div class="sect3">
<h4 id="_perl"><a class="anchor" href="#_perl"></a>2.1.2. Perl</h4>
<div class="ulist">
<ul>
<li>
<p>Functions are called with <code>weechat::xxx(arg1, arg2, …​);</code></p>
</li>
</ul>
</div>
</div>
<div class="sect3">
<h4 id="_ruby"><a class="anchor" href="#_ruby"></a>2.1.3. Ruby</h4>
<div class="ulist">
<ul>
<li>
<p>You have to define <em>weechat_init</em> and call <em>register</em> inside</p>
</li>
<li>
<p>Functions are called with <code>Weechat.xxx(arg1, arg2, …​)</code></p>
</li>
<li>
<p>Due to a limitation of Ruby (15 arguments max by function), the function
<code>Weechat.config_new_option</code> receives the callbacks in an array of 6 strings
(3 callbacks + 3 data strings), so a call to this function looks like:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="ruby"><span class="tok-no">Weechat</span><span class="tok-o">.</span><span class="tok-n">config_new_option</span><span class="tok-p">(</span><span class="tok-n">config</span><span class="tok-p">,</span> <span class="tok-n">section</span><span class="tok-p">,</span> <span class="tok-s2">"name"</span><span class="tok-p">,</span> <span class="tok-s2">"string"</span><span class="tok-p">,</span> <span class="tok-s2">"description of option"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-mi">0</span><span class="tok-p">,</span> <span class="tok-mi">0</span><span class="tok-p">,</span>
<span class="tok-s2">"value"</span><span class="tok-p">,</span> <span class="tok-s2">"value"</span><span class="tok-p">,</span> <span class="tok-mi">0</span><span class="tok-p">,</span> <span class="tok-o">[</span><span class="tok-s2">"check_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"change_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"delete_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-o">]</span><span class="tok-p">)</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_lua"><a class="anchor" href="#_lua"></a>2.1.4. Lua</h4>
<div class="ulist">
<ul>
<li>
<p>Functions are called with <code>weechat.xxx(arg1, arg2, …​)</code></p>
</li>
</ul>
</div>
</div>
<div class="sect3">
<h4 id="_tcl"><a class="anchor" href="#_tcl"></a>2.1.5. Tcl</h4>
<div class="ulist">
<ul>
<li>
<p>Functions are called with <code>weechat::xxx arg1 arg2 …​</code></p>
</li>
</ul>
</div>
</div>
<div class="sect3">
<h4 id="_guile_scheme"><a class="anchor" href="#_guile_scheme"></a>2.1.6. Guile (scheme)</h4>
<div class="ulist">
<ul>
<li>
<p>Functions are called with <code>(weechat:xxx arg1 arg2 …​)</code></p>
</li>
<li>
<p>Following functions take one list of arguments (instead of many arguments
for other functions), because number of arguments exceed number of allowed
arguments in Guile:</p>
<div class="ulist">
<ul>
<li>
<p>config_new_section</p>
</li>
<li>
<p>config_new_option</p>
</li>
<li>
<p>bar_new</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
<div class="sect3">
<h4 id="_javascript"><a class="anchor" href="#_javascript"></a>2.1.7. Javascript</h4>
<div class="ulist">
<ul>
<li>
<p>Functions are called with <code>weechat.xxx(arg1, arg2, …​);</code></p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect2">
<h3 id="register_function"><a class="anchor" href="#register_function"></a>2.2. Register function</h3>
<div class="paragraph">
<p>All WeeChat scripts must "register" themselves to WeeChat, and this must be
first WeeChat function called in script.</p>
</div>
<div class="paragraph">
<p>Prototype:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">register</span><span class="tok-p">(</span><span class="tok-n">name</span><span class="tok-p">,</span> <span class="tok-n">author</span><span class="tok-p">,</span> <span class="tok-n">version</span><span class="tok-p">,</span> <span class="tok-n">license</span><span class="tok-p">,</span> <span class="tok-n">description</span><span class="tok-p">,</span> <span class="tok-n">shutdown_function</span><span class="tok-p">,</span> <span class="tok-n">charset</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>Arguments:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><em>name</em>: string, internal name of script</p>
</li>
<li>
<p><em>author</em>: string, author name</p>
</li>
<li>
<p><em>version</em>: string, script version</p>
</li>
<li>
<p><em>license</em>: string, script license</p>
</li>
<li>
<p><em>description</em>: string, short description of script</p>
</li>
<li>
<p><em>shutdown_function</em>: string, name of function called when script is unloaded
(can be empty string)</p>
</li>
<li>
<p><em>charset</em>: string, script charset (if your script is UTF-8, you can use blank
value here, because UTF-8 is default charset)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Example of script, for each language:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Python:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-kn">import</span> <span class="tok-nn">weechat</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">register</span><span class="tok-p">(</span><span class="tok-s2">"test_python"</span><span class="tok-p">,</span> <span class="tok-s2">"FlashCode"</span><span class="tok-p">,</span> <span class="tok-s2">"1.0"</span><span class="tok-p">,</span> <span class="tok-s2">"GPL3"</span><span class="tok-p">,</span> <span class="tok-s2">"Test script"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"Hello, from python script!"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Perl:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="perl"><span class="tok-nn">weechat::</span><span class="tok-n">register</span><span class="tok-p">(</span><span class="tok-s">"test_perl"</span><span class="tok-p">,</span> <span class="tok-s">"FlashCode"</span><span class="tok-p">,</span> <span class="tok-s">"1.0"</span><span class="tok-p">,</span> <span class="tok-s">"GPL3"</span><span class="tok-p">,</span> <span class="tok-s">"Test script"</span><span class="tok-p">,</span> <span class="tok-s">""</span><span class="tok-p">,</span> <span class="tok-s">""</span><span class="tok-p">);</span>
<span class="tok-nn">weechat::</span><span class="tok-k">print</span><span class="tok-p">(</span><span class="tok-s">""</span><span class="tok-p">,</span> <span class="tok-s">"Hello, from perl script!"</span><span class="tok-p">);</span></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Ruby:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="ruby"><span class="tok-k">def</span> <span class="tok-nf">weechat_init</span>
<span class="tok-no">Weechat</span><span class="tok-o">.</span><span class="tok-n">register</span><span class="tok-p">(</span><span class="tok-s2">"test_ruby"</span><span class="tok-p">,</span> <span class="tok-s2">"FlashCode"</span><span class="tok-p">,</span> <span class="tok-s2">"1.0"</span><span class="tok-p">,</span> <span class="tok-s2">"GPL3"</span><span class="tok-p">,</span> <span class="tok-s2">"Test script"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span>
<span class="tok-no">Weechat</span><span class="tok-o">.</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"Hello, from ruby script!"</span><span class="tok-p">)</span>
<span class="tok-k">return</span> <span class="tok-no">Weechat</span><span class="tok-o">::</span><span class="tok-no">WEECHAT_RC_OK</span>
<span class="tok-k">end</span></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Lua:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="lua"><span class="tok-n">weechat</span><span class="tok-p">.</span><span class="tok-n">register</span><span class="tok-p">(</span><span class="tok-s2">"test_lua"</span><span class="tok-p">,</span> <span class="tok-s2">"FlashCode"</span><span class="tok-p">,</span> <span class="tok-s2">"1.0"</span><span class="tok-p">,</span> <span class="tok-s2">"GPL3"</span><span class="tok-p">,</span> <span class="tok-s2">"Test script"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span>
<span class="tok-n">weechat</span><span class="tok-p">.</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"Hello, from lua script!"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Tcl:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="tcl"><span class="tok-nv">weechat</span><span class="tok-o">::</span>register <span class="tok-s2">"test_tcl"</span> <span class="tok-s2">"FlashCode"</span> <span class="tok-s2">"1.0"</span> <span class="tok-s2">"GPL3"</span> <span class="tok-s2">"Test script"</span> <span class="tok-s2">""</span> <span class="tok-s2">""</span>
<span class="tok-nv">weechat</span><span class="tok-o">::</span>print <span class="tok-s2">""</span> <span class="tok-s2">"Hello, from tcl script!"</span></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Guile (scheme):</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="lisp"><span class="tok-p">(</span><span class="tok-nv">weechat:register</span> <span class="tok-s">"test_scheme"</span> <span class="tok-s">"FlashCode"</span> <span class="tok-s">"1.0"</span> <span class="tok-s">"GPL3"</span> <span class="tok-s">"Test script"</span> <span class="tok-s">""</span> <span class="tok-s">""</span><span class="tok-p">)</span>
<span class="tok-p">(</span><span class="tok-nv">weechat:print</span> <span class="tok-s">""</span> <span class="tok-s">"Hello, from scheme script!"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Javascript:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="javascript"><span class="tok-nx">weechat</span><span class="tok-p">.</span><span class="tok-nx">register</span><span class="tok-p">(</span><span class="tok-s2">"test_js"</span><span class="tok-p">,</span> <span class="tok-s2">"FlashCode"</span><span class="tok-p">,</span> <span class="tok-s2">"1.0"</span><span class="tok-p">,</span> <span class="tok-s2">"GPL3"</span><span class="tok-p">,</span> <span class="tok-s2">"Test script"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">);</span>
<span class="tok-nx">weechat</span><span class="tok-p">.</span><span class="tok-nx">print</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"Hello, from javascript script!"</span><span class="tok-p">);</span></code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="load_script"><a class="anchor" href="#load_script"></a>2.3. Load script</h3>
<div class="paragraph">
<p>It is recommended to use the "script" plugin to load scripts, for example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>/script load script.py
/script load script.pl
/script load script.rb
/script load script.lua
/script load script.tcl
/script load script.scm
/script load script.js</pre>
</div>
</div>
<div class="paragraph">
<p>Each language has also its own command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>/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</pre>
</div>
</div>
<div class="paragraph">
<p>You can make link in directory <em>language/autoload</em> to autoload script when
WeeChat is starting.</p>
</div>
<div class="paragraph">
<p>For example with Python:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>$ cd ~/.weechat/python/autoload
$ ln -s ../script.py</pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
When installing a script with command <code>/script install</code> the link in <em>autoload</em>
directory is automatically created.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="differences_with_c_api"><a class="anchor" href="#differences_with_c_api"></a>3. Differences with C API</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Script API is almost the same as C plugin API.
You can look at <em>WeeChat Plugin API Reference</em> for detail about each function
in API: prototype, arguments, return values, examples.</p>
</div>
<div class="paragraph">
<p>It’s important to make difference between a <em>plugin</em> and a <em>script</em>: a
<em>plugin</em> is a binary file compiled and loaded with command <code>/plugin</code>, whereas
a <em>script</em> is a text file loaded with a plugin like <em>python</em> with command
<code>/python</code>.</p>
</div>
<div class="paragraph">
<p>When your script <em>test.py</em> calls a WeeChat API function, path is like that:</p>
</div>
<div class="literalblock">
<div class="content">
<pre> ┌──────────────────────┐ ╔══════════════════╗
│ python plugin │ ║ WeeChat "core" ║
├────────────┬─────────┤ ╟─────────┐ ║
test.py ─────► │ script API │ C API │ ─────► ║ C API │ ║
└────────────┴─────────┘ ╚═════════╧════════╝</pre>
</div>
</div>
<div class="paragraph">
<p>When WeeChat calls a callback in your script <em>test.py</em>, it’s reverse of
previous path:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>╔══════════════════╗ ┌──────────────────────┐
║ WeeChat "core" ║ │ python plugin │
║ ┌─────────╢ ├─────────┬────────────┤
║ │ C API ║ ─────► │ C API │ script API │ ─────► test.py
╚════════╧═════════╝ └─────────┴────────────┘</pre>
</div>
</div>
<div class="sect2">
<h3 id="pointers"><a class="anchor" href="#pointers"></a>3.1. Pointers</h3>
<div class="paragraph">
<p>As you probably know, there is not really "pointers" in scripts. So when API
functions return pointer, it is converted to string for script.</p>
</div>
<div class="paragraph">
<p>For example, if function return pointer 0x1234ab56, script will get string
"0x1234ab56".</p>
</div>
<div class="paragraph">
<p>And when an API function expects a pointer in arguments, script must give that
string value. C plugin will convert it to real pointer before calling C API
function.</p>
</div>
<div class="paragraph">
<p>Empty string or "0x0" are allowed, they means NULL in C.
For example, to print data on core buffer (WeeChat main buffer), you can do:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"hi!"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<div class="title">Warning</div>
</td>
<td class="content">
In many functions, for speed reasons, WeeChat does not check if your pointer
is correct or not. It’s your job to check you’re giving a valid pointer,
otherwise you may see a nice crash report ;)
</td>
</tr>
</table>
</div>
</div>
<div class="sect2">
<h3 id="callbacks"><a class="anchor" href="#callbacks"></a>3.2. Callbacks</h3>
<div class="paragraph">
<p>Almost all WeeChat callbacks must return WEECHAT_RC_OK or WEECHAT_RC_ERROR
(exception is modifier callback, which returns a string).</p>
</div>
<div class="paragraph">
<p>C callbacks are using a "data" argument, which is a pointer. In script API,
this "data" is a string with a any value (it’s not a pointer).</p>
</div>
<div class="paragraph">
<p>Example of callback, for each language:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Python:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-k">def</span> <span class="tok-nf">timer_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-n">remaining_calls</span><span class="tok-p">):</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"timer! data=</span><span class="tok-si">%s</span><span class="tok-s2">"</span> <span class="tok-o">%</span> <span class="tok-n">data</span><span class="tok-p">)</span>
<span class="tok-k">return</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">WEECHAT_RC_OK</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">hook_timer</span><span class="tok-p">(</span><span class="tok-mi">1000</span><span class="tok-p">,</span> <span class="tok-mi">0</span><span class="tok-p">,</span> <span class="tok-mi">1</span><span class="tok-p">,</span> <span class="tok-s2">"timer_cb"</span><span class="tok-p">,</span> <span class="tok-s2">"test"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Perl:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="perl"><span class="tok-k">sub</span> <span class="tok-nf">timer_cb</span> <span class="tok-p">{</span>
<span class="tok-k">my</span> <span class="tok-p">(</span><span class="tok-nv">$data</span><span class="tok-p">,</span> <span class="tok-nv">$remaining_calls</span><span class="tok-p">)</span> <span class="tok-o">=</span> <span class="tok-nv">@_</span><span class="tok-p">;</span>
<span class="tok-nn">weechat::</span><span class="tok-k">print</span><span class="tok-p">(</span><span class="tok-s">""</span><span class="tok-p">,</span> <span class="tok-s">"timer! data=$data"</span><span class="tok-p">);</span>
<span class="tok-k">return</span> <span class="tok-nn">weechat::</span><span class="tok-n">WEECHAT_RC_OK</span><span class="tok-p">;</span>
<span class="tok-p">}</span>
<span class="tok-nn">weechat::</span><span class="tok-n">hook_timer</span><span class="tok-p">(</span><span class="tok-mi">1000</span><span class="tok-p">,</span> <span class="tok-mi">0</span><span class="tok-p">,</span> <span class="tok-mi">1</span><span class="tok-p">,</span> <span class="tok-s">"timer_cb"</span><span class="tok-p">,</span> <span class="tok-s">"test"</span><span class="tok-p">);</span></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Ruby:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="ruby"><span class="tok-k">def</span> <span class="tok-nf">timer_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-n">remaining_calls</span><span class="tok-p">)</span>
<span class="tok-no">Weechat</span><span class="tok-o">.</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"timer! data=</span><span class="tok-si">#{</span><span class="tok-n">data</span><span class="tok-si">}</span><span class="tok-s2">"</span><span class="tok-p">);</span>
<span class="tok-k">return</span> <span class="tok-no">Weechat</span><span class="tok-o">::</span><span class="tok-no">WEECHAT_RC_OK</span>
<span class="tok-k">end</span>
<span class="tok-no">Weechat</span><span class="tok-o">.</span><span class="tok-n">hook_timer</span><span class="tok-p">(</span><span class="tok-mi">1000</span><span class="tok-p">,</span> <span class="tok-mi">0</span><span class="tok-p">,</span> <span class="tok-mi">1</span><span class="tok-p">,</span> <span class="tok-s2">"timer_cb"</span><span class="tok-p">,</span> <span class="tok-s2">"test"</span><span class="tok-p">);</span></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Lua:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="lua"><span class="tok-kr">function</span> <span class="tok-nf">timer_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-n">remaining_calls</span><span class="tok-p">)</span>
<span class="tok-n">weechat</span><span class="tok-p">.</span><span class="tok-n">print</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"timer! data="</span><span class="tok-o">..</span><span class="tok-n">data</span><span class="tok-p">)</span>
<span class="tok-kr">return</span> <span class="tok-n">weechat</span><span class="tok-p">.</span><span class="tok-n">WEECHAT_RC_OK</span>
<span class="tok-kr">end</span>
<span class="tok-n">weechat</span><span class="tok-p">.</span><span class="tok-n">hook_timer</span><span class="tok-p">(</span><span class="tok-mi">1000</span><span class="tok-p">,</span> <span class="tok-mi">0</span><span class="tok-p">,</span> <span class="tok-mi">1</span><span class="tok-p">,</span> <span class="tok-s2">"timer_cb"</span><span class="tok-p">,</span> <span class="tok-s2">"test"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Tcl:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="tcl"><span class="tok-k">proc</span> timer_cb <span class="tok-k">{</span> <span class="tok-nv">data</span> remaining_calls <span class="tok-k">}</span> <span class="tok-k">{</span>
<span class="tok-nv">weechat</span><span class="tok-o">::</span>print <span class="tok-k">{}</span> <span class="tok-s2">"timer! data=$data"</span>
<span class="tok-k">return</span> <span class="tok-nv">$::weechat::WEECHAT_RC_OK</span>
<span class="tok-k">}</span>
<span class="tok-nv">weechat</span><span class="tok-o">::</span>hook_timer <span class="tok-mi">1000</span> <span class="tok-mi">0</span> <span class="tok-mi">1</span> timer_cb test</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Guile (scheme):</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="lisp"><span class="tok-p">(</span><span class="tok-nv">define</span> <span class="tok-p">(</span><span class="tok-nv">timer_cb</span> <span class="tok-nv">data</span> <span class="tok-nv">remaining_calls</span><span class="tok-p">)</span>
<span class="tok-p">(</span><span class="tok-nv">weechat:print</span> <span class="tok-s">""</span> <span class="tok-p">(</span><span class="tok-nv">string-append</span> <span class="tok-s">"timer! data="</span> <span class="tok-nv">data</span><span class="tok-p">))</span>
<span class="tok-nv">weechat:WEECHAT_RC_OK</span>
<span class="tok-p">)</span>
<span class="tok-p">(</span><span class="tok-nv">weechat:hook_timer</span> <span class="tok-mi">1000</span> <span class="tok-mi">0</span> <span class="tok-mi">1</span> <span class="tok-s">"timer_cb"</span> <span class="tok-s">"test"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>Javascript:</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="javascript"><span class="tok-kd">function</span> <span class="tok-nx">timer_cb</span><span class="tok-p">(</span><span class="tok-nx">data</span><span class="tok-p">,</span> <span class="tok-nx">remaining_calls</span><span class="tok-p">)</span> <span class="tok-p">{</span>
<span class="tok-nx">weechat</span><span class="tok-p">.</span><span class="tok-nx">print</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"timer! data="</span> <span class="tok-o">+</span> <span class="tok-nx">data</span><span class="tok-p">);</span>
<span class="tok-k">return</span> <span class="tok-nx">weechat</span><span class="tok-p">.</span><span class="tok-nx">WEECHAT_RC_OK</span><span class="tok-p">;</span>
<span class="tok-p">}</span>
<span class="tok-nx">weechat</span><span class="tok-p">.</span><span class="tok-nx">hook_timer</span><span class="tok-p">(</span><span class="tok-mi">1000</span><span class="tok-p">,</span> <span class="tok-mi">0</span><span class="tok-p">,</span> <span class="tok-mi">1</span><span class="tok-p">,</span> <span class="tok-s2">"timer_cb"</span><span class="tok-p">,</span> <span class="tok-s2">"test"</span><span class="tok-p">);</span></code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="script_api"><a class="anchor" href="#script_api"></a>4. Script API</h2>
<div class="sectionbody">
<div class="paragraph">
<p>For more information about functions in API, please read
<em>WeeChat Plugin API Reference</em>.</p>
</div>
<div class="sect2">
<h3 id="script_api_functions"><a class="anchor" href="#script_api_functions"></a>4.1. Functions</h3>
<div class="paragraph">
<p>List of functions in script API:</p>
</div>
<table class="tableblock frame-all grid-all" style="width: 75%;">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Category</th>
<th class="tableblock halign-left valign-top">Functions</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">general</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">register</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">plugins</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">plugin_get_name</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">strings</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">charset_set<br>
iconv_to_internal<br>
iconv_from_internal<br>
gettext<br>
ngettext<br>
strlen_screen<br>
string_match<br>
string_has_highlight<br>
string_has_highlight_regex<br>
string_mask_to_regex<br>
string_remove_color<br>
string_is_command_char<br>
string_input_for_buffer<br>
string_eval_expression<br>
string_eval_path_home</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">directories</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">mkdir_home<br>
mkdir<br>
mkdir_parents</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">sorted lists</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">list_new<br>
list_add<br>
list_search<br>
list_search_pos<br>
list_casesearch<br>
list_casesearch_pos<br>
list_get<br>
list_set<br>
list_next<br>
list_prev<br>
list_string<br>
list_size<br>
list_remove<br>
list_remove_all<br>
list_free</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">configuration files</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">config_new<br>
config_new_section<br>
config_search_section<br>
config_new_option<br>
config_search_option<br>
config_string_to_boolean<br>
config_option_reset<br>
config_option_set<br>
config_option_set_null<br>
config_option_unset<br>
config_option_rename<br>
config_option_is_null<br>
config_option_default_is_null<br>
config_boolean<br>
config_boolean_default<br>
config_integer<br>
config_integer_default<br>
config_string<br>
config_string_default<br>
config_color<br>
config_color_default<br>
config_write_option<br>
config_write_line<br>
config_write<br>
config_read<br>
config_reload<br>
config_option_free<br>
config_section_free_options<br>
config_section_free<br>
config_free<br>
config_get<br>
config_get_plugin<br>
config_is_set_plugin<br>
config_set_plugin<br>
config_set_desc_plugin<br>
config_unset_plugin</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">key bindings</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">key_bind<br>
key_unbind</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">display</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">prefix<br>
color<br>
print (for python: prnt)<br>
print_date_tags (for python:
prnt_date_tags)<br>
print_y (for python: prnt_y)<br>
log_print</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">hooks</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">hook_command<br>
hook_command_run<br>
hook_timer<br>
hook_fd<br>
hook_process<br>
hook_process_hashtable<br>
hook_connect<br>
hook_print<br>
hook_signal<br>
hook_signal_send<br>
hook_hsignal<br>
hook_hsignal_send<br>
hook_config<br>
hook_completion<br>
hook_completion_list_add<br>
hook_modifier<br>
hook_modifier_exec<br>
hook_info<br>
hook_info_hashtable<br>
hook_infolist<br>
hook_focus<br>
hook_set<br>
unhook<br>
unhook_all</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">buffers</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">buffer_new<br>
current_buffer<br>
buffer_search<br>
buffer_search_main<br>
buffer_clear<br>
buffer_close<br>
buffer_merge<br>
buffer_unmerge<br>
buffer_get_integer<br>
buffer_get_string<br>
buffer_get_pointer<br>
buffer_set<br>
buffer_string_replace_local_var<br>
buffer_match_list</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">windows</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">current_window<br>
window_search_with_buffer<br>
window_get_integer<br>
window_get_string<br>
window_get_pointer<br>
window_set_title</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">nicklist</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">nicklist_add_group<br>
nicklist_search_group<br>
nicklist_add_nick<br>
nicklist_search_nick<br>
nicklist_remove_group<br>
nicklist_remove_nick<br>
nicklist_remove_all<br>
nicklist_group_get_integer<br>
nicklist_group_get_string<br>
nicklist_group_get_pointer<br>
nicklist_group_set<br>
nicklist_nick_get_integer<br>
nicklist_nick_get_string<br>
nicklist_nick_get_pointer<br>
nicklist_nick_set</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">bars</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">bar_item_search<br>
bar_item_new<br>
bar_item_update<br>
bar_item_remove<br>
bar_search<br>
bar_new<br>
bar_set<br>
bar_update<br>
bar_remove</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">commands</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">command</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">infos</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">info_get<br>
info_get_hashtable</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">infolists</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">infolist_new<br>
infolist_new_item<br>
infolist_new_var_integer<br>
infolist_new_var_string<br>
infolist_new_var_pointer<br>
infolist_new_var_time<br>
infolist_get<br>
infolist_next<br>
infolist_prev<br>
infolist_reset_item_cursor<br>
infolist_fields<br>
infolist_integer<br>
infolist_string<br>
infolist_pointer<br>
infolist_time<br>
infolist_free</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">hdata</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">hdata_get<br>
hdata_get_var_offset<br>
hdata_get_var_type_string<br>
hdata_get_var_array_size<br>
hdata_get_var_array_size_string<br>
hdata_get_var_hdata<br>
hdata_get_list<br>
hdata_check_pointer<br>
hdata_move<br>
hdata_search<br>
hdata_char<br>
hdata_integer<br>
hdata_long<br>
hdata_string<br>
hdata_pointer<br>
hdata_time<br>
hdata_hashtable<br>
hdata_update<br>
hdata_get_string</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">upgrade</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">upgrade_new<br>
upgrade_write_object<br>
upgrade_read<br>
upgrade_close</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="script_api_constants"><a class="anchor" href="#script_api_constants"></a>4.2. Constants</h3>
<div class="paragraph">
<p>List of constants in script API:</p>
</div>
<table class="tableblock frame-all grid-all" style="width: 75%;">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Category</th>
<th class="tableblock halign-left valign-top">Constants</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">return codes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">WEECHAT_RC_OK<br>
WEECHAT_RC_OK_EAT<br>
WEECHAT_RC_ERROR</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">configuration files</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">WEECHAT_CONFIG_READ_OK<br>
WEECHAT_CONFIG_READ_MEMORY_ERROR<br>
WEECHAT_CONFIG_READ_FILE_NOT_FOUND<br>
WEECHAT_CONFIG_WRITE_OK<br>
WEECHAT_CONFIG_WRITE_ERROR<br>
WEECHAT_CONFIG_WRITE_MEMORY_ERROR<br>
WEECHAT_CONFIG_OPTION_SET_OK_CHANGED<br>
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE<br>
WEECHAT_CONFIG_OPTION_SET_ERROR<br>
WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND<br>
WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET<br>
WEECHAT_CONFIG_OPTION_UNSET_OK_RESET<br>
WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED<br>
WEECHAT_CONFIG_OPTION_UNSET_ERROR</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">sorted lists</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">WEECHAT_LIST_POS_SORT<br>
WEECHAT_LIST_POS_BEGINNING<br>
WEECHAT_LIST_POS_END</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">hotlist</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">WEECHAT_HOTLIST_LOW<br>
WEECHAT_HOTLIST_MESSAGE<br>
WEECHAT_HOTLIST_PRIVATE<br>
WEECHAT_HOTLIST_HIGHLIGHT</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">hook process</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">WEECHAT_HOOK_PROCESS_RUNNING<br>
WEECHAT_HOOK_PROCESS_ERROR</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">hook connect</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">WEECHAT_HOOK_CONNECT_OK<br>
WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND<br>
WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND<br>
WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED<br>
WEECHAT_HOOK_CONNECT_PROXY_ERROR<br>
WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR<br>
WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR<br>
WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR<br>
WEECHAT_HOOK_CONNECT_MEMORY_ERROR<br>
WEECHAT_HOOK_CONNECT_TIMEOUT<br>
WEECHAT_HOOK_CONNECT_SOCKET_ERROR</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">hook signal</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">WEECHAT_HOOK_SIGNAL_STRING<br>
WEECHAT_HOOK_SIGNAL_INT<br>
WEECHAT_HOOK_SIGNAL_POINTER</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="common_tasks"><a class="anchor" href="#common_tasks"></a>5. Common tasks</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This chapter shows some common tasks, with examples.
Only partial things in API are used here, for full reference, see
<em>WeeChat Plugin API Reference</em>.</p>
</div>
<div class="sect2">
<h3 id="buffers"><a class="anchor" href="#buffers"></a>5.1. Buffers</h3>
<div class="sect3">
<h4 id="buffers_display_messages"><a class="anchor" href="#buffers_display_messages"></a>5.1.1. Display messages</h4>
<div class="paragraph">
<p>An empty string is often used to work with WeeChat core buffer. For other
buffers, you must give pointer (as string, see <a href="#pointers">pointers</a>).</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-c1"># display "hello" on core buffer</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"hello"</span><span class="tok-p">)</span>
<span class="tok-c1"># display "hello" on core buffer, but do not write it to log file</span>
<span class="tok-c1"># (version >= 0.3.3 only)</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt_date_tags</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-mi">0</span><span class="tok-p">,</span> <span class="tok-s2">"no_log"</span><span class="tok-p">,</span> <span class="tok-s2">"hello"</span><span class="tok-p">)</span>
<span class="tok-c1"># display prefix "==>" and message "hello" on current buffer</span>
<span class="tok-c1"># (prefix and message must be separated by tab)</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">current_buffer</span><span class="tok-p">(),</span> <span class="tok-s2">"==></span><span class="tok-se">\t</span><span class="tok-s2">hello"</span><span class="tok-p">)</span>
<span class="tok-c1"># display error message on core buffer (with error prefix)</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"</span><span class="tok-si">%s</span><span class="tok-s2">wrong arguments"</span> <span class="tok-o">%</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prefix</span><span class="tok-p">(</span><span class="tok-s2">"error"</span><span class="tok-p">))</span>
<span class="tok-c1"># display message with color on core buffer</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"text </span><span class="tok-si">%s</span><span class="tok-s2">yellow on blue"</span> <span class="tok-o">%</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">color</span><span class="tok-p">(</span><span class="tok-s2">"yellow,blue"</span><span class="tok-p">))</span>
<span class="tok-c1"># search buffer and display message</span>
<span class="tok-c1"># (full name of buffer is plugin.name, for example: "irc.freenode.#weechat")</span>
<span class="tok-nb">buffer</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">buffer_search</span><span class="tok-p">(</span><span class="tok-s2">"irc"</span><span class="tok-p">,</span> <span class="tok-s2">"freenode.#weechat"</span><span class="tok-p">)</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"message on #weechat channel"</span><span class="tok-p">)</span>
<span class="tok-c1"># other solution to find an IRC buffer (better)</span>
<span class="tok-c1"># (note that server and channel are separated by a comma)</span>
<span class="tok-nb">buffer</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">info_get</span><span class="tok-p">(</span><span class="tok-s2">"irc_buffer"</span><span class="tok-p">,</span> <span class="tok-s2">"freenode,#weechat"</span><span class="tok-p">)</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"message on #weechat channel"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
Print function is called <code>print</code> in Perl/Ruby/Lua/Tcl/Guile/Javascript and
<code>prnt</code> in Python.
</td>
</tr>
</table>
</div>
</div>
<div class="sect3">
<h4 id="buffers_send_text"><a class="anchor" href="#buffers_send_text"></a>5.1.2. Send text to buffer</h4>
<div class="paragraph">
<p>You can send text or command to a buffer. This is exactly like if you type text
on command line and press [Enter].</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-c1"># execute command "/help" on current buffer (result is on core buffer)</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">command</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"/help"</span><span class="tok-p">)</span>
<span class="tok-c1"># send "hello" to #weechat IRC channel (users on channel will see message)</span>
<span class="tok-nb">buffer</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">info_get</span><span class="tok-p">(</span><span class="tok-s2">"irc_buffer"</span><span class="tok-p">,</span> <span class="tok-s2">"freenode,#weechat"</span><span class="tok-p">)</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">command</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"hello"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="buffers_new"><a class="anchor" href="#buffers_new"></a>5.1.3. Create new buffer</h4>
<div class="paragraph">
<p>You can create a new buffer in your script, then use it for displaying messages.</p>
</div>
<div class="paragraph">
<p>Two callbacks can be called (they are optional): one for input data (when you
type some text and press [Enter] on buffer), the other is called when buffer is
closed (for example by <code>/buffer close</code>).</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-c1"># callback for data received in input</span>
<span class="tok-k">def</span> <span class="tok-nf">buffer_input_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-n">input_data</span><span class="tok-p">):</span>
<span class="tok-c1"># ...</span>
<span class="tok-k">return</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">WEECHAT_RC_OK</span>
<span class="tok-c1"># callback called when buffer is closed</span>
<span class="tok-k">def</span> <span class="tok-nf">buffer_close_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-nb">buffer</span><span class="tok-p">):</span>
<span class="tok-c1"># ...</span>
<span class="tok-k">return</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">WEECHAT_RC_OK</span>
<span class="tok-c1"># create buffer</span>
<span class="tok-nb">buffer</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">buffer_new</span><span class="tok-p">(</span><span class="tok-s2">"mybuffer"</span><span class="tok-p">,</span> <span class="tok-s2">"buffer_input_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"buffer_close_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span>
<span class="tok-c1"># set title</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">buffer_set</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"title"</span><span class="tok-p">,</span> <span class="tok-s2">"This is title for my buffer."</span><span class="tok-p">)</span>
<span class="tok-c1"># disable logging, by setting local variable "no_log" to "1"</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">buffer_set</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"localvar_set_no_log"</span><span class="tok-p">,</span> <span class="tok-s2">"1"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="buffers_properties"><a class="anchor" href="#buffers_properties"></a>5.1.4. Buffer properties</h4>
<div class="paragraph">
<p>You can read buffer properties, as string, integer or pointer.</p>
</div>
<div class="paragraph">
<p>Examples:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-nb">buffer</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">current_buffer</span><span class="tok-p">()</span>
<span class="tok-n">number</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">buffer_get_integer</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"number"</span><span class="tok-p">)</span>
<span class="tok-n">name</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">buffer_get_string</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"name"</span><span class="tok-p">)</span>
<span class="tok-n">short_name</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">buffer_get_string</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"short_name"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>It is possible to add, read or delete local variables in buffer:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-c1"># add local variable</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">buffer_set</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"localvar_set_myvar"</span><span class="tok-p">,</span> <span class="tok-s2">"my_value"</span><span class="tok-p">)</span>
<span class="tok-c1"># read local variable</span>
<span class="tok-n">myvar</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">buffer_get_string</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"localvar_myvar"</span><span class="tok-p">)</span>
<span class="tok-c1"># delete local variable</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">buffer_set</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"localvar_del_myvar"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>To see local variables of a buffer, do this command in WeeChat:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>/buffer localvar</pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="hooks"><a class="anchor" href="#hooks"></a>5.2. Hooks</h3>
<div class="sect3">
<h4 id="hook_command"><a class="anchor" href="#hook_command"></a>5.2.1. Add new command</h4>
<div class="paragraph">
<p>Add a custom command with <code>hook_command</code>. You can use a custom completion
template to complete arguments of your command.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-k">def</span> <span class="tok-nf">my_command_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-n">args</span><span class="tok-p">):</span>
<span class="tok-c1"># ...</span>
<span class="tok-k">return</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">WEECHAT_RC_OK</span>
<span class="tok-n">hook</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">hook_command</span><span class="tok-p">(</span><span class="tok-s2">"myfilter"</span><span class="tok-p">,</span> <span class="tok-s2">"description of myfilter"</span><span class="tok-p">,</span>
<span class="tok-s2">"[list] | [enable|disable|toggle [name]] | [add name plugin.buffer tags regex] | [del name|-all]"</span><span class="tok-p">,</span>
<span class="tok-s2">"description of arguments..."</span><span class="tok-p">,</span>
<span class="tok-s2">"list"</span>
<span class="tok-s2">" || enable %(filters_names)"</span>
<span class="tok-s2">" || disable %(filters_names)"</span>
<span class="tok-s2">" || toggle %(filters_names)"</span>
<span class="tok-s2">" || add </span><span class="tok-si">%(filters_names) %</span><span class="tok-s2">(buffers_plugins_names)|*"</span>
<span class="tok-s2">" || del %(filters_names)|-all"</span><span class="tok-p">,</span>
<span class="tok-s2">"my_command_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>And then in WeeChat:</p>
</div>
<div class="listingblock">
<div class="content">
<pre>/help myfilter
/myfilter arguments...</pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="hook_timer"><a class="anchor" href="#hook_timer"></a>5.2.2. Add a timer</h4>
<div class="paragraph">
<p>Add a timer with <code>hook_timer</code>.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-k">def</span> <span class="tok-nf">timer_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-n">remaining_calls</span><span class="tok-p">):</span>
<span class="tok-c1"># ...</span>
<span class="tok-k">return</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">WEECHAT_RC_OK</span>
<span class="tok-c1"># timer called each minute when second is 00</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">hook_timer</span><span class="tok-p">(</span><span class="tok-mi">60</span> <span class="tok-o">*</span> <span class="tok-mi">1000</span><span class="tok-p">,</span> <span class="tok-mi">60</span><span class="tok-p">,</span> <span class="tok-mi">0</span><span class="tok-p">,</span> <span class="tok-s2">"timer_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="hook_process"><a class="anchor" href="#hook_process"></a>5.2.3. Run a background process</h4>
<div class="paragraph">
<p>You can run a background process with <code>hook_process</code>. Your callback will be
called when data is ready. It may be called many times.</p>
</div>
<div class="paragraph">
<p>For the last call to your callback, <em>rc</em> is set to 0 or positive value, it’s
return code of command.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-n">process_output</span> <span class="tok-o">=</span> <span class="tok-s2">""</span>
<span class="tok-k">def</span> <span class="tok-nf">my_process_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-n">command</span><span class="tok-p">,</span> <span class="tok-n">rc</span><span class="tok-p">,</span> <span class="tok-n">out</span><span class="tok-p">,</span> <span class="tok-n">err</span><span class="tok-p">):</span>
<span class="tok-k">global</span> <span class="tok-n">process_output</span>
<span class="tok-k">if</span> <span class="tok-n">out</span> <span class="tok-o">!=</span> <span class="tok-s2">""</span><span class="tok-p">:</span>
<span class="tok-n">process_output</span> <span class="tok-o">+=</span> <span class="tok-n">out</span>
<span class="tok-k">if</span> <span class="tok-nb">int</span><span class="tok-p">(</span><span class="tok-n">rc</span><span class="tok-p">)</span> <span class="tok-o">>=</span> <span class="tok-mi">0</span><span class="tok-p">:</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-n">process_output</span><span class="tok-p">)</span>
<span class="tok-k">return</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">WEECHAT_RC_OK</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">hook_process</span><span class="tok-p">(</span><span class="tok-s2">"/bin/ls -l /etc"</span><span class="tok-p">,</span> <span class="tok-mi">10</span> <span class="tok-o">*</span> <span class="tok-mi">1000</span><span class="tok-p">,</span> <span class="tok-s2">"my_process_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="url_transfer"><a class="anchor" href="#url_transfer"></a>5.2.4. URL transfer</h4>
<div class="paragraph">
<p><em>New in version 0.3.7.</em></p>
</div>
<div class="paragraph">
<p>To download URL (or post to URL), you have to use function <code>hook_process</code>, or
<code>hook_process_hashtable</code> if you need to set options for URL transfer.</p>
</div>
<div class="paragraph">
<p>Example of URL transfer without option: the HTML page will be received as "out"
in callback (standard output of process):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-c1"># Display current stable version of WeeChat.</span>
<span class="tok-n">weechat_version</span> <span class="tok-o">=</span> <span class="tok-s2">""</span>
<span class="tok-k">def</span> <span class="tok-nf">weechat_process_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-n">command</span><span class="tok-p">,</span> <span class="tok-n">rc</span><span class="tok-p">,</span> <span class="tok-n">out</span><span class="tok-p">,</span> <span class="tok-n">err</span><span class="tok-p">):</span>
<span class="tok-k">global</span> <span class="tok-n">weechat_version</span>
<span class="tok-k">if</span> <span class="tok-n">out</span> <span class="tok-o">!=</span> <span class="tok-s2">""</span><span class="tok-p">:</span>
<span class="tok-n">weechat_version</span> <span class="tok-o">+=</span> <span class="tok-n">out</span>
<span class="tok-k">if</span> <span class="tok-nb">int</span><span class="tok-p">(</span><span class="tok-n">rc</span><span class="tok-p">)</span> <span class="tok-o">>=</span> <span class="tok-mi">0</span><span class="tok-p">:</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"Current WeeChat stable is: </span><span class="tok-si">%s</span><span class="tok-s2">"</span> <span class="tok-o">%</span> <span class="tok-n">weechat_version</span><span class="tok-p">)</span>
<span class="tok-k">return</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">WEECHAT_RC_OK</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">hook_process</span><span class="tok-p">(</span><span class="tok-s2">"url:https://weechat.org/dev/info/stable/"</span><span class="tok-p">,</span>
<span class="tok-mi">30</span> <span class="tok-o">*</span> <span class="tok-mi">1000</span><span class="tok-p">,</span> <span class="tok-s2">"weechat_process_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<div class="title">Tip</div>
</td>
<td class="content">
All infos available about WeeChat are on page <a href="https://weechat.org/dev/info" class="bare">https://weechat.org/dev/info</a>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Example of URL transfer with an option: download latest WeeChat development
package in file <em>/tmp/weechat-devel.tar.gz</em>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-k">def</span> <span class="tok-nf">my_process_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-n">command</span><span class="tok-p">,</span> <span class="tok-n">rc</span><span class="tok-p">,</span> <span class="tok-n">out</span><span class="tok-p">,</span> <span class="tok-n">err</span><span class="tok-p">):</span>
<span class="tok-k">if</span> <span class="tok-nb">int</span><span class="tok-p">(</span><span class="tok-n">rc</span><span class="tok-p">)</span> <span class="tok-o">>=</span> <span class="tok-mi">0</span><span class="tok-p">:</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"End of transfer (rc=</span><span class="tok-si">%s</span><span class="tok-s2">)"</span> <span class="tok-o">%</span> <span class="tok-n">rc</span><span class="tok-p">)</span>
<span class="tok-k">return</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">WEECHAT_RC_OK</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">hook_process_hashtable</span><span class="tok-p">(</span><span class="tok-s2">"url:https://weechat.org/files/src/weechat-devel.tar.gz"</span><span class="tok-p">,</span>
<span class="tok-p">{</span><span class="tok-s2">"file_out"</span><span class="tok-p">:</span> <span class="tok-s2">"/tmp/weechat-devel.tar.gz"</span><span class="tok-p">},</span>
<span class="tok-mi">30</span> <span class="tok-o">*</span> <span class="tok-mi">1000</span><span class="tok-p">,</span> <span class="tok-s2">"my_process_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="paragraph">
<p>For more information about URL transfer and available options, see functions
<code>hook_process</code> and <code>hook_process_hashtable</code> in <em>WeeChat Plugin API Reference</em>.</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="config_options"><a class="anchor" href="#config_options"></a>5.3. Config / options</h3>
<div class="sect3">
<h4 id="config_options_set_script"><a class="anchor" href="#config_options_set_script"></a>5.3.1. Set options for script</h4>
<div class="paragraph">
<p>Function <code>config_is_set_plugin</code> is used to check if an option is set or not,
and <code>config_set_plugin</code> to set option.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-n">script_options</span> <span class="tok-o">=</span> <span class="tok-p">{</span>
<span class="tok-s2">"option1"</span> <span class="tok-p">:</span> <span class="tok-s2">"value1"</span><span class="tok-p">,</span>
<span class="tok-s2">"option2"</span> <span class="tok-p">:</span> <span class="tok-s2">"value2"</span><span class="tok-p">,</span>
<span class="tok-s2">"option3"</span> <span class="tok-p">:</span> <span class="tok-s2">"value3"</span><span class="tok-p">,</span>
<span class="tok-p">}</span>
<span class="tok-k">for</span> <span class="tok-n">option</span><span class="tok-p">,</span> <span class="tok-n">default_value</span> <span class="tok-ow">in</span> <span class="tok-n">script_options</span><span class="tok-o">.</span><span class="tok-n">items</span><span class="tok-p">():</span>
<span class="tok-k">if</span> <span class="tok-ow">not</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">config_is_set_plugin</span><span class="tok-p">(</span><span class="tok-n">option</span><span class="tok-p">):</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">config_set_plugin</span><span class="tok-p">(</span><span class="tok-n">option</span><span class="tok-p">,</span> <span class="tok-n">default_value</span><span class="tok-p">)</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="config_options_detect_changes"><a class="anchor" href="#config_options_detect_changes"></a>5.3.2. Detect changes</h4>
<div class="paragraph">
<p>You must use <code>hook_config</code> to be notified if user changes some script options.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-n">SCRIPT_NAME</span> <span class="tok-o">=</span> <span class="tok-s2">"myscript"</span>
<span class="tok-c1"># ...</span>
<span class="tok-k">def</span> <span class="tok-nf">config_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-n">option</span><span class="tok-p">,</span> <span class="tok-n">value</span><span class="tok-p">):</span>
<span class="tok-sd">"""Callback called when a script option is changed."""</span>
<span class="tok-c1"># for example, read all script options to script variables...</span>
<span class="tok-c1"># ...</span>
<span class="tok-k">return</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">WEECHAT_RC_OK</span>
<span class="tok-c1"># ...</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">hook_config</span><span class="tok-p">(</span><span class="tok-s2">"plugins.var.python."</span> <span class="tok-o">+</span> <span class="tok-n">SCRIPT_NAME</span> <span class="tok-o">+</span> <span class="tok-s2">".*"</span><span class="tok-p">,</span> <span class="tok-s2">"config_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span>
<span class="tok-c1"># for other languages, change "python" with your language (perl/ruby/lua/tcl/guile/javascript)</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="config_options_weechat"><a class="anchor" href="#config_options_weechat"></a>5.3.3. Read WeeChat options</h4>
<div class="paragraph">
<p>Function <code>config_get</code> returns pointer to option. Then, depending on option type,
you must call <code>config_string</code>, <code>config_boolean</code>, <code>config_integer</code> or
<code>config_color</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-c1"># string</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"value of option weechat.look.item_time_format is: </span><span class="tok-si">%s</span><span class="tok-s2">"</span>
<span class="tok-o">%</span> <span class="tok-p">(</span><span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">config_string</span><span class="tok-p">(</span><span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">config_get</span><span class="tok-p">(</span><span class="tok-s2">"weechat.look.item_time_format"</span><span class="tok-p">))))</span>
<span class="tok-c1"># boolean</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"value of option weechat.look.day_change is: </span><span class="tok-si">%d</span><span class="tok-s2">"</span>
<span class="tok-o">%</span> <span class="tok-p">(</span><span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">config_boolean</span><span class="tok-p">(</span><span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">config_get</span><span class="tok-p">(</span><span class="tok-s2">"weechat.look.day_change"</span><span class="tok-p">))))</span>
<span class="tok-c1"># integer</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"value of option weechat.look.scroll_page_percent is: </span><span class="tok-si">%d</span><span class="tok-s2">"</span>
<span class="tok-o">%</span> <span class="tok-p">(</span><span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">config_integer</span><span class="tok-p">(</span><span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">config_get</span><span class="tok-p">(</span><span class="tok-s2">"weechat.look.scroll_page_percent"</span><span class="tok-p">))))</span>
<span class="tok-c1"># color</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"value of option weechat.color.chat_delimiters is: </span><span class="tok-si">%s</span><span class="tok-s2">"</span>
<span class="tok-o">%</span> <span class="tok-p">(</span><span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">config_color</span><span class="tok-p">(</span><span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">config_get</span><span class="tok-p">(</span><span class="tok-s2">"weechat.color.chat_delimiters"</span><span class="tok-p">))))</span></code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="irc"><a class="anchor" href="#irc"></a>5.4. IRC</h3>
<div class="sect3">
<h4 id="irc_catch_messages"><a class="anchor" href="#irc_catch_messages"></a>5.4.1. Catch messages</h4>
<div class="paragraph">
<p>IRC plugin sends two signals for a message received (<code>xxx</code> is IRC internal
server name, <code>yyy</code> is IRC command name like JOIN, QUIT, PRIVMSG, 301, ..):</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1">xxxx,irc_in_yyy</dt>
<dd>
<p>signal sent before processing message</p>
</dd>
<dt class="hdlist1">xxx,irc_in2_yyy</dt>
<dd>
<p>signal sent after processing message</p>
</dd>
</dl>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-k">def</span> <span class="tok-nf">join_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-n">signal</span><span class="tok-p">,</span> <span class="tok-n">signal_data</span><span class="tok-p">):</span>
<span class="tok-c1"># signal is for example: "freenode,irc_in2_join"</span>
<span class="tok-c1"># signal_data is IRC message, for example: ":nick!user@host JOIN :#channel"</span>
<span class="tok-n">nick</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">info_get</span><span class="tok-p">(</span><span class="tok-s2">"irc_nick_from_host"</span><span class="tok-p">,</span> <span class="tok-n">signal_data</span><span class="tok-p">)</span>
<span class="tok-n">server</span> <span class="tok-o">=</span> <span class="tok-n">signal</span><span class="tok-o">.</span><span class="tok-n">split</span><span class="tok-p">(</span><span class="tok-s2">","</span><span class="tok-p">)[</span><span class="tok-mi">0</span><span class="tok-p">]</span>
<span class="tok-n">channel</span> <span class="tok-o">=</span> <span class="tok-n">signal_data</span><span class="tok-o">.</span><span class="tok-n">split</span><span class="tok-p">(</span><span class="tok-s2">":"</span><span class="tok-p">)[</span><span class="tok-o">-</span><span class="tok-mi">1</span><span class="tok-p">]</span>
<span class="tok-nb">buffer</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">info_get</span><span class="tok-p">(</span><span class="tok-s2">"irc_buffer"</span><span class="tok-p">,</span> <span class="tok-s2">"</span><span class="tok-si">%s</span><span class="tok-s2">,</span><span class="tok-si">%s</span><span class="tok-s2">"</span> <span class="tok-o">%</span> <span class="tok-p">(</span><span class="tok-n">server</span><span class="tok-p">,</span> <span class="tok-n">channel</span><span class="tok-p">))</span>
<span class="tok-k">if</span> <span class="tok-nb">buffer</span><span class="tok-p">:</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-nb">buffer</span><span class="tok-p">,</span> <span class="tok-s2">"Eheh, </span><span class="tok-si">%s</span><span class="tok-s2"> has joined this channel!"</span> <span class="tok-o">%</span> <span class="tok-n">nick</span><span class="tok-p">)</span>
<span class="tok-k">return</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">WEECHAT_RC_OK</span>
<span class="tok-c1"># it is useful here to use "*" as server, to catch JOIN messages on all IRC</span>
<span class="tok-c1"># servers</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">hook_signal</span><span class="tok-p">(</span><span class="tok-s2">"*,irc_in2_join"</span><span class="tok-p">,</span> <span class="tok-s2">"join_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="irc_modify_messages"><a class="anchor" href="#irc_modify_messages"></a>5.4.2. Modify messages</h4>
<div class="paragraph">
<p>IRC plugin sends a "modifier" called "irc_in_xxx" ("xxx" is IRC command) for a
message received, so that you can modify it.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-k">def</span> <span class="tok-nf">modifier_cb</span><span class="tok-p">(</span><span class="tok-n">data</span><span class="tok-p">,</span> <span class="tok-n">modifier</span><span class="tok-p">,</span> <span class="tok-n">modifier_data</span><span class="tok-p">,</span> <span class="tok-n">string</span><span class="tok-p">):</span>
<span class="tok-c1"># add server name to all messages received</span>
<span class="tok-c1"># (OK that's not very useful, but that's just an example!)</span>
<span class="tok-k">return</span> <span class="tok-s2">"</span><span class="tok-si">%s</span><span class="tok-s2"> </span><span class="tok-si">%s</span><span class="tok-s2">"</span> <span class="tok-o">%</span> <span class="tok-p">(</span><span class="tok-n">string</span><span class="tok-p">,</span> <span class="tok-n">modifier_data</span><span class="tok-p">)</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">hook_modifier</span><span class="tok-p">(</span><span class="tok-s2">"irc_in_privmsg"</span><span class="tok-p">,</span> <span class="tok-s2">"modifier_cb"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<div class="title">Warning</div>
</td>
<td class="content">
A malformed message could crash WeeChat or cause severe problems!
</td>
</tr>
</table>
</div>
</div>
<div class="sect3">
<h4 id="irc_message_parse"><a class="anchor" href="#irc_message_parse"></a>5.4.3. Parse message</h4>
<div class="paragraph">
<p><em>New in version 0.3.4.</em></p>
</div>
<div class="paragraph">
<p>You can parse an IRC message with info_hashtable called "irc_message_parse".</p>
</div>
<div class="paragraph">
<p>The result is a hashtable with following keys
(the example values are built with this message:
<code>@time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello!</code>):</p>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: 4.7619%;">
<col style="width: 9.5238%;">
<col style="width: 47.619%;">
<col style="width: 38.0953%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Key</th>
<th class="tableblock halign-center valign-top">WeeChat version</th>
<th class="tableblock halign-left valign-top">Description</th>
<th class="tableblock halign-left valign-top">Example</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">tags</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 0.4.0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The tags in message (can be empty)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>time=2015-06-27T16:40:35.000Z</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">message_without_tags</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 0.4.0</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The message without the tags (the same as message if there are no tags)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>:nick!user@host PRIVMSG #weechat :hello!</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">nick</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 0.3.4</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The origin nick</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>nick</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">host</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 0.3.4</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The origin host (includes the nick)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>nick!user@host</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">command</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 0.3.4</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The command (<em>PRIVMSG</em>, <em>NOTICE</em>, …​)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>PRIVMSG</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">channel</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 0.3.4</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The target channel</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>#weechat</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">arguments</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 0.3.4</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The command arguments (includes the channel)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>#weechat :hello!</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">text</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 1.3</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The text (for example user message)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>hello!</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">pos_command</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 1.3</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The index of <em>command</em> in message ("-1" if <em>command</em> was not found)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>47</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">pos_arguments</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 1.3</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The index of <em>arguments</em> in message ("-1" if <em>arguments</em> was not found)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>55</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">pos_channel</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 1.3</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The index of <em>channel</em> in message ("-1" if <em>channel</em> was not found)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>55</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">pos_text</p></td>
<td class="tableblock halign-center valign-top"><p class="tableblock">≥ 1.3</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The index of <em>text</em> in message ("-1" if <em>text</em> was not found)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>65</code></p></td>
</tr>
</tbody>
</table>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-nb">dict</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">info_get_hashtable</span><span class="tok-p">(</span>
<span class="tok-s2">"irc_message_parse"</span><span class="tok-p">,</span>
<span class="tok-p">{</span><span class="tok-s2">"message"</span><span class="tok-p">:</span> <span class="tok-s2">"@time=2015-06-27T16:40:35.000Z :nick!user@host PRIVMSG #weechat :hello!"</span><span class="tok-p">})</span>
<span class="tok-c1"># dict == {</span>
<span class="tok-c1"># "tags": "time=2015-06-27T16:40:35.000Z",</span>
<span class="tok-c1"># "message_without_tags": ":nick!user@host PRIVMSG #weechat :hello!",</span>
<span class="tok-c1"># "nick": "nick",</span>
<span class="tok-c1"># "host": "nick!user@host",</span>
<span class="tok-c1"># "command": "PRIVMSG",</span>
<span class="tok-c1"># "channel": "#weechat",</span>
<span class="tok-c1"># "arguments": "#weechat :hello!",</span>
<span class="tok-c1"># "text": "hello!",</span>
<span class="tok-c1"># "pos_command": "47",</span>
<span class="tok-c1"># "pos_arguments": "55",</span>
<span class="tok-c1"># "pos_channel": "55",</span>
<span class="tok-c1"># "pos_text": "65",</span>
<span class="tok-c1"># }</span></code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="infos"><a class="anchor" href="#infos"></a>5.5. Infos</h3>
<div class="sect3">
<h4 id="infos_weechat_version"><a class="anchor" href="#infos_weechat_version"></a>5.5.1. WeeChat version</h4>
<div class="paragraph">
<p>The best way to check version is to ask "version_number" and make integer
comparison with hexadecimal version number.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-n">version</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">info_get</span><span class="tok-p">(</span><span class="tok-s2">"version_number"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span> <span class="tok-ow">or</span> <span class="tok-mi">0</span>
<span class="tok-k">if</span> <span class="tok-nb">int</span><span class="tok-p">(</span><span class="tok-n">version</span><span class="tok-p">)</span> <span class="tok-o">>=</span> <span class="tok-mh">0x00030200</span><span class="tok-p">:</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"This is WeeChat 0.3.2 or newer"</span><span class="tok-p">)</span>
<span class="tok-k">else</span><span class="tok-p">:</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"This is WeeChat 0.3.1 or older"</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
Versions ≤ 0.3.1.1 return empty string for <em>info_get("version_number")</em> so you
must check that value returned is <strong>not</strong> empty.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>To get version as string:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-c1"># this will display for example "Version 0.3.2"</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"Version </span><span class="tok-si">%s</span><span class="tok-s2">"</span> <span class="tok-o">%</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">info_get</span><span class="tok-p">(</span><span class="tok-s2">"version"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">))</span></code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="infos_other"><a class="anchor" href="#infos_other"></a>5.5.2. Other infos</h4>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-c1"># WeeChat home directory, for example: "/home/xxxx/.weechat"</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"WeeChat home dir: </span><span class="tok-si">%s</span><span class="tok-s2">"</span> <span class="tok-o">%</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">info_get</span><span class="tok-p">(</span><span class="tok-s2">"weechat_dir"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">))</span>
<span class="tok-c1"># keyboard inactivity</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"Inactivity since </span><span class="tok-si">%s</span><span class="tok-s2"> seconds"</span> <span class="tok-o">%</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">info_get</span><span class="tok-p">(</span><span class="tok-s2">"inactivity"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">))</span></code></pre>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="infolists"><a class="anchor" href="#infolists"></a>5.6. Infolists</h3>
<div class="sect3">
<h4 id="infolists_read"><a class="anchor" href="#infolists_read"></a>5.6.1. Read an infolist</h4>
<div class="paragraph">
<p>You can read infolist built by WeeChat or other plugins.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="python"><span class="tok-c1"># read infolist "buffer", to get list of buffers</span>
<span class="tok-n">infolist</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">infolist_get</span><span class="tok-p">(</span><span class="tok-s2">"buffer"</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">""</span><span class="tok-p">)</span>
<span class="tok-k">if</span> <span class="tok-n">infolist</span><span class="tok-p">:</span>
<span class="tok-k">while</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">infolist_next</span><span class="tok-p">(</span><span class="tok-n">infolist</span><span class="tok-p">):</span>
<span class="tok-n">name</span> <span class="tok-o">=</span> <span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">infolist_string</span><span class="tok-p">(</span><span class="tok-n">infolist</span><span class="tok-p">,</span> <span class="tok-s2">"name"</span><span class="tok-p">)</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">prnt</span><span class="tok-p">(</span><span class="tok-s2">""</span><span class="tok-p">,</span> <span class="tok-s2">"buffer: </span><span class="tok-si">%s</span><span class="tok-s2">"</span> <span class="tok-o">%</span> <span class="tok-n">name</span><span class="tok-p">)</span>
<span class="tok-n">weechat</span><span class="tok-o">.</span><span class="tok-n">infolist_free</span><span class="tok-p">(</span><span class="tok-n">infolist</span><span class="tok-p">)</span></code></pre>
</div>
</div>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<div class="title">Important</div>
</td>
<td class="content">
Don’t forget to call <code>infolist_free</code> to free memory used by infolist, because
WeeChat will not automatically free memory.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<div id="footer-text">
Version 1.6<br>
</div>
</div>
</body>
</html>
|