aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Pipfile13
-rw-r--r--poetry.lock414
-rw-r--r--pyproject.toml42
-rw-r--r--slack.py343
-rw-r--r--tests/__init__.py0
-rw-r--r--tests/conftest.py23
-rw-r--r--tests/test_hook_process_hashtable.py67
-rw-r--r--tests/test_http_request.py136
-rw-r--r--tests/test_sleep.py22
-rw-r--r--tests/test_task_runner.py62
-rw-r--r--typings/slack_api.pyi73
-rw-r--r--typings/weechat.pyi2654
12 files changed, 3836 insertions, 13 deletions
diff --git a/Pipfile b/Pipfile
deleted file mode 100644
index 06def7b..0000000
--- a/Pipfile
+++ /dev/null
@@ -1,13 +0,0 @@
-[[source]]
-name = "pypi"
-url = "https://pypi.org/simple"
-verify_ssl = true
-
-[packages]
-websocket-client = "*"
-
-[dev-packages]
-black = "==23.*"
-mock = "*"
-pytest = "*"
-flake8 = "*"
diff --git a/poetry.lock b/poetry.lock
new file mode 100644
index 0000000..36f2fd4
--- /dev/null
+++ b/poetry.lock
@@ -0,0 +1,414 @@
+# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.
+
+[[package]]
+name = "attrs"
+version = "22.1.0"
+description = "Classes Without Boilerplate"
+optional = false
+python-versions = ">=3.5"
+files = [
+ {file = "attrs-22.1.0-py2.py3-none-any.whl", hash = "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c"},
+ {file = "attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"},
+]
+
+[package.extras]
+dev = ["cloudpickle", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "mypy (>=0.900,!=0.940)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "sphinx", "sphinx-notfound-page", "zope.interface"]
+docs = ["furo", "sphinx", "sphinx-notfound-page", "zope.interface"]
+tests = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "zope.interface"]
+tests-no-zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins"]
+
+[[package]]
+name = "black"
+version = "22.8.0"
+description = "The uncompromising code formatter."
+optional = false
+python-versions = ">=3.6.2"
+files = [
+ {file = "black-22.8.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:ce957f1d6b78a8a231b18e0dd2d94a33d2ba738cd88a7fe64f53f659eea49fdd"},
+ {file = "black-22.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5107ea36b2b61917956d018bd25129baf9ad1125e39324a9b18248d362156a27"},
+ {file = "black-22.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e8166b7bfe5dcb56d325385bd1d1e0f635f24aae14b3ae437102dedc0c186747"},
+ {file = "black-22.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd82842bb272297503cbec1a2600b6bfb338dae017186f8f215c8958f8acf869"},
+ {file = "black-22.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:d839150f61d09e7217f52917259831fe2b689f5c8e5e32611736351b89bb2a90"},
+ {file = "black-22.8.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:a05da0430bd5ced89176db098567973be52ce175a55677436a271102d7eaa3fe"},
+ {file = "black-22.8.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a098a69a02596e1f2a58a2a1c8d5a05d5a74461af552b371e82f9fa4ada8342"},
+ {file = "black-22.8.0-cp36-cp36m-win_amd64.whl", hash = "sha256:5594efbdc35426e35a7defa1ea1a1cb97c7dbd34c0e49af7fb593a36bd45edab"},
+ {file = "black-22.8.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:a983526af1bea1e4cf6768e649990f28ee4f4137266921c2c3cee8116ae42ec3"},
+ {file = "black-22.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b2c25f8dea5e8444bdc6788a2f543e1fb01494e144480bc17f806178378005e"},
+ {file = "black-22.8.0-cp37-cp37m-win_amd64.whl", hash = "sha256:78dd85caaab7c3153054756b9fe8c611efa63d9e7aecfa33e533060cb14b6d16"},
+ {file = "black-22.8.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:cea1b2542d4e2c02c332e83150e41e3ca80dc0fb8de20df3c5e98e242156222c"},
+ {file = "black-22.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5b879eb439094751185d1cfdca43023bc6786bd3c60372462b6f051efa6281a5"},
+ {file = "black-22.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:0a12e4e1353819af41df998b02c6742643cfef58282915f781d0e4dd7a200411"},
+ {file = "black-22.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c3a73f66b6d5ba7288cd5d6dad9b4c9b43f4e8a4b789a94bf5abfb878c663eb3"},
+ {file = "black-22.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:e981e20ec152dfb3e77418fb616077937378b322d7b26aa1ff87717fb18b4875"},
+ {file = "black-22.8.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:8ce13ffed7e66dda0da3e0b2eb1bdfc83f5812f66e09aca2b0978593ed636b6c"},
+ {file = "black-22.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:32a4b17f644fc288c6ee2bafdf5e3b045f4eff84693ac069d87b1a347d861497"},
+ {file = "black-22.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0ad827325a3a634bae88ae7747db1a395d5ee02cf05d9aa7a9bd77dfb10e940c"},
+ {file = "black-22.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:53198e28a1fb865e9fe97f88220da2e44df6da82b18833b588b1883b16bb5d41"},
+ {file = "black-22.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:bc4d4123830a2d190e9cc42a2e43570f82ace35c3aeb26a512a2102bce5af7ec"},
+ {file = "black-22.8.0-py3-none-any.whl", hash = "sha256:d2c21d439b2baf7aa80d6dd4e3659259be64c6f49dfd0f32091063db0e006db4"},
+ {file = "black-22.8.0.tar.gz", hash = "sha256:792f7eb540ba9a17e8656538701d3eb1afcb134e3b45b71f20b25c77a8db7e6e"},
+]
+
+[package.dependencies]
+click = ">=8.0.0"
+mypy-extensions = ">=0.4.3"
+pathspec = ">=0.9.0"
+platformdirs = ">=2"
+tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""}
+typed-ast = {version = ">=1.4.2", markers = "python_version < \"3.8\" and implementation_name == \"cpython\""}
+typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""}
+
+[package.extras]
+colorama = ["colorama (>=0.4.3)"]
+d = ["aiohttp (>=3.7.4)"]
+jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
+uvloop = ["uvloop (>=0.15.2)"]
+
+[[package]]
+name = "click"
+version = "8.1.3"
+description = "Composable command line interface toolkit"
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"},
+ {file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"},
+]
+
+[package.dependencies]
+colorama = {version = "*", markers = "platform_system == \"Windows\""}
+importlib-metadata = {version = "*", markers = "python_version < \"3.8\""}
+
+[[package]]
+name = "colorama"
+version = "0.4.5"
+description = "Cross-platform colored terminal text."
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
+files = [
+ {file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"},
+ {file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"},
+]
+
+[[package]]
+name = "coverage"
+version = "6.5.0"
+description = "Code coverage measurement for Python"
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "coverage-6.5.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ef8674b0ee8cc11e2d574e3e2998aea5df5ab242e012286824ea3c6970580e53"},
+ {file = "coverage-6.5.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:784f53ebc9f3fd0e2a3f6a78b2be1bd1f5575d7863e10c6e12504f240fd06660"},
+ {file = "coverage-6.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b4a5be1748d538a710f87542f22c2cad22f80545a847ad91ce45e77417293eb4"},
+ {file = "coverage-6.5.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:83516205e254a0cb77d2d7bb3632ee019d93d9f4005de31dca0a8c3667d5bc04"},
+ {file = "coverage-6.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:af4fffaffc4067232253715065e30c5a7ec6faac36f8fc8d6f64263b15f74db0"},
+ {file = "coverage-6.5.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:97117225cdd992a9c2a5515db1f66b59db634f59d0679ca1fa3fe8da32749cae"},
+ {file = "coverage-6.5.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:a1170fa54185845505fbfa672f1c1ab175446c887cce8212c44149581cf2d466"},
+ {file = "coverage-6.5.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:11b990d520ea75e7ee8dcab5bc908072aaada194a794db9f6d7d5cfd19661e5a"},
+ {file = "coverage-6.5.0-cp310-cp310-win32.whl", hash = "sha256:5dbec3b9095749390c09ab7c89d314727f18800060d8d24e87f01fb9cfb40b32"},
+ {file = "coverage-6.5.0-cp310-cp310-win_amd64.whl", hash = "sha256:59f53f1dc5b656cafb1badd0feb428c1e7bc19b867479ff72f7a9dd9b479f10e"},
+ {file = "coverage-6.5.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4a5375e28c5191ac38cca59b38edd33ef4cc914732c916f2929029b4bfb50795"},
+ {file = "coverage-6.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c4ed2820d919351f4167e52425e096af41bfabacb1857186c1ea32ff9983ed75"},
+ {file = "coverage-6.5.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:33a7da4376d5977fbf0a8ed91c4dffaaa8dbf0ddbf4c8eea500a2486d8bc4d7b"},
+ {file = "coverage-6.5.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a8fb6cf131ac4070c9c5a3e21de0f7dc5a0fbe8bc77c9456ced896c12fcdad91"},
+ {file = "coverage-6.5.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:a6b7d95969b8845250586f269e81e5dfdd8ff828ddeb8567a4a2eaa7313460c4"},
+ {file = "coverage-6.5.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:1ef221513e6f68b69ee9e159506d583d31aa3567e0ae84eaad9d6ec1107dddaa"},
+ {file = "coverage-6.5.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:cca4435eebea7962a52bdb216dec27215d0df64cf27fc1dd538415f5d2b9da6b"},
+ {file = "coverage-6.5.0-cp311-cp311-win32.whl", hash = "sha256:98e8a10b7a314f454d9eff4216a9a94d143a7ee65018dd12442e898ee2310578"},
+ {file = "coverage-6.5.0-cp311-cp311-win_amd64.whl", hash = "sha256:bc8ef5e043a2af066fa8cbfc6e708d58017024dc4345a1f9757b329a249f041b"},
+ {file = "coverage-6.5.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:4433b90fae13f86fafff0b326453dd42fc9a639a0d9e4eec4d366436d1a41b6d"},
+ {file = "coverage-6.5.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f4f05d88d9a80ad3cac6244d36dd89a3c00abc16371769f1340101d3cb899fc3"},
+ {file = "coverage-6.5.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:94e2565443291bd778421856bc975d351738963071e9b8839ca1fc08b42d4bef"},
+ {file = "coverage-6.5.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:027018943386e7b942fa832372ebc120155fd970837489896099f5cfa2890f79"},
+ {file = "coverage-6.5.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:255758a1e3b61db372ec2736c8e2a1fdfaf563977eedbdf131de003ca5779b7d"},
+ {file = "coverage-6.5.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:851cf4ff24062c6aec510a454b2584f6e998cada52d4cb58c5e233d07172e50c"},
+ {file = "coverage-6.5.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:12adf310e4aafddc58afdb04d686795f33f4d7a6fa67a7a9d4ce7d6ae24d949f"},
+ {file = "coverage-6.5.0-cp37-cp37m-win32.whl", hash = "sha256:b5604380f3415ba69de87a289a2b56687faa4fe04dbee0754bfcae433489316b"},
+ {file = "coverage-6.5.0-cp37-cp37m-win_amd64.whl", hash = "sha256:4a8dbc1f0fbb2ae3de73eb0bdbb914180c7abfbf258e90b311dcd4f585d44bd2"},
+ {file = "coverage-6.5.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d900bb429fdfd7f511f868cedd03a6bbb142f3f9118c09b99ef8dc9bf9643c3c"},
+ {file = "coverage-6.5.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:2198ea6fc548de52adc826f62cb18554caedfb1d26548c1b7c88d8f7faa8f6ba"},
+ {file = "coverage-6.5.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6c4459b3de97b75e3bd6b7d4b7f0db13f17f504f3d13e2a7c623786289dd670e"},
+ {file = "coverage-6.5.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:20c8ac5386253717e5ccc827caad43ed66fea0efe255727b1053a8154d952398"},
+ {file = "coverage-6.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6b07130585d54fe8dff3d97b93b0e20290de974dc8177c320aeaf23459219c0b"},
+ {file = "coverage-6.5.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:dbdb91cd8c048c2b09eb17713b0c12a54fbd587d79adcebad543bc0cd9a3410b"},
+ {file = "coverage-6.5.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:de3001a203182842a4630e7b8d1a2c7c07ec1b45d3084a83d5d227a3806f530f"},
+ {file = "coverage-6.5.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:e07f4a4a9b41583d6eabec04f8b68076ab3cd44c20bd29332c6572dda36f372e"},
+ {file = "coverage-6.5.0-cp38-cp38-win32.whl", hash = "sha256:6d4817234349a80dbf03640cec6109cd90cba068330703fa65ddf56b60223a6d"},
+ {file = "coverage-6.5.0-cp38-cp38-win_amd64.whl", hash = "sha256:7ccf362abd726b0410bf8911c31fbf97f09f8f1061f8c1cf03dfc4b6372848f6"},
+ {file = "coverage-6.5.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:633713d70ad6bfc49b34ead4060531658dc6dfc9b3eb7d8a716d5873377ab745"},
+ {file = "coverage-6.5.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:95203854f974e07af96358c0b261f1048d8e1083f2de9b1c565e1be4a3a48cfc"},
+ {file = "coverage-6.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b9023e237f4c02ff739581ef35969c3739445fb059b060ca51771e69101efffe"},
+ {file = "coverage-6.5.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:265de0fa6778d07de30bcf4d9dc471c3dc4314a23a3c6603d356a3c9abc2dfcf"},
+ {file = "coverage-6.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f830ed581b45b82451a40faabb89c84e1a998124ee4212d440e9c6cf70083e5"},
+ {file = "coverage-6.5.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:7b6be138d61e458e18d8e6ddcddd36dd96215edfe5f1168de0b1b32635839b62"},
+ {file = "coverage-6.5.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:42eafe6778551cf006a7c43153af1211c3aaab658d4d66fa5fcc021613d02518"},
+ {file = "coverage-6.5.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:723e8130d4ecc8f56e9a611e73b31219595baa3bb252d539206f7bbbab6ffc1f"},
+ {file = "coverage-6.5.0-cp39-cp39-win32.whl", hash = "sha256:d9ecf0829c6a62b9b573c7bb6d4dcd6ba8b6f80be9ba4fc7ed50bf4ac9aecd72"},
+ {file = "coverage-6.5.0-cp39-cp39-win_amd64.whl", hash = "sha256:fc2af30ed0d5ae0b1abdb4ebdce598eafd5b35397d4d75deb341a614d333d987"},
+ {file = "coverage-6.5.0-pp36.pp37.pp38-none-any.whl", hash = "sha256:1431986dac3923c5945271f169f59c45b8802a114c8f548d611f2015133df77a"},
+ {file = "coverage-6.5.0.tar.gz", hash = "sha256:f642e90754ee3e06b0e7e51bce3379590e76b7f76b708e1a71ff043f87025c84"},
+]
+
+[package.dependencies]
+tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.11.0a6\" and extra == \"toml\""}
+
+[package.extras]
+toml = ["tomli"]
+
+[[package]]
+name = "importlib-metadata"
+version = "5.0.0"
+description = "Read metadata from Python packages"
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "importlib_metadata-5.0.0-py3-none-any.whl", hash = "sha256:ddb0e35065e8938f867ed4928d0ae5bf2a53b7773871bfe6bcc7e4fcdc7dea43"},
+ {file = "importlib_metadata-5.0.0.tar.gz", hash = "sha256:da31db32b304314d044d3c12c79bd59e307889b287ad12ff387b3500835fc2ab"},
+]
+
+[package.dependencies]
+typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""}
+zipp = ">=0.5"
+
+[package.extras]
+docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)"]
+perf = ["ipython"]
+testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)"]
+
+[[package]]
+name = "iniconfig"
+version = "1.1.1"
+description = "iniconfig: brain-dead simple config-ini parsing"
+optional = false
+python-versions = "*"
+files = [
+ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
+ {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
+]
+
+[[package]]
+name = "mypy-extensions"
+version = "0.4.3"
+description = "Experimental type system extensions for programs checked with the mypy typechecker."
+optional = false
+python-versions = "*"
+files = [
+ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"},
+ {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"},
+]
+
+[[package]]
+name = "packaging"
+version = "21.3"
+description = "Core utilities for Python packages"
+optional = false
+python-versions = ">=3.6"
+files = [
+ {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
+ {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
+]
+
+[package.dependencies]
+pyparsing = ">=2.0.2,<3.0.5 || >3.0.5"
+
+[[package]]
+name = "pathspec"
+version = "0.10.1"
+description = "Utility library for gitignore style pattern matching of file paths."
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "pathspec-0.10.1-py3-none-any.whl", hash = "sha256:46846318467efc4556ccfd27816e004270a9eeeeb4d062ce5e6fc7a87c573f93"},
+ {file = "pathspec-0.10.1.tar.gz", hash = "sha256:7ace6161b621d31e7902eb6b5ae148d12cfd23f4a249b9ffb6b9fee12084323d"},
+]
+
+[[package]]
+name = "platformdirs"
+version = "2.5.2"
+description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "platformdirs-2.5.2-py3-none-any.whl", hash = "sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788"},
+ {file = "platformdirs-2.5.2.tar.gz", hash = "sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"},
+]
+
+[package.extras]
+docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx (>=4)", "sphinx-autodoc-typehints (>=1.12)"]
+test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)"]
+
+[[package]]
+name = "pluggy"
+version = "1.0.0"
+description = "plugin and hook calling mechanisms for python"
+optional = false
+python-versions = ">=3.6"
+files = [
+ {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
+ {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
+]
+
+[package.dependencies]
+importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
+
+[package.extras]
+dev = ["pre-commit", "tox"]
+testing = ["pytest", "pytest-benchmark"]
+
+[[package]]
+name = "py"
+version = "1.11.0"
+description = "library with cross-python path, ini-parsing, io, code, log facilities"
+optional = false
+python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
+files = [
+ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"},
+ {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},
+]
+
+[[package]]
+name = "pyparsing"
+version = "3.0.9"
+description = "pyparsing module - Classes and methods to define and execute parsing grammars"
+optional = false
+python-versions = ">=3.6.8"
+files = [
+ {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
+ {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"},
+]
+
+[package.extras]
+diagrams = ["jinja2", "railroad-diagrams"]
+
+[[package]]
+name = "pytest"
+version = "7.1.3"
+description = "pytest: simple powerful testing with Python"
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "pytest-7.1.3-py3-none-any.whl", hash = "sha256:1377bda3466d70b55e3f5cecfa55bb7cfcf219c7964629b967c37cf0bda818b7"},
+ {file = "pytest-7.1.3.tar.gz", hash = "sha256:4f365fec2dff9c1162f834d9f18af1ba13062db0c708bf7b946f8a5c76180c39"},
+]
+
+[package.dependencies]
+attrs = ">=19.2.0"
+colorama = {version = "*", markers = "sys_platform == \"win32\""}
+importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
+iniconfig = "*"
+packaging = "*"
+pluggy = ">=0.12,<2.0"
+py = ">=1.8.2"
+tomli = ">=1.0.0"
+
+[package.extras]
+testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
+
+[[package]]
+name = "pytest-cov"
+version = "4.0.0"
+description = "Pytest plugin for measuring coverage."
+optional = false
+python-versions = ">=3.6"
+files = [
+ {file = "pytest-cov-4.0.0.tar.gz", hash = "sha256:996b79efde6433cdbd0088872dbc5fb3ed7fe1578b68cdbba634f14bb8dd0470"},
+ {file = "pytest_cov-4.0.0-py3-none-any.whl", hash = "sha256:2feb1b751d66a8bd934e5edfa2e961d11309dc37b73b0eabe73b5945fee20f6b"},
+]
+
+[package.dependencies]
+coverage = {version = ">=5.2.1", extras = ["toml"]}
+pytest = ">=4.6"
+
+[package.extras]
+testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"]
+
+[[package]]
+name = "tomli"
+version = "2.0.1"
+description = "A lil' TOML parser"
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
+ {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
+]
+
+[[package]]
+name = "typed-ast"
+version = "1.5.4"
+description = "a fork of Python 2 and 3 ast modules with type comment support"
+optional = false
+python-versions = ">=3.6"
+files = [
+ {file = "typed_ast-1.5.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:669dd0c4167f6f2cd9f57041e03c3c2ebf9063d0757dc89f79ba1daa2bfca9d4"},
+ {file = "typed_ast-1.5.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:211260621ab1cd7324e0798d6be953d00b74e0428382991adfddb352252f1d62"},
+ {file = "typed_ast-1.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:267e3f78697a6c00c689c03db4876dd1efdfea2f251a5ad6555e82a26847b4ac"},
+ {file = "typed_ast-1.5.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:c542eeda69212fa10a7ada75e668876fdec5f856cd3d06829e6aa64ad17c8dfe"},
+ {file = "typed_ast-1.5.4-cp310-cp310-win_amd64.whl", hash = "sha256:a9916d2bb8865f973824fb47436fa45e1ebf2efd920f2b9f99342cb7fab93f72"},
+ {file = "typed_ast-1.5.4-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:79b1e0869db7c830ba6a981d58711c88b6677506e648496b1f64ac7d15633aec"},
+ {file = "typed_ast-1.5.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a94d55d142c9265f4ea46fab70977a1944ecae359ae867397757d836ea5a3f47"},
+ {file = "typed_ast-1.5.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:183afdf0ec5b1b211724dfef3d2cad2d767cbefac291f24d69b00546c1837fb6"},
+ {file = "typed_ast-1.5.4-cp36-cp36m-win_amd64.whl", hash = "sha256:639c5f0b21776605dd6c9dbe592d5228f021404dafd377e2b7ac046b0349b1a1"},
+ {file = "typed_ast-1.5.4-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:cf4afcfac006ece570e32d6fa90ab74a17245b83dfd6655a6f68568098345ff6"},
+ {file = "typed_ast-1.5.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ed855bbe3eb3715fca349c80174cfcfd699c2f9de574d40527b8429acae23a66"},
+ {file = "typed_ast-1.5.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6778e1b2f81dfc7bc58e4b259363b83d2e509a65198e85d5700dfae4c6c8ff1c"},
+ {file = "typed_ast-1.5.4-cp37-cp37m-win_amd64.whl", hash = "sha256:0261195c2062caf107831e92a76764c81227dae162c4f75192c0d489faf751a2"},
+ {file = "typed_ast-1.5.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:2efae9db7a8c05ad5547d522e7dbe62c83d838d3906a3716d1478b6c1d61388d"},
+ {file = "typed_ast-1.5.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7d5d014b7daa8b0bf2eaef684295acae12b036d79f54178b92a2b6a56f92278f"},
+ {file = "typed_ast-1.5.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:370788a63915e82fd6f212865a596a0fefcbb7d408bbbb13dea723d971ed8bdc"},
+ {file = "typed_ast-1.5.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:4e964b4ff86550a7a7d56345c7864b18f403f5bd7380edf44a3c1fb4ee7ac6c6"},
+ {file = "typed_ast-1.5.4-cp38-cp38-win_amd64.whl", hash = "sha256:683407d92dc953c8a7347119596f0b0e6c55eb98ebebd9b23437501b28dcbb8e"},
+ {file = "typed_ast-1.5.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4879da6c9b73443f97e731b617184a596ac1235fe91f98d279a7af36c796da35"},
+ {file = "typed_ast-1.5.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3e123d878ba170397916557d31c8f589951e353cc95fb7f24f6bb69adc1a8a97"},
+ {file = "typed_ast-1.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ebd9d7f80ccf7a82ac5f88c521115cc55d84e35bf8b446fcd7836eb6b98929a3"},
+ {file = "typed_ast-1.5.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98f80dee3c03455e92796b58b98ff6ca0b2a6f652120c263efdba4d6c5e58f72"},
+ {file = "typed_ast-1.5.4-cp39-cp39-win_amd64.whl", hash = "sha256:0fdbcf2fef0ca421a3f5912555804296f0b0960f0418c440f5d6d3abb549f3e1"},
+ {file = "typed_ast-1.5.4.tar.gz", hash = "sha256:39e21ceb7388e4bb37f4c679d72707ed46c2fbf2a5609b8b8ebc4b067d977df2"},
+]
+
+[[package]]
+name = "typing-extensions"
+version = "4.3.0"
+description = "Backported and Experimental Type Hints for Python 3.7+"
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "typing_extensions-4.3.0-py3-none-any.whl", hash = "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02"},
+ {file = "typing_extensions-4.3.0.tar.gz", hash = "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"},
+]
+
+[[package]]
+name = "websocket-client"
+version = "1.4.1"
+description = "WebSocket client for Python with low level API options"
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "websocket-client-1.4.1.tar.gz", hash = "sha256:f9611eb65c8241a67fb373bef040b3cf8ad377a9f6546a12b620b6511e8ea9ef"},
+ {file = "websocket_client-1.4.1-py3-none-any.whl", hash = "sha256:398909eb7e261f44b8f4bd474785b6ec5f5b499d4953342fe9755e01ef624090"},
+]
+
+[package.extras]
+docs = ["Sphinx (>=3.4)", "sphinx-rtd-theme (>=0.5)"]
+optional = ["python-socks", "wsaccel"]
+test = ["websockets"]
+
+[[package]]
+name = "zipp"
+version = "3.8.1"
+description = "Backport of pathlib-compatible object wrapper for zip files"
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "zipp-3.8.1-py3-none-any.whl", hash = "sha256:47c40d7fe183a6f21403a199b3e4192cca5774656965b0a4988ad2f8feb5f009"},
+ {file = "zipp-3.8.1.tar.gz", hash = "sha256:05b45f1ee8f807d0cc928485ca40a07cb491cf092ff587c0df9cb1fd154848d2"},
+]
+
+[package.extras]
+docs = ["jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx"]
+testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"]
+
+[metadata]
+lock-version = "2.0"
+python-versions = "^3.7"
+content-hash = "0577c19d3a21a882ceb59849ddd930e274cc9ae2ad7d968dea2857e680b71ecf"
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..151d4fa
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,42 @@
+[tool.black]
+extend-exclude = '^/typings/weechat.pyi'
+
+[tool.poetry]
+name = "wee-slack"
+version = "3.0.0"
+description = ""
+license = "MIT"
+authors = ["Trygve Aaberge <trygveaa@gmail.com>"]
+readme = "README.md"
+repository = "https://github.com/wee-slack/wee-slack"
+# packages = [{include = "wee_slack"}]
+# packages = [{ include = "." }]
+
+[tool.poetry.dependencies]
+python = "^3.7"
+websocket-client = ">= 0.37.0"
+
+[tool.poetry.group.dev.dependencies]
+black = "^22.8.0"
+pytest = "^7.1.3"
+pytest-cov = "^4.0.0"
+
+[tool.pylint.main]
+ignored-modules = ["weechat"]
+
+[tool.pylint."messages control"]
+disable = [
+ "missing-class-docstring",
+ "missing-function-docstring",
+ "missing-module-docstring",
+ "no-member",
+]
+
+[tool.pyright]
+strict = ["**"]
+reportMissingModuleSource = false
+
+
+[build-system]
+requires = ["poetry-core"]
+build-backend = "poetry.core.masonry.api"
diff --git a/slack.py b/slack.py
new file mode 100644
index 0000000..4e92ca2
--- /dev/null
+++ b/slack.py
@@ -0,0 +1,343 @@
+from __future__ import annotations
+from enum import IntEnum
+from io import StringIO
+import json
+import os
+import resource
+from typing import (
+ Any,
+ Dict,
+ Generator,
+ Generic,
+ NamedTuple,
+ TYPE_CHECKING,
+ Tuple,
+ TypeVar,
+ Union,
+)
+from typing import Coroutine
+from urllib.parse import urlencode
+from uuid import uuid4
+
+import weechat
+
+
+if TYPE_CHECKING:
+ from slack_api import (
+ SlackConversation,
+ SlackConversationNotIm,
+ SlackConversationIm,
+ )
+else:
+ # To support running without slack types
+ SlackConversation = Any
+ SlackConversationNotIm = Any
+ SlackConversationIm = Any
+
+SCRIPT_NAME = "slack"
+SCRIPT_AUTHOR = "Trygve Aaberge <trygveaa@gmail.com>"
+SCRIPT_VERSION = "3.0.0"
+SCRIPT_LICENSE = "MIT"
+SCRIPT_DESC = "Extends weechat for typing notification/search/etc on slack.com"
+REPO_URL = "https://github.com/wee-slack/wee-slack"
+
+### Basic classes
+
+T = TypeVar("T")
+
+
+class LogLevel(IntEnum):
+ TRACE = 1
+ DEBUG = 2
+ INFO = 3
+ WARN = 4
+ ERROR = 5
+ FATAL = 6
+
+
+class HttpError(Exception):
+ def __init__(self, url: str, return_code: int, http_status: int, error: str):
+ super().__init__()
+ self.url = url
+ self.return_code = return_code
+ self.http_status = http_status
+ self.error = error
+
+
+class Future(Generic[T]):
+ def __init__(self):
+ self.id = str(uuid4())
+
+ def __await__(self) -> Generator[Future[T], T, T]:
+ return (yield self)
+
+
+class FutureProcess(Future[Tuple[str, int, str, str]]):
+ pass
+
+
+class FutureTimer(Future[Tuple[int]]):
+ pass
+
+
+class Task(Future[T]):
+ def __init__(self, coroutine: Coroutine[Future[Any], Any, T], final: bool):
+ super().__init__()
+ self.coroutine = coroutine
+ self.final = final
+
+
+### Helpers
+
+
+def log(level: LogLevel, message: str):
+ if level >= LogLevel.INFO:
+ print(level, message)
+
+
+def available_file_descriptors():
+ num_current_file_descriptors = len(os.listdir("/proc/self/fd/"))
+ max_file_descriptors = min(resource.getrlimit(resource.RLIMIT_NOFILE))
+ return max_file_descriptors - num_current_file_descriptors
+
+
+### WeeChat callbacks
+
+active_tasks: Dict[str, Task[Any]] = {}
+active_responses: Dict[str, Tuple[Any, ...]] = {}
+
+
+def shutdown_cb():
+ return weechat.WEECHAT_RC_OK
+
+
+def weechat_task_cb(data: str, *args: Any) -> int:
+ task = active_tasks.pop(data)
+ task_runner(task, args)
+ return weechat.WEECHAT_RC_OK
+
+
+### WeeChat helpers
+
+
+def task_runner(task: Task[Any], response: Any):
+ while True:
+ try:
+ future = task.coroutine.send(response)
+ if future.id in active_responses:
+ response = active_responses.pop(future.id)
+ else:
+ if future.id in active_tasks:
+ raise Exception(
+ f"future.id in active_tasks, {future.id}, {active_tasks}"
+ )
+ active_tasks[future.id] = task
+ break
+ except StopIteration as e:
+ if task.id in active_tasks:
+ task = active_tasks.pop(task.id)
+ response = e.value
+ else:
+ if task.id in active_responses:
+ raise Exception(
+ f"task.id in active_responses, {task.id}, {active_responses}"
+ )
+ if not task.final:
+ active_responses[task.id] = e.value
+ break
+
+
+def create_task(
+ coroutine: Coroutine[Future[Any], Any, T], final: bool = False
+) -> Task[T]:
+ task = Task(coroutine, final)
+ task_runner(task, None)
+ return task
+
+
+async def sleep(milliseconds: int):
+ future = FutureTimer()
+ weechat.hook_timer(milliseconds, 0, 1, weechat_task_cb.__name__, future.id)
+ return await future
+
+
+async def hook_process_hashtable(command: str, options: Dict[str, str], timeout: int):
+ future = FutureProcess()
+ log(
+ LogLevel.DEBUG,
+ f"hook_process_hashtable calling ({future.id}): command: {command}",
+ )
+ while available_file_descriptors() < 10:
+ await sleep(10)
+ weechat.hook_process_hashtable(
+ command, options, timeout, weechat_task_cb.__name__, future.id
+ )
+
+ stdout = StringIO()
+ stderr = StringIO()
+ return_code = -1
+
+ while return_code == -1:
+ _, return_code, out, err = await future
+ log(
+ LogLevel.TRACE,
+ f"hook_process_hashtable intermediary response ({future.id}): command: {command}",
+ )
+ stdout.write(out)
+ stderr.write(err)
+
+ out = stdout.getvalue()
+ err = stderr.getvalue()
+ log(
+ LogLevel.DEBUG,
+ f"hook_process_hashtable response ({future.id}): command: {command}, "
+ f"return_code: {return_code}, response length: {len(out)}"
+ + (f", error: {err}" if err else ""),
+ )
+
+ return command, return_code, out, err
+
+
+async def http_request(
+ url: str, options: Dict[str, str], timeout: int, max_retries: int = 5
+) -> str:
+ options["header"] = "1"
+ _, return_code, out, err = await hook_process_hashtable(
+ f"url:{url}", options, timeout
+ )
+
+ if return_code != 0 or err:
+ if max_retries > 0:
+ log(
+ LogLevel.INFO,
+ f"HTTP error, retrying (max {max_retries} times): "
+ f"return_code: {return_code}, error: {err}, url: {url}",
+ )
+ await sleep(1000)
+ return await http_request(url, options, timeout, max_retries - 1)
+ raise HttpError(url, return_code, 0, err)
+
+ headers_end_index = out.index("\r\n\r\n")
+ headers = out[:headers_end_index].split("\r\n")
+ http_status = int(headers[0].split(" ")[1])
+
+ if http_status == 429:
+ for header in headers[1:]:
+ name, value = header.split(":", 1)
+ if name.lower() == "retry-after":
+ retry_after = int(value.strip())
+ log(
+ LogLevel.INFO,
+ f"HTTP ratelimit, retrying in {retry_after} seconds, url: {url}",
+ )
+ await sleep(retry_after * 1000)
+ return await http_request(url, options, timeout)
+
+ body = out[headers_end_index + 4 :]
+
+ if http_status >= 400:
+ raise HttpError(url, return_code, http_status, body)
+
+ return body
+
+
+### Slack Classes
+
+
+class SlackConfig:
+ def __init__(self):
+ self.slack_timeout = 30000
+
+
+class SlackToken(NamedTuple):
+ token: str
+ cookie: Union[str, None] = None
+
+
+class SlackApi:
+ def __init__(self, token: SlackToken):
+ self.token = token
+
+ def get_request_options(self):
+ cookies = f"d={self.token.cookie}" if self.token.cookie else ""
+ return {
+ "useragent": f"wee_slack {SCRIPT_VERSION}",
+ "httpheader": f"Authorization: Bearer {self.token.token}",
+ "cookie": cookies,
+ }
+
+ async def fetch(self, method: str, params: Dict[str, Union[str, int]] = {}):
+ url = f"https://api.slack.com/api/{method}?{urlencode(params)}"
+ response = await http_request(
+ url,
+ self.get_request_options(),
+ config.slack_timeout,
+ )
+ return json.loads(response)
+
+ async def fetch_list(
+ self,
+ method: str,
+ list_key: str,
+ params: Dict[str, Union[str, int]] = {},
+ pages: int = 1, # negative or 0 means all pages
+ ):
+ response = await self.fetch(method, params)
+ next_cursor = response.get("response_metadata", {}).get("next_cursor")
+ if pages != 1 and next_cursor and response["ok"]:
+ params["cursor"] = next_cursor
+ next_pages = await self.fetch_list(method, list_key, params, pages - 1)
+ response[list_key].extend(next_pages[list_key])
+ return response
+ return response
+
+
+class SlackTeam:
+ def __init__(self, token: SlackToken):
+ self.api = SlackApi(token)
+
+
+class SlackChannelCommonNew:
+ def __init__(self, team: SlackTeam, slack_info: SlackConversation):
+ self.team = team
+ self.api = team.api
+ self.id = slack_info["id"]
+ # self.fetch_info()
+
+ async def fetch_info(self):
+ response = await self.api.fetch("conversations.info", {"channel": self.id})
+ print(len(response))
+
+
+class SlackChannelNew(SlackChannelCommonNew):
+ def __init__(self, team: SlackTeam, slack_info: SlackConversationNotIm):
+ super().__init__(team, slack_info)
+ self.name = slack_info["name"]
+
+
+class SlackIm(SlackChannelCommonNew):
+ def __init__(self, team: SlackTeam, slack_info: SlackConversationIm):
+ super().__init__(team, slack_info)
+ self.user = slack_info["user"]
+
+
+async def init():
+ token = SlackToken(
+ weechat.config_get_plugin("api_token"), weechat.config_get_plugin("api_cookie")
+ )
+ team = SlackTeam(token)
+ print(team)
+
+
+if __name__ == "__main__":
+ if weechat.register(
+ SCRIPT_NAME,
+ SCRIPT_AUTHOR,
+ SCRIPT_VERSION,
+ SCRIPT_LICENSE,
+ SCRIPT_DESC,
+ "shutdown_cb",
+ "",
+ ):
+ config = SlackConfig()
+ create_task(init(), final=True)
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/__init__.py
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 0000000..c3d19e9
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,23 @@
+import importlib
+import importlib.machinery
+import sys
+
+
+# Copied from https://stackoverflow.com/a/72721573
+def import_stub(stubs_path: str, module_name: str):
+ sys.path_hooks.insert(
+ 0,
+ importlib.machinery.FileFinder.path_hook(
+ (importlib.machinery.SourceFileLoader, [".pyi"])
+ ),
+ )
+ sys.path.insert(0, stubs_path)
+
+ try:
+ return importlib.import_module(module_name)
+ finally:
+ sys.path.pop(0)
+ sys.path_hooks.pop(0)
+
+
+import_stub("typings", "weechat")
diff --git a/tests/test_hook_process_hashtable.py b/tests/test_hook_process_hashtable.py
new file mode 100644
index 0000000..27629b5
--- /dev/null
+++ b/tests/test_hook_process_hashtable.py
@@ -0,0 +1,67 @@
+from unittest.mock import MagicMock, patch
+
+import pytest
+import weechat
+
+from slack import (
+ FutureProcess,
+ FutureTimer,
+ hook_process_hashtable,
+ weechat_task_cb,
+)
+import slack
+
+
+@patch.object(weechat, "hook_process_hashtable")
+def test_hook_process_hashtable(mock_method: MagicMock):
+ command = "command"
+ options = {"option": "1"}
+ timeout = 123
+ coroutine = hook_process_hashtable(command, options, timeout)
+ future = coroutine.send(None)
+ assert isinstance(future, FutureProcess)
+
+ mock_method.assert_called_once_with(
+ command, options, timeout, weechat_task_cb.__name__, future.id
+ )
+
+ with pytest.raises(StopIteration) as excinfo:
+ coroutine.send((command, 0, "out", "err"))
+ assert excinfo.value.value == (command, 0, "out", "err")
+
+
+@patch.object(weechat, "hook_process_hashtable")
+def test_hook_process_hashtable_chunked(mock_method: MagicMock):
+ command = "command"
+ options = {"option": "1"}
+ timeout = 123
+ coroutine = hook_process_hashtable(command, options, timeout)
+ future = coroutine.send(None)
+ assert isinstance(future, FutureProcess)
+
+ mock_method.assert_called_once_with(
+ command, options, timeout, weechat_task_cb.__name__, future.id
+ )
+
+ assert isinstance(coroutine.send((command, -1, "o1", "e1")), FutureProcess)
+ assert isinstance(coroutine.send((command, -1, "o2", "e2")), FutureProcess)
+
+ with pytest.raises(StopIteration) as excinfo:
+ coroutine.send((command, 0, "o3", "e3"))
+ assert excinfo.value.value == (command, 0, "o1o2o3", "e1e2e3")
+
+
+@patch.object(slack, "available_file_descriptors")
+def test_hook_process_hashtable_wait_on_max_file_descriptors(
+ mock_available_file_descriptors: MagicMock,
+):
+ mock_available_file_descriptors.return_value = 0
+ coroutine = hook_process_hashtable("", {}, 0)
+ future = coroutine.send(None)
+ assert isinstance(future, FutureTimer)
+
+ mock_available_file_descriptors.return_value = 9
+ assert isinstance(coroutine.send((0,)), FutureTimer)
+
+ mock_available_file_descriptors.return_value = 10
+ assert isinstance(coroutine.send((0,)), FutureProcess)
diff --git a/tests/test_http_request.py b/tests/test_http_request.py
new file mode 100644
index 0000000..f4f36ac
--- /dev/null
+++ b/tests/test_http_request.py
@@ -0,0 +1,136 @@
+from unittest.mock import MagicMock, patch
+
+import pytest
+import weechat
+
+from slack import (
+ FutureProcess,
+ FutureTimer,
+ HttpError,
+ http_request,
+ weechat_task_cb,
+)
+
+
+@patch.object(weechat, "hook_process_hashtable")
+def test_http_request_success(mock_method: MagicMock):
+ url = "http://example.com"
+ options = {"option": "1"}
+ timeout = 123
+ coroutine = http_request(url, options, timeout)
+ future = coroutine.send(None)
+ assert isinstance(future, FutureProcess)
+
+ mock_method.assert_called_once_with(
+ f"url:{url}",
+ {**options, "header": "1"},
+ timeout,
+ weechat_task_cb.__name__,
+ future.id,
+ )
+
+ response = "response"
+ body = f"HTTP/2 200\r\n\r\n{response}"
+
+ with pytest.raises(StopIteration) as excinfo:
+ coroutine.send(("", 0, body, ""))
+ assert excinfo.value.value == response
+
+
+def test_http_request_error_process_return_code():
+ url = "http://example.com"
+ coroutine = http_request(url, {}, 0, max_retries=0)
+ assert isinstance(coroutine.send(None), FutureProcess)
+
+ with pytest.raises(HttpError) as excinfo:
+ coroutine.send(("", -2, "", ""))
+
+ assert excinfo.value.url == url
+ assert excinfo.value.return_code == -2
+ assert excinfo.value.http_status == 0
+ assert excinfo.value.error == ""
+
+
+def test_http_request_error_process_stderr():
+ url = "http://example.com"
+ coroutine = http_request(url, {}, 0, max_retries=0)
+ assert isinstance(coroutine.send(None), FutureProcess)
+
+ with pytest.raises(HttpError) as excinfo:
+ coroutine.send(("", 0, "", "err"))
+
+ assert excinfo.value.url == url
+ assert excinfo.value.return_code == 0
+ assert excinfo.value.http_status == 0
+ assert excinfo.value.error == "err"
+
+
+def test_http_request_error_process_http():
+ url = "http://example.com"
+ coroutine = http_request(url, {}, 0, max_retries=0)
+ assert isinstance(coroutine.send(None), FutureProcess)
+
+ response = "response"
+ body = f"HTTP/2 400\r\n\r\n{response}"
+
+ with pytest.raises(HttpError) as excinfo:
+ coroutine.send(("", 0, body, ""))
+
+ assert excinfo.value.url == url
+ assert excinfo.value.return_code == 0
+ assert excinfo.value.http_status == 400
+ assert excinfo.value.error == response
+
+
+def test_http_request_error_retry_success():
+ url = "http://example.com"
+ coroutine = http_request(url, {}, 0, max_retries=2)
+ assert isinstance(coroutine.send(None), FutureProcess)
+
+ assert isinstance(coroutine.send(("", -2, "", "")), FutureTimer)
+ assert isinstance(coroutine.send((0,)), FutureProcess)
+
+ response = "response"
+ body = f"HTTP/2 200\r\n\r\n{response}"
+
+ with pytest.raises(StopIteration) as excinfo:
+ coroutine.send(("", 0, body, ""))
+ assert excinfo.value.value == response
+
+
+def test_http_request_error_retry_error():
+ url = "http://example.com"
+ coroutine = http_request(url, {}, 0, max_retries=2)
+ assert isinstance(coroutine.send(None), FutureProcess)
+
+ assert isinstance(coroutine.send(("", -2, "", "")), FutureTimer)
+ assert isinstance(coroutine.send((0,)), FutureProcess)
+ assert isinstance(coroutine.send(("", -2, "", "")), FutureTimer)
+ assert isinstance(coroutine.send((0,)), FutureProcess)
+
+ with pytest.raises(HttpError) as excinfo:
+ coroutine.send(("", -2, "", ""))
+
+ assert excinfo.value.url == url
+ assert excinfo.value.return_code == -2
+ assert excinfo.value.http_status == 0
+ assert excinfo.value.error == ""
+
+
+@patch.object(weechat, "hook_timer")
+def test_http_request_ratelimit(mock_method: MagicMock):
+ url = "http://example.com"
+ coroutine = http_request(url, {}, 0)
+ assert isinstance(coroutine.send(None), FutureProcess)
+
+ body = "HTTP/2 429\r\nRetry-After: 12\r\n\r\n"
+
+ timer = coroutine.send(("", 0, body, ""))
+ assert isinstance(timer, FutureTimer)
+
+ mock_method.assert_called_once_with(12000, 0, 1, weechat_task_cb.__name__, timer.id)
+
+ assert isinstance(coroutine.send((0,)), FutureProcess)
+
+ with pytest.raises(StopIteration):
+ coroutine.send(("", 0, "HTTP/2 200\r\n\r\n", ""))
diff --git a/tests/test_sleep.py b/tests/test_sleep.py
new file mode 100644
index 0000000..c226c47
--- /dev/null
+++ b/tests/test_sleep.py
@@ -0,0 +1,22 @@
+from unittest.mock import MagicMock, patch
+
+import pytest
+import weechat
+
+from slack import FutureTimer, sleep, weechat_task_cb
+
+
+@patch.object(weechat, "hook_timer")
+def test_sleep(mock_method: MagicMock):
+ milliseconds = 123
+ coroutine = sleep(milliseconds)
+ future = coroutine.send(None)
+ assert isinstance(future, FutureTimer)
+
+ mock_method.assert_called_once_with(
+ milliseconds, 0, 1, weechat_task_cb.__name__, future.id
+ )
+
+ with pytest.raises(StopIteration) as excinfo:
+ coroutine.send((0,))
+ assert excinfo.value.value == (0,) # TODO: Will probably change to None
diff --git a/tests/test_task_runner.py b/tests/test_task_runner.py
new file mode 100644
index 0000000..a9db046
--- /dev/null
+++ b/tests/test_task_runner.py
@@ -0,0 +1,62 @@
+import slack
+from slack import Future, create_task, weechat_task_cb
+
+
+def test_run_single_task():
+ slack.active_tasks = {}
+ slack.active_responses = {}
+ future = Future[str]()
+
+ async def awaitable():
+ result = await future
+ return "awaitable", result
+
+ task = create_task(awaitable())
+ weechat_task_cb(future.id, "data")
+
+ assert not slack.active_tasks
+ assert slack.active_responses == {task.id: ("awaitable", ("data",))}
+
+
+def test_run_nested_task():
+ slack.active_tasks = {}
+ slack.active_responses = {}
+ future = Future[str]()
+
+ async def awaitable1():
+ result = await future
+ return "awaitable1", result
+
+ async def awaitable2():
+ result = await create_task(awaitable1())
+ return "awaitable2", result
+
+ task = create_task(awaitable2())
+ weechat_task_cb(future.id, "data")
+
+ assert not slack.active_tasks
+ assert slack.active_responses == {
+ task.id: ("awaitable2", ("awaitable1", ("data",)))
+ }
+
+
+def test_run_two_tasks_concurrently():
+ slack.active_tasks = {}
+ slack.active_responses = {}
+ future1 = Future[str]()
+ future2 = Future[str]()
+
+ async def awaitable(future: Future[str]):
+ result = await future
+ return "awaitable", result
+
+ task1 = create_task(awaitable(future1))
+ task2 = create_task(awaitable(future2))
+ weechat_task_cb(future1.id, "data1")
+ weechat_task_cb(future2.id, "data2")
+
+ assert not slack.active_tasks
+ assert slack.active_responses == {
+ task1.id: ("awaitable", ("data1",)),
+ task2.id: ("awaitable", ("data2",)),
+ }
diff --git a/typings/slack_api.pyi b/typings/slack_api.pyi
new file mode 100644
index 0000000..4829047
--- /dev/null
+++ b/typings/slack_api.pyi
@@ -0,0 +1,73 @@
+from typing import TypedDict
+
+class SlackTopic(TypedDict):
+ value: str
+ creator: str
+ last_set: int
+
+class SlackPurpose(TypedDict):
+ value: str
+ creator: str
+ last_set: int
+
+class SlackConversationCommon(TypedDict):
+ id: str
+
+class SlackConversationCommonNotIm(SlackConversationCommon):
+ created: int
+ creator: str
+ is_archived: bool
+ is_channel: bool
+ is_ext_shared: bool
+ is_general: bool
+ is_group: bool
+ is_im: bool
+ is_member: bool
+ is_mpim: bool
+ is_org_shared: bool
+ is_pending_ext_shared: bool
+ is_private: bool
+ is_shared: bool
+ name_normalized: str
+ name: str
+ num_members: int
+ parent_conversation: None
+ pending_connected_team_ids: list
+ pending_shared: list
+ previous_names: list[str]
+ purpose: SlackPurpose
+ shared_team_ids: list[str]
+ topic: SlackTopic
+ unlinked: int
+
+class SlackConversationPublic(SlackConversationCommonNotIm):
+ num_members: int
+ previous_names: list[str]
+
+class SlackConversationPrivate(SlackConversationCommonNotIm):
+ num_members: int
+
+class SlackConversationMpim(SlackConversationCommonNotIm):
+ num_members: int
+
+class SlackConversationGroup(SlackConversationCommonNotIm):
+ is_open: bool
+ last_read: str
+ priority: int
+
+class SlackConversationIm(SlackConversationCommon):
+ created: int
+ is_archived: bool
+ is_im: bool
+ is_org_shared: bool
+ is_user_deleted: bool
+ priority: int
+ user: str
+
+SlackConversationNotIm = (
+ SlackConversationPublic
+ | SlackConversationPrivate
+ | SlackConversationMpim
+ | SlackConversationGroup
+)
+SlackConversation = SlackConversationNotIm | SlackConversationIm
diff --git a/typings/weechat.pyi b/typings/weechat.pyi
new file mode 100644
index 0000000..ce72b2a
--- /dev/null
+++ b/typings/weechat.pyi
@@ -0,0 +1,2654 @@
+#
+# WeeChat Python stub file, auto-generated by python_stub.py.
+# DO NOT EDIT BY HAND!
+#
+
+from typing import Dict
+
+WEECHAT_RC_OK: int = 0
+WEECHAT_RC_OK_EAT: int = 1
+WEECHAT_RC_ERROR: int = -1
+WEECHAT_CONFIG_READ_OK: int = 0
+WEECHAT_CONFIG_READ_MEMORY_ERROR: int = -1
+WEECHAT_CONFIG_READ_FILE_NOT_FOUND: int = -2
+WEECHAT_CONFIG_WRITE_OK: int = 0
+WEECHAT_CONFIG_WRITE_ERROR: int = -1
+WEECHAT_CONFIG_WRITE_MEMORY_ERROR: int = -2
+WEECHAT_CONFIG_OPTION_SET_OK_CHANGED: int = 2
+WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE: int = 1
+WEECHAT_CONFIG_OPTION_SET_ERROR: int = 0
+WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND: int = -1
+WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET: int = 0
+WEECHAT_CONFIG_OPTION_UNSET_OK_RESET: int = 1
+WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED: int = 2
+WEECHAT_CONFIG_OPTION_UNSET_ERROR: int = -1
+WEECHAT_LIST_POS_SORT: str = "sort"
+WEECHAT_LIST_POS_BEGINNING: str = "beginning"
+WEECHAT_LIST_POS_END: str = "end"
+WEECHAT_HOTLIST_LOW: str = "0"
+WEECHAT_HOTLIST_MESSAGE: str = "1"
+WEECHAT_HOTLIST_PRIVATE: str = "2"
+WEECHAT_HOTLIST_HIGHLIGHT: str = "3"
+WEECHAT_HOOK_PROCESS_RUNNING: int = -1
+WEECHAT_HOOK_PROCESS_ERROR: int = -2
+WEECHAT_HOOK_CONNECT_OK: int = 0
+WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND: int = 1
+WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND: int = 2
+WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED: int = 3
+WEECHAT_HOOK_CONNECT_PROXY_ERROR: int = 4
+WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR: int = 5
+WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR: int = 6
+WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR: int = 7
+WEECHAT_HOOK_CONNECT_MEMORY_ERROR: int = 8
+WEECHAT_HOOK_CONNECT_TIMEOUT: int = 9
+WEECHAT_HOOK_CONNECT_SOCKET_ERROR: int = 10
+WEECHAT_HOOK_SIGNAL_STRING: str = "string"
+WEECHAT_HOOK_SIGNAL_INT: str = "int"
+WEECHAT_HOOK_SIGNAL_POINTER: str = "pointer"
+
+
+def register(name: str, author: str, version: str, license: str, description: str, shutdown_function: str, charset: str) -> int:
+ """`register in WeeChat plugin API reference <https://weechat.org/doc/api/#_register>`_
+ """
+ ...
+
+
+def plugin_get_name(plugin: str) -> str:
+ """`plugin_get_name in WeeChat plugin API reference <https://weechat.org/doc/api/#_plugin_get_name>`_
+ ::
+
+ # example
+ plugin = weechat.buffer_get_pointer(weechat.current_buffer(), "plugin")
+ name = weechat.plugin_get_name(plugin)
+ """
+ ...
+
+
+def charset_set(charset: str) -> int:
+ """`charset_set in WeeChat plugin API reference <https://weechat.org/doc/api/#_charset_set>`_
+ ::
+
+ # example
+ weechat.charset_set("iso-8859-1")
+ """
+ ...
+
+
+def iconv_to_internal(charset: str, string: str) -> str:
+ """`iconv_to_internal in WeeChat plugin API reference <https://weechat.org/doc/api/#_iconv_to_internal>`_
+ ::
+
+ # example
+ str = weechat.iconv_to_internal("iso-8859-1", "iso string: é à")
+ """
+ ...
+
+
+def iconv_from_internal(charset: str, string: str) -> str:
+ """`iconv_from_internal in WeeChat plugin API reference <https://weechat.org/doc/api/#_iconv_from_internal>`_
+ ::
+
+ # example
+ str = weechat.iconv_from_internal("iso-8859-1", "utf-8 string: é à")
+ """
+ ...
+
+
+def gettext(string: str) -> str:
+ """`gettext in WeeChat plugin API reference <https://weechat.org/doc/api/#_gettext>`_
+ ::
+
+ # example
+ str = weechat.gettext("hello")
+ """
+ ...
+
+
+def ngettext(string: str, plural: str, count: int) -> str:
+ """`ngettext in WeeChat plugin API reference <https://weechat.org/doc/api/#_ngettext>`_
+ ::
+
+ # example
+ num_files = 2
+ str = weechat.ngettext("file", "files", num_files)
+ """
+ ...
+
+
+def strlen_screen(string: str) -> int:
+ """`strlen_screen in WeeChat plugin API reference <https://weechat.org/doc/api/#_strlen_screen>`_
+ ::
+
+ # example
+ length = weechat.strlen_screen("é") # 1
+ """
+ ...
+
+
+def string_match(string: str, mask: str, case_sensitive: int) -> int:
+ """`string_match in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_match>`_
+ ::
+
+ # examples
+ match1 = weechat.string_match("abcdef", "abc*", 0) # == 1
+ match2 = weechat.string_match("abcdef", "*dd*", 0) # == 0
+ match3 = weechat.string_match("abcdef", "*def", 0) # == 1
+ match4 = weechat.string_match("abcdef", "*de*", 0) # == 1
+ match5 = weechat.string_match("abcdef", "*b*d*", 0) # == 1
+ """
+ ...
+
+
+def string_match_list(string: str, masks: str, case_sensitive: int) -> int:
+ """`string_match_list in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_match_list>`_
+ ::
+
+ # examples
+ match1 = weechat.string_match("abc", "*,!abc*", 0) # == 0
+ match2 = weechat.string_match("abcdef", "*,!abc*", 0) # == 0
+ match3 = weechat.string_match("def", "*,!abc*", 0) # == 1
+ """
+ ...
+
+
+def string_eval_path_home(path: str, pointers: Dict[str, str], extra_vars: Dict[str, str], options: Dict[str, str]) -> str:
+ """`string_eval_path_home in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_eval_path_home>`_
+ ::
+
+ # example
+ path = weechat.string_eval_path_home("${weechat_config_dir}/test.conf", {}, {}, {})
+ # path == "/home/user/.config/weechat/test.conf"
+ """
+ ...
+
+
+def string_mask_to_regex(mask: str) -> str:
+ """`string_mask_to_regex in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_mask_to_regex>`_
+ ::
+
+ # example
+ regex = weechat.string_mask_to_regex("test*mask") # "test.*mask"
+ """
+ ...
+
+
+def string_has_highlight(string: str, highlight_words: str) -> int:
+ """`string_has_highlight in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_has_highlight>`_
+ ::
+
+ # example
+ highlight = weechat.string_has_highlight("my test string", "test,word2") # 1
+ """
+ ...
+
+
+def string_has_highlight_regex(string: str, regex: str) -> int:
+ """`string_has_highlight_regex in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_has_highlight_regex>`_
+ ::
+
+ # example
+ highlight = weechat.string_has_highlight_regex("my test string", "test|word2") # 1
+ """
+ ...
+
+
+def string_format_size(size: int) -> str:
+ """`string_format_size in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_format_size>`_
+ ::
+
+ # example
+ str = weechat.string_format_size(15200) # == "15.2 KB"
+ """
+ ...
+
+
+def string_parse_size(size: str) -> int:
+ """`string_parse_size in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_parse_size>`_
+ ::
+
+ # example
+ size = weechat.string_parse_size("1.34m") # 1340000
+ """
+ ...
+
+
+def string_color_code_size(string: str) -> int:
+ """`string_color_code_size in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_color_code_size>`_
+ ::
+
+ # examples
+ size = weechat.string_color_code_size("test") # size == 0
+ size = weechat.string_color_code_size(weechat.color("bold")) # size == 2
+ size = weechat.string_color_code_size(weechat.color("yellow,red")) # size == 7
+ """
+ ...
+
+
+def string_remove_color(string: str, replacement: str) -> str:
+ """`string_remove_color in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_remove_color>`_
+ ::
+
+ # example
+ str = weechat.string_remove_color(my_string, "?")
+ """
+ ...
+
+
+def string_is_command_char(string: str) -> int:
+ """`string_is_command_char in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_is_command_char>`_
+ ::
+
+ # examples
+ command_char1 = weechat.string_is_command_char("/test") # == 1
+ command_char2 = weechat.string_is_command_char("test") # == 0
+ """
+ ...
+
+
+def string_input_for_buffer(string: str) -> str:
+ """`string_input_for_buffer in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_input_for_buffer>`_
+ ::
+
+ # examples
+ str1 = weechat.string_input_for_buffer("test") # "test"
+ str2 = weechat.string_input_for_buffer("/test") # ""
+ str3 = weechat.string_input_for_buffer("//test") # "/test"
+ """
+ ...
+
+
+def string_eval_expression(expr: str, pointers: Dict[str, str], extra_vars: Dict[str, str], options: Dict[str, str]) -> str:
+ """`string_eval_expression in WeeChat plugin API reference <https://weechat.org/doc/api/#_string_eval_expression>`_
+ ::
+
+ # examples
+
+ # conditions
+ str1 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
+ str2 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
+
+ # simple expression
+ str3 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
+
+ # replace with regex: add brackets around URLs
+ options = {
+ "regex": "[a-zA-Z0-9_]+://[^ ]+",
+ "regex_replace": "[ ${re:0} ]",
+ }
+ str4 = weechat.string_eval_expression("test: https://weechat.org", {}, {}, options) # "test: [ https://weechat.org ]"
+
+ # replace with regex: hide passwords
+ options = {
+ "regex": "(password=)([^ ]+)",
+ "regex_replace": "${re:1}${hide:*,${re:2}}",
+ }
+ str5 = weechat.string_eval_expression("password=abc password=def", {}, {}, options) # "password=*** password=***"
+ """
+ ...
+
+
+def mkdir_home(directory: str, mode: int) -> int:
+ """`mkdir_home in WeeChat plugin API reference <https://weechat.org/doc/api/#_mkdir_home>`_
+ ::
+
+ # example
+ weechat.mkdir_home("${weechat_cache_dir}/temp", 0755)
+ """
+ ...
+
+
+def mkdir(directory: str, mode: int) -> int:
+ """`mkdir in WeeChat plugin API reference <https://weechat.org/doc/api/#_mkdir>`_
+ ::
+
+ # example
+ weechat.mkdir("/tmp/mydir", 0755)
+ """
+ ...
+
+
+def mkdir_parents(directory: str, mode: int) -> int:
+ """`mkdir_parents in WeeChat plugin API reference <https://weechat.org/doc/api/#_mkdir_parents>`_
+ ::
+
+ # example
+ weechat.mkdir_parents("/tmp/my/dir", 0755)
+ """
+ ...
+
+
+def list_new() -> str:
+ """`list_new in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_new>`_
+ ::
+
+ # example
+ list = weechat.list_new()
+ """
+ ...
+
+
+def list_add(list: str, data: str, where: str, user_data: str) -> str:
+ """`list_add in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_add>`_
+ ::
+
+ # example
+ item = weechat.list_add(list, "my data", weechat.WEECHAT_LIST_POS_SORT, "")
+ """
+ ...
+
+
+def list_search(list: str, data: str) -> str:
+ """`list_search in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_search>`_
+ ::
+
+ # example
+ item = weechat.list_search(list, "my data")
+ """
+ ...
+
+
+def list_search_pos(list: str, data: str) -> int:
+ """`list_search_pos in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_search_pos>`_
+ ::
+
+ # example
+ pos_item = weechat.list_search_pos(list, "my data")
+ """
+ ...
+
+
+def list_casesearch(list: str, data: str) -> str:
+ """`list_casesearch in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_casesearch>`_
+ ::
+
+ # example
+ item = weechat.list_casesearch(list, "my data")
+ """
+ ...
+
+
+def list_casesearch_pos(list: str, data: str) -> int:
+ """`list_casesearch_pos in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_casesearch_pos>`_
+ ::
+
+ # example
+ pos_item = weechat.list_casesearch_pos(list, "my data")
+ """
+ ...
+
+
+def list_get(list: str, position: int) -> str:
+ """`list_get in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_get>`_
+ ::
+
+ # example
+ item = weechat.list_get(list, 0)
+ """
+ ...
+
+
+def list_set(item: str, value: str) -> int:
+ """`list_set in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_set>`_
+ ::
+
+ # example
+ weechat.list_set(item, "new data")
+ """
+ ...
+
+
+def list_next(item: str) -> str:
+ """`list_next in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_next>`_
+ ::
+
+ # example
+ item = weechat.list_next(item)
+ """
+ ...
+
+
+def list_prev(item: str) -> str:
+ """`list_prev in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_prev>`_
+ ::
+
+ # example
+ item = weechat.list_prev(item)
+ """
+ ...
+
+
+def list_string(item: str) -> str:
+ """`list_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_string>`_
+ ::
+
+ # example
+ weechat.prnt("", "value of item: %s" % weechat.list_string(item))
+ """
+ ...
+
+
+def list_size(list: str) -> int:
+ """`list_size in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_size>`_
+ ::
+
+ # example
+ weechat.prnt("", "size of list: %d" % weechat.list_size(list))
+ """
+ ...
+
+
+def list_remove(list: str, item: str) -> int:
+ """`list_remove in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_remove>`_
+ ::
+
+ # example
+ weechat.list_remove(list, item)
+ """
+ ...
+
+
+def list_remove_all(list: str) -> int:
+ """`list_remove_all in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_remove_all>`_
+ ::
+
+ # example
+ weechat.list_remove_all(list)
+ """
+ ...
+
+
+def list_free(list: str) -> int:
+ """`list_free in WeeChat plugin API reference <https://weechat.org/doc/api/#_list_free>`_
+ ::
+
+ # example
+ weechat.list_free(list)
+ """
+ ...
+
+
+def config_new(name: str, callback_reload: str, callback_reload_data: str) -> str:
+ """`config_new in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_new>`_
+ ::
+
+ # example
+ def my_config_reload_cb(data: str, config_file: str) -> int:
+ # ...
+ return weechat.WEECHAT_RC_OK
+
+ config_file = weechat.config_new("test", "my_config_reload_cb", "")
+ """
+ ...
+
+
+def config_new_section(config_file: str, name: str,
+ user_can_add_options: int, user_can_delete_options: int,
+ callback_read: str, callback_read_data: str,
+ callback_write: str, callback_write_data: str,
+ callback_write_default: str, callback_write_default_data: str,
+ callback_create_option: str, callback_create_option_data: str,
+ callback_delete_option: str, callback_delete_option_data: str) -> str:
+ """`config_new_section in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_new_section>`_
+ ::
+
+ # example
+ def my_section_read_cb(data: str, config_file: str, section: str, option_name: str, value: str) -> int:
+ # ...
+ return weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED
+ # return weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
+ # return weechat.WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND
+ # return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR
+
+ def my_section_write_cb(data: str, config_file: str, section_name: str) -> int:
+ # ...
+ return weechat.WEECHAT_CONFIG_WRITE_OK
+
+ def my_section_write_default_cb(data: str, config_file: str, section_name: str) -> int:
+ # ...
+ return weechat.WEECHAT_CONFIG_WRITE_OK
+
+ def my_section_create_option_cb(data: str, config_file: str, section: str, option_name: str, value: str) -> int:
+ # ...
+ return weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
+
+ def my_section_delete_option_cb(data: str, config_file: str, section: str, option: str) -> int:
+ # ...
+ return weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED
+
+ section = weechat.config_new_section(config_file, "section1", 1, 1,
+ "my_section_read_cb", "",
+ "my_section_write_cb", "",
+ "my_section_write_default_cb", "",
+ "my_section_create_option_cb", "",
+ "my_section_delete_option_cb", "")
+ """
+ ...
+
+
+def config_search_section(config_file: str, section_name: str) -> str:
+ """`config_search_section in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_search_section>`_
+ ::
+
+ # example
+ section = weechat.config_search_section(config_file, "section")
+ """
+ ...
+
+
+def config_new_option(config_file: str, section: str, name: str, type: str, description: str,
+ string_values: str, min: int, max: int,
+ default_value: str | None, value: str | None, null_value_allowed: int,
+ callback_check_value: str, callback_check_value_data: str,
+ callback_change: str, callback_change_data: str,
+ callback_delete: str, callback_delete_data: str) -> str:
+ """`config_new_option in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_new_option>`_
+ ::
+
+ # example
+ def option4_check_value_cb(data: str, option: str, value: str) -> int:
+ # ...
+ return 1
+ # return 0
+
+ def option4_change_cb(data: str, option: str) -> None:
+ # ...
+
+ def option4_delete_cb(data: str, option: str) -> None:
+ # ...
+
+ option1 = weechat.config_new_option(config_file, section, "option1", "boolean",
+ "My option, type boolean",
+ "", 0, 0, "on", "on", 0,
+ "", "",
+ "", "",
+ "", "")
+
+ option2 = weechat.config_new_option(config_file, section, "option2", "integer",
+ "My option, type integer",
+ "", 0, 100, "15", "15", 0,
+ "", "",
+ "", "",
+ "", "")
+
+ option3 = weechat.config_new_option(config_file, section, "option3", "integer",
+ "My option, type integer (with string values)",
+ "top|bottom|left|right",
+ 0, 0, "bottom", "bottom", 0,
+ "", "",
+ "", "",
+ "", "")
+
+ option4 = weechat.config_new_option(config_file, section, "option4", "string",
+ "My option, type string",
+ "", 0, 0, "test", "test", 1,
+ "option4_check_value_cb", "",
+ "option4_change_cb", "",
+ "option4_delete_cb", "")
+
+ option5 = weechat.config_new_option(config_file, section, "option5", "color",
+ "My option, type color",
+ "", 0, 0, "lightblue", "lightblue", 0,
+ "", "",
+ "", "",
+ "", "")
+ """
+ ...
+
+
+def config_search_option(config_file: str, section: str, option_name: str) -> str:
+ """`config_search_option in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_search_option>`_
+ ::
+
+ # example
+ option = weechat.config_search_option(config_file, section, "option")
+ """
+ ...
+
+
+def config_string_to_boolean(text: str) -> int:
+ """`config_string_to_boolean in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_string_to_boolean>`_
+ ::
+
+ # example
+ if weechat.config_string_to_boolean(text):
+ # ...
+ """
+ ...
+
+
+def config_option_reset(option: str, run_callback: int) -> int:
+ """`config_option_reset in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_option_reset>`_
+ ::
+
+ # example
+ rc = weechat.config_option_reset(option, 1)
+ if rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
+ # ...
+ """
+ ...
+
+
+def config_option_set(option: str, value: str, run_callback: int) -> int:
+ """`config_option_set in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_option_set>`_
+ ::
+
+ # example
+ rc = weechat.config_option_set(option, "new_value", 1)
+ if rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
+ # ...
+ """
+ ...
+
+
+def config_option_set_null(option: str, run_callback: int) -> int:
+ """`config_option_set_null in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_option_set_null>`_
+ ::
+
+ # example
+ rc = weechat.config_option_set_null(option, 1)
+ if rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
+ # ...
+ """
+ ...
+
+
+def config_option_unset(option: str) -> int:
+ """`config_option_unset in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_option_unset>`_
+ ::
+
+ # example
+ rc = weechat.config_option_unset(option)
+ if rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_RESET:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_ERROR:
+ # ...
+ """
+ ...
+
+
+def config_option_rename(option: str, new_name: str) -> int:
+ """`config_option_rename in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_option_rename>`_
+ ::
+
+ # example
+ weechat.config_option_rename(option, "new_name")
+ """
+ ...
+
+
+def config_option_is_null(option: str) -> int:
+ """`config_option_is_null in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_option_is_null>`_
+ ::
+
+ # example
+ if weechat.config_option_is_null(option):
+ # ...
+ """
+ ...
+
+
+def config_option_default_is_null(option: str) -> int:
+ """`config_option_default_is_null in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_option_default_is_null>`_
+ ::
+
+ # example
+ if weechat.config_option_default_is_null(option):
+ # ...
+ """
+ ...
+
+
+def config_boolean(option: str) -> int:
+ """`config_boolean in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_boolean>`_
+ ::
+
+ # example
+ option = weechat.config_get("plugin.section.option")
+ if weechat.config_boolean(option):
+ # ...
+ """
+ ...
+
+
+def config_boolean_default(option: str) -> int:
+ """`config_boolean_default in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_boolean_default>`_
+ ::
+
+ # example
+ option = weechat.config_get("plugin.section.option")
+ if weechat.config_boolean_default(option):
+ # ...
+ """
+ ...
+
+
+def config_integer(option: str) -> int:
+ """`config_integer in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_integer>`_
+ ::
+
+ # example
+ option = weechat.config_get("plugin.section.option")
+ value = weechat.config_integer(option)
+ """
+ ...
+
+
+def config_integer_default(option: str) -> int:
+ """`config_integer_default in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_integer_default>`_
+ ::
+
+ # example
+ option = weechat.config_get("plugin.section.option")
+ value = weechat.config_integer_default(option)
+ """
+ ...
+
+
+def config_string(option: str) -> str:
+ """`config_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_string>`_
+ ::
+
+ # example
+ option = weechat.config_get("plugin.section.option")
+ value = weechat.config_string(option)
+ """
+ ...
+
+
+def config_string_default(option: str) -> str:
+ """`config_string_default in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_string_default>`_
+ ::
+
+ # example
+ option = weechat.config_get("plugin.section.option")
+ value = weechat.config_string_default(option)
+ """
+ ...
+
+
+def config_color(option: str) -> str:
+ """`config_color in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_color>`_
+ ::
+
+ # example
+ option = weechat.config_get("plugin.section.option")
+ value = weechat.config_color(option)
+ """
+ ...
+
+
+def config_color_default(option: str) -> str:
+ """`config_color_default in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_color_default>`_
+ ::
+
+ # example
+ option = weechat.config_get("plugin.section.option")
+ value = weechat.config_color_default(option)
+ """
+ ...
+
+
+def config_write_option(config_file: str, option: str) -> int:
+ """`config_write_option in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_write_option>`_
+ ::
+
+ # example
+ def my_section_write_cb(data: str, config_file: str, section_name: str) -> int:
+ weechat.config_write_line(config_file, "my_section", "")
+ weechat.config_write_option(config_file, option)
+ return weechat.WEECHAT_RC_OK
+ """
+ ...
+
+
+def config_write_line(config_file: str, option_name: str, value: str) -> int:
+ """`config_write_line in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_write_line>`_
+ ::
+
+ # example
+ def my_section_write_cb(data: str, config_file: str, section_name: str) -> int:
+ weechat.config_write_line(config_file, "my_section", "")
+ weechat.config_write_line(config_file, "option", "value")
+ return weechat.WEECHAT_RC_OK
+ """
+ ...
+
+
+def config_write(config_file: str) -> int:
+ """`config_write in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_write>`_
+ ::
+
+ # example
+ rc = weechat.config_write(config_file)
+ if rc == weechat.WEECHAT_CONFIG_WRITE_OK:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_WRITE_MEMORY_ERROR:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_WRITE_ERROR:
+ # ...
+ """
+ ...
+
+
+def config_read(config_file: str) -> int:
+ """`config_read in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_read>`_
+ ::
+
+ # example
+ rc = weechat.config_read(config_file)
+ if rc == weechat.WEECHAT_CONFIG_READ_OK:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_READ_MEMORY_ERROR:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_READ_FILE_NOT_FOUND:
+ # ...
+ """
+ ...
+
+
+def config_reload(config_file: str) -> int:
+ """`config_reload in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_reload>`_
+ ::
+
+ # example
+ rc = weechat.config_reload(config_file)
+ if rc == weechat.WEECHAT_CONFIG_READ_OK:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_READ_MEMORY_ERROR:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_READ_FILE_NOT_FOUND:
+ # ...
+ """
+ ...
+
+
+def config_option_free(option: str) -> int:
+ """`config_option_free in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_option_free>`_
+ ::
+
+ # example
+ weechat.config_option_free(option)
+ """
+ ...
+
+
+def config_section_free_options(section: str) -> int:
+ """`config_section_free_options in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_section_free_options>`_
+ ::
+
+ # example
+ weechat.config_section_free_options(section)
+ """
+ ...
+
+
+def config_section_free(section: str) -> int:
+ """`config_section_free in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_section_free>`_
+ ::
+
+ # example
+ weechat.config_section_free(section)
+ """
+ ...
+
+
+def config_free(config_file: str) -> int:
+ """`config_free in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_free>`_
+ ::
+
+ # example
+ weechat.config_free(config_file)
+ """
+ ...
+
+
+def config_get(option_name: str) -> str:
+ """`config_get in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_get>`_
+ ::
+
+ # example
+ option = weechat.config_get("weechat.look.item_time_format")
+ """
+ ...
+
+
+def config_get_plugin(option_name: str) -> str:
+ """`config_get_plugin in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_get_plugin>`_
+ ::
+
+ # example
+ value = weechat.config_get_plugin("option")
+ """
+ ...
+
+
+def config_is_set_plugin(option_name: str) -> int:
+ """`config_is_set_plugin in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_is_set_plugin>`_
+ ::
+
+ # example
+ if weechat.config_is_set_plugin("option"):
+ # option is set
+ # ...
+ else:
+ # option does not exist
+ # ...
+ """
+ ...
+
+
+def config_set_plugin(option_name: str, value: str) -> int:
+ """`config_set_plugin in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_set_plugin>`_
+ ::
+
+ # example
+ rc = weechat.config_set_plugin("option", "test_value")
+ if rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
+ # ...
+ """
+ ...
+
+
+def config_set_desc_plugin(option_name: str, description: str) -> int:
+ """`config_set_desc_plugin in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_set_desc_plugin>`_
+ ::
+
+ # example
+ version = weechat.info_get("version_number", "") or 0
+ if int(version) >= 0x00030500:
+ weechat.config_set_desc_plugin("option", "description of option")
+ """
+ ...
+
+
+def config_unset_plugin(option_name: str) -> int:
+ """`config_unset_plugin in WeeChat plugin API reference <https://weechat.org/doc/api/#_config_unset_plugin>`_
+ ::
+
+ # example
+ rc = weechat.config_unset_plugin("option")
+ if rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_RESET:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED:
+ # ...
+ elif rc == weechat.WEECHAT_CONFIG_OPTION_UNSET_ERROR:
+ # ...
+ """
+ ...
+
+
+def key_bind(context: str, keys: Dict[str, str]) -> int:
+ """`key_bind in WeeChat plugin API reference <https://weechat.org/doc/api/#_key_bind>`_
+ ::
+
+ # example
+ keys = {"@chat(python.test):button1": "hsignal:test_mouse",
+ "@chat(python.test):wheelup": "/mycommand up",
+ "@chat(python.test):wheeldown": "/mycommand down"}
+ weechat.key_bind("mouse", keys)
+ """
+ ...
+
+
+def key_unbind(context: str, key: str) -> int:
+ """`key_unbind in WeeChat plugin API reference <https://weechat.org/doc/api/#_key_unbind>`_
+ ::
+
+ # examples
+
+ # remove a single key
+ weechat.key_unbind("mouse", "@chat(plugin.buffer):button1")
+
+ # remove all keys with area "chat(python.test)"
+ weechat.key_unbind("mouse", "area:chat(python.test)")
+ """
+ ...
+
+
+def prefix(prefix: str) -> str:
+ """`prefix in WeeChat plugin API reference <https://weechat.org/doc/api/#_prefix>`_
+ ::
+
+ # example
+ weechat.prnt("", "%sThis is an error..." % weechat.prefix("error"))
+ """
+ ...
+
+
+def color(color_name: str) -> str:
+ """`color in WeeChat plugin API reference <https://weechat.org/doc/api/#_color>`_
+ ::
+
+ # example
+ weechat.prnt("", "Color: %sblue %sdefault color %syellow on red"
+ % (weechat.color("blue"), weechat.color("chat"), weechat.color("yellow,red")))
+ """
+ ...
+
+
+def prnt(buffer: str, message: str) -> int:
+ """`prnt in WeeChat plugin API reference <https://weechat.org/doc/api/#_prnt>`_
+ ::
+
+ # example
+ weechat.prnt("", "Hello on WeeChat buffer")
+ weechat.prnt(buffer, "Hello on this buffer")
+ weechat.prnt(buffer, "%sThis is an error!" % weechat.prefix("error"))
+ weechat.prnt(buffer, " \tMessage without prefix but with \t some \t tabs")
+ weechat.prnt(buffer, "\t\tMessage without time/alignment")
+ weechat.prnt(buffer, "\t\t") # empty line (without time)
+ """
+ ...
+
+
+def prnt_date_tags(buffer: str, date: int, tags: str, message: str) -> int:
+ """`prnt_date_tags in WeeChat plugin API reference <https://weechat.org/doc/api/#_prnt_date_tags>`_
+ ::
+
+ # example
+ time = int(time.time())
+ weechat.prnt_date_tags("", time - 120, "notify_message",
+ "Message 2 minutes ago, with a tag 'notify_message'")
+ """
+ ...
+
+
+def prnt_y(buffer: str, y: int, message: str) -> int:
+ """`prnt_y in WeeChat plugin API reference <https://weechat.org/doc/api/#_prnt_y>`_
+ ::
+
+ # example
+ weechat.prnt_y("", 2, "My message on third line")
+ """
+ ...
+
+
+def prnt_y_date_tags(buffer: str, y: int, date: int, tags: str, message: str) -> int:
+ """`prnt_y_date_tags in WeeChat plugin API reference <https://weechat.org/doc/api/#_prnt_y_date_tags>`_
+ ::
+
+ # example
+ weechat.prnt_y_date_tags("", 2, 0, "my_tag", "My message on third line with a tag")
+ """
+ ...
+
+
+def log_print(message: str) -> int:
+ """`log_print in WeeChat plugin API reference <https://weechat.org/doc/api/#_log_print>`_
+ ::
+
+ # example
+ weechat.log_print("My message in log file")
+ """
+ ...
+
+
+def hook_command(command: str, description: str, args: str, args_description: str,
+ completion: str, callback: str, callback_data: str) -> str:
+ """`hook_command in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_command>`_
+ ::
+
+ # example
+ def my_command_cb(data: str, buffer: str, args: str) -> int:
+ # ...
+ return weechat.WEECHAT_RC_OK
+
+ hook = weechat.hook_command("myfilter", "description of myfilter",
+ "[list] | [enable|disable|toggle [name]] | [add name plugin.buffer tags regex] | [del name|-all]",
+ "description of arguments...",
+ "list"
+ " || enable %(filters_names)"
+ " || disable %(filters_names)"
+ " || toggle %(filters_names)"
+ " || add %(filters_names) %(buffers_plugins_names)|*"
+ " || del %(filters_names)|-all",
+ "my_command_cb", "")
+ """
+ ...
+
+
+def hook_completion(completion_item: str, description: str, callback: str, callback_data: str) -> str:
+ """`hook_completion in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_completion>`_
+ ::
+
+ # example
+ def my_completion_cb(data: str, completion_item: str, buffer: str, completion: str) -> int:
+ weechat.completion_list_add(completion, "word1", 0, weechat.WEECHAT_LIST_POS_SORT)
+ weechat.completion_list_add(completion, "test_word2", 0, weechat.WEECHAT_LIST_POS_SORT)
+ return weechat.WEECHAT_RC_OK
+
+ hook = weechat.hook_completion("plugin_item", "my custom completion!",
+ "my_completion_cb", "")
+ """
+ ...
+
+
+def hook_command_run(command: str, callback: str, callback_data: str) -> str:
+ """`hook_command_run in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_command_run>`_
+ ::
+
+ # example
+ def my_command_run_cb(data: str, buffer: str, command: str) -> int:
+ weechat.prnt("", "I'm eating the completion!")
+ return weechat.WEECHAT_RC_OK_EAT
+
+ hook = weechat.hook_command_run("/input complete*", "my_command_run_cb", "")
+ """
+ ...
+
+
+def hook_timer(interval: int, align_second: int, max_calls: int, callback: str, callback_data: str) -> str:
+ """`hook_timer in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_timer>`_
+ ::
+
+ # example
+ def my_timer_cb(data: str, remaining_calls: int) -> int:
+ # ...
+ return weechat.WEECHAT_RC_OK
+
+ # timer called each 20 seconds
+ hook = weechat.hook_timer(20 * 1000, 0, 0, "my_timer_cb", "")
+ """
+ ...
+
+
+def hook_fd(fd: int, flag_read: int, flag_write: int, flag_exception: int, callback: str, callback_data: str) -> str:
+ """`hook_fd in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_fd>`_
+ ::
+
+ # example
+ def my_fd_cb(data: str, fd: int) -> int:
+ # ...
+ return weechat.WEECHAT_RC_OK
+
+ sock = ...
+ hook = weechat.hook_fd(sock, 1, 0, 0, "my_fd_cb", "")
+ """
+ ...
+
+
+def hook_process(command: str, timeout: int, callback: str, callback_data: str) -> str:
+ """`hook_process in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_process>`_
+ ::
+
+ # example with an external command
+ def my_process_cb(data: str, command: str, return_code: int, out: str, err: str) -> int:
+ if return_code == weechat.WEECHAT_HOOK_PROCESS_ERROR:
+ weechat.prnt("", "Error with command '%s'" % command)
+ return weechat.WEECHAT_RC_OK
+ if return_code >= 0:
+ weechat.prnt("", "return_code = %d" % return_code)
+ if out:
+ weechat.prnt("", "stdout: %s" % out)
+ if err:
+ weechat.prnt("", "stderr: %s" % err)
+ return weechat.WEECHAT_RC_OK
+
+ hook = weechat.hook_process("ls", 5000, "my_process_cb", "")
+
+ # example with a script function
+ def get_status(data: str) -> str:
+ # do something blocking...
+ # ...
+ return "this is the result"
+
+ def my_process_cb(data: str, command: str, return_code: int, out: str, err: str) -> int:
+ if return_code == weechat.WEECHAT_HOOK_PROCESS_ERROR:
+ weechat.prnt("", "Error with command '%s'" % command)
+ return weechat.WEECHAT_RC_OK
+ if return_code >= 0:
+ weechat.prnt("", "return_code = %d" % return_code)
+ if out:
+ weechat.prnt("", "stdout: %s" % out)
+ if err:
+ weechat.prnt("", "stderr: %s" % err)
+ return weechat.WEECHAT_RC_OK
+
+ hook = weechat.hook_process("func:get_status", 5000, "my_process_cb", "")
+ """
+ ...
+
+
+def hook_process_hashtable(command: str, options: Dict[str, str], timeout: int, callback: str, callback_data: str) -> str:
+ """`hook_process_hashtable in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_process_hashtable>`_
+ ::
+
+ # example
+ def my_process_cb(data: str, command: str, return_code: int, out: str, err: str) -> int:
+ if return_code == weechat.WEECHAT_HOOK_PROCESS_ERROR:
+ weechat.prnt("", "Error with command '%s'" % command)
+ return weechat.WEECHAT_RC_OK
+ if return_code >= 0:
+ weechat.prnt("", "return_code = %d" % return_code)
+ if out:
+ weechat.prnt("", "stdout: %s" % out)
+ if err:
+ weechat.prnt("", "stderr: %s" % err)
+ return weechat.WEECHAT_RC_OK
+
+ # example 1: download URL
+ hook1 = weechat.hook_process_hashtable("url:https://weechat.org/",
+ {"file_out": "/tmp/weechat.org.html"},
+ 20000, "my_process_cb", "")
+
+ # example 2: open URL with custom HTTP headers
+ options = {
+ "httpheader": "\n".join([
+ "Header1: value1",
+ "Header2: value2",
+ ]),
+ }
+ hook2 = weechat.hook_process_hashtable("url:http://localhost:8080/",
+ options,
+ 20000, "my_process_cb", "")
+
+ # example 3: execute a notify program with a message from someone
+ hook3 = weechat.hook_process_hashtable("my-notify-command",
+ {"arg1": "-from",
+ "arg2": nick,
+ "arg3": "-msg",
+ "arg4": message}, # untrusted argument
+ 20000, "my_process_cb", "")
+
+ # example 4: call shell to execute a command (command must be SAFE)
+ hook4 = weechat.hook_process_hashtable("sh",
+ {"arg1": "-c",
+ "arg2": "ls -l /tmp | grep something"},
+ 20000, "my_process_cb", "")
+ """
+ ...
+
+
+def hook_connect(proxy: str, address: str, port: int, ipv6: int, retry: int, local_hostname: str,
+ callback: str, callback_data: str) -> str:
+ """`hook_connect in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_connect>`_
+ ::
+
+ # example
+ def my_connect_cb(data: str, status: int, gnutls_rc: int, sock: int, error: str, ip_address: str) -> int:
+ if status == WEECHAT_HOOK_CONNECT_OK:
+ # ...
+ elif status == WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND:
+ # ...
+ elif status == WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND:
+ # ...
+ elif status == WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED:
+ # ...
+ elif status == WEECHAT_HOOK_CONNECT_PROXY_ERROR:
+ # ...
+ elif status == WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR:
+ # ...
+ elif status == WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR:
+ # ...
+ elif status == WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR:
+ # ...
+ elif status == WEECHAT_HOOK_CONNECT_MEMORY_ERROR:
+ # ...
+ elif status == WEECHAT_HOOK_CONNECT_TIMEOUT:
+ # ...
+ elif status == WEECHAT_HOOK_CONNECT_SOCKET_ERROR:
+ # ...
+ return weechat.WEECHAT_RC_OK
+
+ hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
+ "my_connect_cb", "")
+ """
+ ...
+
+
+def hook_line(buffer_type: str, buffer_name: str, tags: str, callback: str, callback_data: str) -> str:
+ """`hook_line in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_line>`_
+ ::
+
+ # example
+ def my_line_cb(data: str, line: Dict[str, str]) -> Dict[str, str]:
+ # force a highlight on the line
+ return {"highlight": "1"}
+
+ # catch lines with tag "irc_join"
+ hook = weechat.hook_line("", "", "irc_join", "my_line_cb", "")
+ """
+ ...
+
+
+def hook_print(buffer: str, tags: str, message: str, strip_colors: int, callback: str, callback_data: str) -> str:
+ """`hook_print in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_print>`_
+ ::
+
+ # example
+ def my_print_cb(data: str, buffer: str, date: str, tags: str, displayed: int, highlight: int, prefix: str, message: str) -> int:
+ if highlight:
+ # ...
+ return weechat.WEECHAT_RC_OK
+
+ # catch all messages, on all buffers, without color
+ hook = weechat.hook_print("", "", "", 1, "my_print_cb", "")
+ """
+ ...
+
+
+def hook_signal(signal: str, callback: str, callback_data: str) -> str:
+ """`hook_signal in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_signal>`_
+ ::
+
+ # example
+ def my_signal_cb(data: str, signal: str, signal_data: str) -> int:
+ # ...
+ return weechat.WEECHAT_RC_OK
+
+ # catch signals "quit" and "upgrade"
+ hook = weechat.hook_signal("quit;upgrade", "my_signal_cb", "")
+ """
+ ...
+
+
+def hook_signal_send(signal: str, type_data: str, signal_data: str) -> int:
+ """`hook_signal_send in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_signal_send>`_
+ ::
+
+ # example
+ rc = weechat.hook_signal_send("my_signal", weechat.WEECHAT_HOOK_SIGNAL_STRING, my_string)
+ """
+ ...
+
+
+def hook_hsignal(signal: str, callback: str, callback_data: str) -> str:
+ """`hook_hsignal in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_hsignal>`_
+ ::
+
+ # example
+ def my_hsignal_cb(data: str, signal: str, hashtable: Dict[str, str]) -> int:
+ # ...
+ return weechat.WEECHAT_RC_OK
+
+ hook = weechat.hook_hsignal("test", "my_hsignal_cb", "")
+ """
+ ...
+
+
+def hook_hsignal_send(signal: str, hashtable: Dict[str, str]) -> int:
+ """`hook_hsignal_send in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_hsignal_send>`_
+ ::
+
+ # example
+ rc = weechat.hook_hsignal_send("my_hsignal", {"key": "value"})
+ """
+ ...
+
+
+def hook_config(option: str, callback: str, callback_data: str) -> str:
+ """`hook_config in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_config>`_
+ ::
+
+ # example
+ def my_config_cb(data: str, option: str, value: str) -> int:
+ # ...
+ return weechat.WEECHAT_RC_OK
+
+ # catch changes to option "weechat.look.item_time_format"
+ hook = weechat.hook_config("weechat.look.item_time_format", "my_config_cb", "")
+ """
+ ...
+
+
+def hook_modifier(modifier: str, callback: str, callback_data: str) -> str:
+ """`hook_modifier in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_modifier>`_
+ ::
+
+ # example
+ def my_modifier_cb(data: str, modifier: str, modifier_data: str, string: str) -> str:
+ return "%s xxx" % string
+
+ hook = weechat.hook_modifier("weechat_print", "my_modifier_cb", "")
+ """
+ ...
+
+
+def hook_modifier_exec(modifier: str, modifier_data: str, string: str) -> str:
+ """`hook_modifier_exec in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_modifier_exec>`_
+ ::
+
+ # example
+ weechat.hook_modifier_exec("my_modifier", my_data, my_string)
+ """
+ ...
+
+
+def hook_info(info_name: str, description: str, args_description: str,
+ callback: str, callback_data: str) -> str:
+ """`hook_info in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_info>`_
+ ::
+
+ # example
+ def my_info_cb(data: str, info_name: str, arguments: str) -> str:
+ return "some_info"
+
+ hook = weechat.hook_info("my_info", "Some info", "Info about arguments",
+ "my_info_cb", "")
+ """
+ ...
+
+
+def hook_info_hashtable(info_name: str, description: str, args_description: str,
+ output_description: str, callback: str, callback_data: str) -> str:
+ """`hook_info_hashtable in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_info_hashtable>`_
+ ::
+
+ # example
+ def my_info_hashtable_cb(data: str, info_name: str, hashtable: Dict[str, str]) -> Dict[str, str]:
+ return {"test_key": "test_value"}
+
+ hook = weechat.hook_info_hashtable("my_info_hashtable", "Some info",
+ "Info about input hashtable",
+ "Info about output hashtable",
+ "my_info_hashtable_cb", "")
+ """
+ ...
+
+
+def hook_infolist(infolist_name: str, description: str, pointer_description: str,
+ args_description: str, callback: str, callback_data: str) -> str:
+ """`hook_infolist in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_infolist>`_
+ ::
+
+ # example
+ def my_infolist_cb(data: str, infolist_name: str, pointer: str, arguments: str) -> str:
+ # build infolist
+ # ...
+ return my_infolist
+
+ hook = weechat.hook_infolist("my_infolist", "Infolist with some data",
+ "Info about pointer", "Info about arguments",
+ "my_infolist_cb", "")
+ """
+ ...
+
+
+def hook_focus(area: str, callback: str, callback_data: str) -> str:
+ """`hook_focus in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_focus>`_
+ ::
+
+ # example
+ def my_focus_nicklist_cb(data: str, info: Dict[str, str]) -> Dict[str, str]:
+ # build dict
+ # ...
+ return my_dict
+
+ hook = weechat.hook_focus("buffer_nicklist", "my_focus_nicklist_cb", "")
+ """
+ ...
+
+
+def hook_set(hook: str, property: str, value: str) -> int:
+ """`hook_set in WeeChat plugin API reference <https://weechat.org/doc/api/#_hook_set>`_
+ ::
+
+ # example
+ def my_process_cb(data: str, command: str, return_code: int, out: str, err: str) -> int:
+ # ...
+ return weechat.WEECHAT_RC_OK
+
+ hook = weechat.hook_process_hashtable("/path/to/command", {"stdin": "1"},
+ 20000, "my_process_cb", "")
+ weechat.hook_set(hook, "stdin", "data sent to stdin of child process")
+ weechat.hook_set(hook, "stdin_close", "") # optional
+ """
+ ...
+
+
+def unhook(hook: str) -> int:
+ """`unhook in WeeChat plugin API reference <https://weechat.org/doc/api/#_unhook>`_
+ ::
+
+ # example
+ weechat.unhook(my_hook)
+ """
+ ...
+
+
+def unhook_all() -> int:
+ """`unhook_all in WeeChat plugin API reference <https://weechat.org/doc/api/#_unhook_all>`_
+ ::
+
+ # example
+ weechat.unhook_all()
+ """
+ ...
+
+
+def buffer_new(name: str, input_callback: str, input_callback_data: str,
+ close_callback: str, close_callback_data: str) -> str:
+ """`buffer_new in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_new>`_
+ ::
+
+ # example
+ def my_input_cb(data: str, buffer: str, input_data: str) -> int:
+ weechat.prnt(buffer, "Text: %s" % input_data)
+ return weechat.WEECHAT_RC_OK
+
+ def my_close_cb(data: str, buffer: str) -> int:
+ weechat.prnt("", "Buffer '%s' will be closed!" % weechat.buffer_get_string(buffer, "name"))
+ return weechat.WEECHAT_RC_OK
+
+ buffer = weechat.buffer_new("my_buffer", "my_input_cb", "", "my_close_cb", "")
+ """
+ ...
+
+
+def buffer_new_props(name: str, properties: Dict[str, str],
+ input_callback: str, input_callback_data: str,
+ close_callback: str, close_callback_data: str) -> str:
+ """`buffer_new_props in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_new_props>`_
+ ::
+
+ # example
+ def my_input_cb(data: str, buffer: str, input_data: str) -> int:
+ weechat.prnt(buffer, "Text: %s" % input_data)
+ return weechat.WEECHAT_RC_OK
+
+ def my_close_cb(data: str, buffer: str) -> int:
+ weechat.prnt("", "Buffer '%s' will be closed!" % weechat.buffer_get_string(buffer, "name"))
+ return weechat.WEECHAT_RC_OK
+
+ properties = {
+ "type": "free", # buffer with free content
+ "localvar_set_no_log": "1", # no logging on this buffer
+ "key_bind_meta-c": "/my_command", # bind key alt-c on this buffer
+ }
+ buffer = weechat.buffer_new_props("my_buffer", properties, "my_input_cb", "", "my_close_cb", "")
+ """
+ ...
+
+
+def current_buffer() -> str:
+ """`current_buffer in WeeChat plugin API reference <https://weechat.org/doc/api/#_current_buffer>`_
+ ::
+
+ # example
+ weechat.prnt(weechat.current_buffer(), "Text on current buffer")
+ """
+ ...
+
+
+def buffer_search(plugin: str, name: str) -> str:
+ """`buffer_search in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_search>`_
+ ::
+
+ # example
+ buffer = weechat.buffer_search("my_plugin", "my_buffer")
+ """
+ ...
+
+
+def buffer_search_main() -> str:
+ """`buffer_search_main in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_search_main>`_
+ ::
+
+ # example
+ buffer = weechat.buffer_search_main()
+ """
+ ...
+
+
+def buffer_clear(buffer: str) -> int:
+ """`buffer_clear in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_clear>`_
+ ::
+
+ # example
+ buffer = weechat.buffer_search("my_plugin", "my_buffer")
+ if buffer:
+ weechat.buffer_clear(buffer)
+ """
+ ...
+
+
+def buffer_close(buffer: str) -> int:
+ """`buffer_close in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_close>`_
+ ::
+
+ # example
+ buffer = weechat.buffer_new("my_buffer", "my_input_cb", "", "my_close_cb", "")
+ # ...
+ weechat.buffer_close(buffer)
+ """
+ ...
+
+
+def buffer_merge(buffer: str, target_buffer: str) -> int:
+ """`buffer_merge in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_merge>`_
+ ::
+
+ # example
+ # merge current buffer with WeeChat "core" buffer
+ weechat.buffer_merge(weechat.current_buffer(), weechat.buffer_search_main())
+ """
+ ...
+
+
+def buffer_unmerge(buffer: str, number: int) -> int:
+ """`buffer_unmerge in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_unmerge>`_
+ ::
+
+ # example
+ weechat.buffer_unmerge(weechat.current_buffer(), 1)
+ """
+ ...
+
+
+def buffer_get_integer(buffer: str, property: str) -> int:
+ """`buffer_get_integer in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_get_integer>`_
+ ::
+
+ # example
+ weechat.prnt("", "my buffer number is: %d" % weechat.buffer_get_integer(my_buffer, "number"))
+ """
+ ...
+
+
+def buffer_get_string(buffer: str, property: str) -> str:
+ """`buffer_get_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_get_string>`_
+ ::
+
+ # example
+ weechat.prnt("", "name / short name of buffer are: %s / %s"
+ % (weechat.buffer_get_string(my_buffer, "name"),
+ weechat.buffer_get_string(my_buffer, "short_name")))
+ """
+ ...
+
+
+def buffer_get_pointer(buffer: str, property: str) -> str:
+ """`buffer_get_pointer in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_get_pointer>`_
+ ::
+
+ # example
+ weechat.prnt("", "plugin pointer of my buffer: %s" % weechat.buffer_get_pointer(my_buffer, "plugin"))
+ """
+ ...
+
+
+def buffer_set(buffer: str, property: str, value: str) -> int:
+ """`buffer_set in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_set>`_
+ ::
+
+ # examples
+
+ # disable hotlist (for all buffers)
+ weechat.buffer_set("", "hotlist", "-")
+
+ # enable again hotlist
+ weechat.buffer_set("", "hotlist", "+")
+
+ # change buffer name
+ weechat.buffer_set(my_buffer, "name", "my_new_name")
+
+ # add new local variable "toto" with value "abc"
+ weechat.buffer_set(my_buffer, "localvar_set_toto", "abc")
+
+ # remove local variable "toto"
+ weechat.buffer_set(my_buffer, "localvar_del_toto", "")
+ """
+ ...
+
+
+def buffer_string_replace_local_var(buffer: str, string: str) -> str:
+ """`buffer_string_replace_local_var in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_string_replace_local_var>`_
+ ::
+
+ # example
+ weechat.buffer_set(my_buffer, "localvar_set_toto", "abc")
+ str = weechat.buffer_string_replace_local_var(my_buffer, "test with $toto")
+ # str contains "test with abc"
+ """
+ ...
+
+
+def buffer_match_list(buffer: str, string: str) -> int:
+ """`buffer_match_list in WeeChat plugin API reference <https://weechat.org/doc/api/#_buffer_match_list>`_
+ ::
+
+ # example
+ buffer = weechat.buffer_search("irc", "libera.#weechat")
+ if buffer:
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*")) # 1
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "*,!*#weechat*")) # 0
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.libera.*")) # 1
+ weechat.prnt("", "%d" % weechat.buffer_match_list(buffer, "irc.oftc.*,python.*")) # 0
+ """
+ ...
+
+
+def current_window() -> str:
+ """`current_window in WeeChat plugin API reference <https://weechat.org/doc/api/#_current_window>`_
+ ::
+
+ # example
+ current_window = weechat.current_window()
+ """
+ ...
+
+
+def window_search_with_buffer(buffer: str) -> str:
+ """`window_search_with_buffer in WeeChat plugin API reference <https://weechat.org/doc/api/#_window_search_with_buffer>`_
+ ::
+
+ # example
+ weechat.prnt("", "window displaying core buffer: %s"
+ % weechat.window_search_with_buffer(weechat.buffer_search_main()))
+ """
+ ...
+
+
+def window_get_integer(window: str, property: str) -> int:
+ """`window_get_integer in WeeChat plugin API reference <https://weechat.org/doc/api/#_window_get_integer>`_
+ ::
+
+ # example
+ weechat.prnt("", "current window is at position (x,y): (%d,%d)"
+ % (weechat.window_get_integer(weechat.current_window(), "win_x"),
+ weechat.window_get_integer(weechat.current_window(), "win_y")))
+ """
+ ...
+
+
+def window_get_string(window: str, property: str) -> str:
+ """`window_get_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_window_get_string>`_
+ """
+ ...
+
+
+def window_get_pointer(window: str, property: str) -> str:
+ """`window_get_pointer in WeeChat plugin API reference <https://weechat.org/doc/api/#_window_get_pointer>`_
+ ::
+
+ # example
+ weechat.prnt("", "buffer displayed in current window: %s"
+ % weechat.window_get_pointer(weechat.current_window(), "buffer"))
+ """
+ ...
+
+
+def window_set_title(title: str) -> int:
+ """`window_set_title in WeeChat plugin API reference <https://weechat.org/doc/api/#_window_set_title>`_
+ ::
+
+ # example
+ weechat.window_set_title("new title here")
+ """
+ ...
+
+
+def nicklist_add_group(buffer: str, parent_group: str, name: str, color: str, visible: int) -> str:
+ """`nicklist_add_group in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_add_group>`_
+ ::
+
+ # example
+ group = weechat.nicklist_add_group(my_buffer, my_parent_group, "test_group",
+ "weechat.color.nicklist_group", 1)
+ """
+ ...
+
+
+def nicklist_search_group(buffer: str, from_group: str, name: str) -> str:
+ """`nicklist_search_group in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_search_group>`_
+ ::
+
+ # example
+ group = weechat.nicklist_search_group(my_buffer, "", "test_group")
+ """
+ ...
+
+
+def nicklist_add_nick(buffer: str, group: str, name: str, color: str, prefix: str, prefix_color: str, visible: int) -> str:
+ """`nicklist_add_nick in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_add_nick>`_
+ ::
+
+ # example
+ if nick_away:
+ color = "weechat.color.nicklist_away"
+ else:
+ color = "bar_fg"
+ nick = weechat.nicklist_add_nick(my_buffer, my_group, "test_nick", color, "@", "lightgreen", 1)
+ """
+ ...
+
+
+def nicklist_search_nick(buffer: str, from_group: str, name: str) -> str:
+ """`nicklist_search_nick in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_search_nick>`_
+ ::
+
+ # example
+ nick = weechat.nicklist_search_nick(my_buffer, "", "test_nick")
+ """
+ ...
+
+
+def nicklist_remove_group(buffer: str, group: str) -> int:
+ """`nicklist_remove_group in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_remove_group>`_
+ ::
+
+ # example
+ weechat.nicklist_remove_group(my_buffer, my_group)
+ """
+ ...
+
+
+def nicklist_remove_nick(buffer: str, nick: str) -> int:
+ """`nicklist_remove_nick in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_remove_nick>`_
+ ::
+
+ # example
+ weechat.nicklist_remove_nick(my_buffer, my_nick)
+ """
+ ...
+
+
+def nicklist_remove_all(buffer: str) -> int:
+ """`nicklist_remove_all in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_remove_all>`_
+ ::
+
+ # example
+ weechat.nicklist_remove_all(my_buffer)
+ """
+ ...
+
+
+def nicklist_group_get_integer(buffer: str, group: str, property: str) -> int:
+ """`nicklist_group_get_integer in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_group_get_integer>`_
+ ::
+
+ # example
+ visible = weechat.nicklist_group_get_integer(buffer, group, "visible")
+ """
+ ...
+
+
+def nicklist_group_get_string(buffer: str, group: str, property: str) -> str:
+ """`nicklist_group_get_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_group_get_string>`_
+ ::
+
+ # example
+ color = weechat.nicklist_group_get_string(buffer, group, "color")
+ """
+ ...
+
+
+def nicklist_group_get_pointer(buffer: str, group: str, property: str) -> str:
+ """`nicklist_group_get_pointer in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_group_get_pointer>`_
+ ::
+
+ # example
+ parent = weechat.nicklist_group_get_pointer(buffer, group, "parent")
+ """
+ ...
+
+
+def nicklist_group_set(buffer: str, group: str, property: str, value: str) -> int:
+ """`nicklist_group_set in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_group_set>`_
+ ::
+
+ # examples
+
+ # change group color to "bar_fg"
+ weechat.nicklist_group_set(buffer, group, "color", "bar_fg")
+
+ # change group color to yellow
+ weechat.nicklist_group_set(buffer, group, "color", "yellow")
+
+ # hide group in nicklist
+ weechat.nicklist_group_set(buffer, group, "visible", "0")
+ """
+ ...
+
+
+def nicklist_nick_get_integer(buffer: str, nick: str, property: str) -> int:
+ """`nicklist_nick_get_integer in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_nick_get_integer>`_
+ ::
+
+ # example
+ visible = weechat.nicklist_nick_get_integer(buffer, nick, "visible")
+ """
+ ...
+
+
+def nicklist_nick_get_string(buffer: str, nick: str, property: str) -> str:
+ """`nicklist_nick_get_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_nick_get_string>`_
+ ::
+
+ # example
+ color = weechat.nicklist_nick_get_string(buffer, nick, "color")
+ """
+ ...
+
+
+def nicklist_nick_get_pointer(buffer: str, nick: str, property: str) -> str:
+ """`nicklist_nick_get_pointer in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_nick_get_pointer>`_
+ ::
+
+ # example
+ group = weechat.nicklist_nick_get_pointer(buffer, nick, "group")
+ """
+ ...
+
+
+def nicklist_nick_set(buffer: str, nick: str, property: str, value: str) -> int:
+ """`nicklist_nick_set in WeeChat plugin API reference <https://weechat.org/doc/api/#_nicklist_nick_set>`_
+ ::
+
+ # examples
+
+ # change nick color to cyan
+ weechat.nicklist_nick_set(buffer, nick, "color", "cyan")
+
+ # change prefix to "+"
+ weechat.nicklist_nick_set(buffer, nick, "prefix", "+")
+
+ # change prefix color to yellow
+ weechat.nicklist_nick_set(buffer, nick, "prefix_color", "yellow")
+
+ # hide nick in nicklist
+ weechat.nicklist_nick_set(buffer, nick, "visible", "0")
+ """
+ ...
+
+
+def bar_item_search(name: str) -> str:
+ """`bar_item_search in WeeChat plugin API reference <https://weechat.org/doc/api/#_bar_item_search>`_
+ ::
+
+ # example
+ bar_item = weechat.bar_item_search("myitem")
+ """
+ ...
+
+
+def bar_item_new(name: str, build_callback: str, build_callback_data: str) -> str:
+ """`bar_item_new in WeeChat plugin API reference <https://weechat.org/doc/api/#_bar_item_new>`_
+ ::
+
+ # example (callback without "buffer" and "extra_info")
+ def my_build_callback(data: str, item: str, window: str) -> str:
+ return "my content"
+
+ bar_item = weechat.bar_item_new("myitem", "my_build_callback", "")
+
+ # example (callback with all arguments, for WeeChat ≥ 0.4.2)
+ def my_build_callback2(data: str, item: str, window: str, buffer: str, extra_info: Dict[str, str]) -> str:
+ return "my content"
+
+ bar_item2 = weechat.bar_item_new("(extra)myitem2", "my_build_callback2", "") # WeeChat ≥ 0.4.2
+ """
+ ...
+
+
+def bar_item_update(name: str) -> int:
+ """`bar_item_update in WeeChat plugin API reference <https://weechat.org/doc/api/#_bar_item_update>`_
+ ::
+
+ # example
+ weechat.bar_item_update("myitem")
+ """
+ ...
+
+
+def bar_item_remove(item: str) -> int:
+ """`bar_item_remove in WeeChat plugin API reference <https://weechat.org/doc/api/#_bar_item_remove>`_
+ ::
+
+ # example
+ weechat.bar_item_remove(myitem)
+ """
+ ...
+
+
+def bar_search(name: str) -> str:
+ """`bar_search in WeeChat plugin API reference <https://weechat.org/doc/api/#_bar_search>`_
+ ::
+
+ # example
+ bar = weechat.bar_search("mybar")
+ """
+ ...
+
+
+def bar_new(name: str, hidden: str, priority: str, type: str, condition: str, position: str,
+ filling_top_bottom: str, filling_left_right: str, size: str, size_max: str,
+ color_fg: str, color_delim: str, color_bg: str, color_bg_inactive: str,
+ separator: str, items: str) -> str:
+ """`bar_new in WeeChat plugin API reference <https://weechat.org/doc/api/#_bar_new>`_
+ ::
+
+ # example
+ bar = weechat.bar_new("mybar", "off", "100", "window", "", "top", "horizontal", "vertical",
+ "0", "5", "default", "cyan", "blue", "darkgray", "off", "time,buffer_number+buffer_name")
+ """
+ ...
+
+
+def bar_set(bar: str, property: str, value: str) -> int:
+ """`bar_set in WeeChat plugin API reference <https://weechat.org/doc/api/#_bar_set>`_
+ ::
+
+ # example
+ weechat.bar_set(my_bar, "position", "bottom")
+ """
+ ...
+
+
+def bar_update(name: str) -> int:
+ """`bar_update in WeeChat plugin API reference <https://weechat.org/doc/api/#_bar_update>`_
+ ::
+
+ # example
+ weechat.bar_update("mybar")
+ """
+ ...
+
+
+def bar_remove(bar: str) -> int:
+ """`bar_remove in WeeChat plugin API reference <https://weechat.org/doc/api/#_bar_remove>`_
+ ::
+
+ # example
+ weechat.bar_remove(my_bar)
+ """
+ ...
+
+
+def command(buffer: str, command: str) -> int:
+ """`command in WeeChat plugin API reference <https://weechat.org/doc/api/#_command>`_
+ ::
+
+ # example
+ rc = weechat.command(weechat.buffer_search("irc", "libera.#weechat"), "/whois FlashCode")
+ """
+ ...
+
+
+def command_options(buffer: str, command: str, options: Dict[str, str]) -> int:
+ """`command_options in WeeChat plugin API reference <https://weechat.org/doc/api/#_command_options>`_
+ ::
+
+ # example: allow any command except /exec
+ rc = weechat.command("", "/some_command arguments", {"commands": "*,!exec"})
+ """
+ ...
+
+
+def completion_new(buffer: str) -> str:
+ """`completion_new in WeeChat plugin API reference <https://weechat.org/doc/api/#_completion_new>`_
+ ::
+
+ # example
+ completion = weechat.completion_new(weechat.buffer_search_main())
+ """
+ ...
+
+
+def completion_search(completion: str, data: str, position: int, direction: int) -> int:
+ """`completion_search in WeeChat plugin API reference <https://weechat.org/doc/api/#_completion_search>`_
+ ::
+
+ # example
+ completion = weechat.completion_new(weechat.buffer_search_main())
+ if weechat.completion_search(completion, "/help filt", 10, 1):
+ # ...
+ """
+ ...
+
+
+def completion_get_string(completion: str, property: str) -> str:
+ """`completion_get_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_completion_get_string>`_
+ ::
+
+ # example
+ def my_completion_cb(data: str, completion_item: str, buffer: str, completion: str) -> int:
+ # get arguments of command
+ args = weechat.completion_get_string(completion, "args")
+ # completion depending on args
+ # ...
+ return weechat.WEECHAT_RC_OK
+ """
+ ...
+
+
+def completion_list_add(completion: str, word: str, nick_completion: int, where: str) -> int:
+ """`completion_list_add in WeeChat plugin API reference <https://weechat.org/doc/api/#_completion_list_add>`_
+ ::
+
+ # example: see function hook_completion
+ """
+ ...
+
+
+def completion_free(completion: str) -> int:
+ """`completion_free in WeeChat plugin API reference <https://weechat.org/doc/api/#_completion_free>`_
+ ::
+
+ # example
+ weechat.completion_free(completion)
+ """
+ ...
+
+
+def info_get(info_name: str, arguments: str) -> str:
+ """`info_get in WeeChat plugin API reference <https://weechat.org/doc/api/#_info_get>`_
+ ::
+
+ # example
+ weechat.prnt("", "Current WeeChat version is: %s (compiled on %s)"
+ % (weechat.info_get("version", ""), weechat.info_get("date", ""))
+ weechat.prnt("", "WeeChat config directory is: %s" % weechat.info_get("weechat_config_dir", ""))
+ """
+ ...
+
+
+def info_get_hashtable(info_name: str, dict_in: Dict[str, str]) -> Dict[str, str]:
+ """`info_get_hashtable in WeeChat plugin API reference <https://weechat.org/doc/api/#_info_get_hashtable>`_
+ ::
+
+ # example
+ dict_in = {"message": ":nick!user@host PRIVMSG #weechat :message here"}
+ weechat.prnt("", "message parsed: %s"
+ % weechat.info_get_hashtable("irc_message_parse", dict_in))
+ """
+ ...
+
+
+def infolist_new() -> str:
+ """`infolist_new in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_new>`_
+ ::
+
+ # example
+ infolist = weechat.infolist_new()
+ """
+ ...
+
+
+def infolist_new_item(infolist: str) -> str:
+ """`infolist_new_item in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_new_item>`_
+ ::
+
+ # example
+ item = weechat.infolist_new_item(infolist)
+ """
+ ...
+
+
+def infolist_new_var_integer(item: str, name: str, value: int) -> str:
+ """`infolist_new_var_integer in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_new_var_integer>`_
+ ::
+
+ # example
+ var = weechat.infolist_new_var_integer(item, "my_integer", 123)
+ """
+ ...
+
+
+def infolist_new_var_string(item: str, name: str, value: str) -> str:
+ """`infolist_new_var_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_new_var_string>`_
+ ::
+
+ # example
+ var = weechat.infolist_new_var_string(item, "my_string", "value")
+ """
+ ...
+
+
+def infolist_new_var_pointer(item: str, name: str, pointer: str) -> str:
+ """`infolist_new_var_pointer in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_new_var_pointer>`_
+ ::
+
+ # example
+ var = weechat.infolist_new_var_pointer(item, "my_pointer", pointer)
+ """
+ ...
+
+
+def infolist_new_var_time(item: str, name: str, time: int) -> str:
+ """`infolist_new_var_time in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_new_var_time>`_
+ ::
+
+ # example
+ var = weechat.infolist_new_var_time(item, "my_time", int(time.time()))
+ """
+ ...
+
+
+def infolist_get(infolist_name: str, pointer: str, arguments: str) -> str:
+ """`infolist_get in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_get>`_
+ ::
+
+ # example
+ infolist = weechat.infolist_get("irc_server", "", "")
+ """
+ ...
+
+
+def infolist_next(infolist: str) -> int:
+ """`infolist_next in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_next>`_
+ ::
+
+ # example
+ rc = weechat.infolist_next(infolist)
+ if rc:
+ # read variables in item...
+ else:
+ # no more item available
+ """
+ ...
+
+
+def infolist_prev(infolist: str) -> int:
+ """`infolist_prev in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_prev>`_
+ ::
+
+ # example
+ rc = weechat.infolist_prev(infolist)
+ if rc:
+ # read variables in item...
+ else:
+ # no more item available
+ """
+ ...
+
+
+def infolist_reset_item_cursor(infolist: str) -> int:
+ """`infolist_reset_item_cursor in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_reset_item_cursor>`_
+ ::
+
+ # example
+ weechat.infolist_reset_item_cursor(infolist)
+ """
+ ...
+
+
+def infolist_search_var(infolist: str, name: str) -> str:
+ """`infolist_search_var in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_search_var>`_
+ ::
+
+ # example
+ if weechat.infolist_search_var(infolist, "name"):
+ # variable "name" exists
+ # ...
+ """
+ ...
+
+
+def infolist_fields(infolist: str) -> str:
+ """`infolist_fields in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_fields>`_
+ ::
+
+ # example
+ fields = weechat.infolist_fields(infolist)
+ # fields contains something like:
+ # "i:my_integer,s:my_string,p:my_pointer,b:my_buffer,t:my_time"
+ """
+ ...
+
+
+def infolist_integer(infolist: str, var: str) -> int:
+ """`infolist_integer in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_integer>`_
+ ::
+
+ # example
+ weechat.prnt("", "integer = %d" % weechat.infolist_integer(infolist, "my_integer"))
+ """
+ ...
+
+
+def infolist_string(infolist: str, var: str) -> str:
+ """`infolist_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_string>`_
+ ::
+
+ # example
+ weechat.prnt("", "string = %s" % weechat.infolist_string(infolist, "my_string"))
+ """
+ ...
+
+
+def infolist_pointer(infolist: str, var: str) -> str:
+ """`infolist_pointer in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_pointer>`_
+ ::
+
+ # example
+ weechat.prnt("", "pointer = 0x%s" % weechat.infolist_pointer(infolist, "my_pointer"))
+ """
+ ...
+
+
+def infolist_time(infolist: str, var: str) -> int:
+ """`infolist_time in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_time>`_
+ ::
+
+ # example
+ weechat.prnt("", "time = %ld" % weechat.infolist_time(infolist, "my_time"))
+ """
+ ...
+
+
+def infolist_free(infolist: str) -> int:
+ """`infolist_free in WeeChat plugin API reference <https://weechat.org/doc/api/#_infolist_free>`_
+ ::
+
+ # example
+ weechat.infolist_free(infolist)
+ """
+ ...
+
+
+def hdata_get(hdata_name: str) -> str:
+ """`hdata_get in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_get>`_
+ ::
+
+ # example
+ hdata = weechat.hdata_get("irc_server")
+ """
+ ...
+
+
+def hdata_get_var_offset(hdata: str, name: str) -> int:
+ """`hdata_get_var_offset in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_get_var_offset>`_
+ ::
+
+ # example
+ offset = weechat.hdata_get_var_offset(hdata, "name")
+ """
+ ...
+
+
+def hdata_get_var_type_string(hdata: str, name: str) -> str:
+ """`hdata_get_var_type_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_get_var_type_string>`_
+ ::
+
+ # example
+ weechat.prnt("", "type = %s" % weechat.hdata_get_var_type_string("name"))
+ """
+ ...
+
+
+def hdata_get_var_array_size(hdata: str, pointer: str, name: str) -> int:
+ """`hdata_get_var_array_size in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_get_var_array_size>`_
+ ::
+
+ # example
+ array_size = weechat.hdata_get_var_array_size(hdata, pointer, "name")
+ """
+ ...
+
+
+def hdata_get_var_array_size_string(hdata: str, pointer: str, name: str) -> str:
+ """`hdata_get_var_array_size_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_get_var_array_size_string>`_
+ ::
+
+ # example
+ array_size = weechat.hdata_get_var_array_size_string(hdata, pointer, "name")
+ """
+ ...
+
+
+def hdata_get_var_hdata(hdata: str, name: str) -> str:
+ """`hdata_get_var_hdata in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_get_var_hdata>`_
+ ::
+
+ # example
+ weechat.prnt("", "hdata = %s" % weechat.hdata_get_var_hdata(hdata, "name"))
+ """
+ ...
+
+
+def hdata_get_list(hdata: str, name: str) -> str:
+ """`hdata_get_list in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_get_list>`_
+ ::
+
+ # example
+ hdata = weechat.hdata_get("buffer")
+ buffers = weechat.hdata_get_list(hdata, "gui_buffers")
+ """
+ ...
+
+
+def hdata_check_pointer(hdata: str, list: str, pointer: str) -> int:
+ """`hdata_check_pointer in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_check_pointer>`_
+ ::
+
+ # example
+ hdata = weechat.hdata_get("buffer")
+ if weechat.hdata_check_pointer(hdata, weechat.hdata_get_list(hdata, "gui_buffers"), ptr_buffer):
+ # valid pointer
+ # ...
+ else:
+ # invalid pointer
+ # ...
+ """
+ ...
+
+
+def hdata_move(hdata: str, pointer: str, count: int) -> str:
+ """`hdata_move in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_move>`_
+ ::
+
+ # example
+ hdata = weechat.hdata_get("buffer")
+ buffer = weechat.buffer_search_main()
+
+ # move to next buffer, 2 times
+ buffer = weechat.hdata_move(hdata, buffer, 2)
+
+ # move to previous buffer
+ if buffer:
+ buffer = weechat.hdata_move(hdata, buffer, -1)
+ """
+ ...
+
+
+def hdata_search(hdata: str, pointer: str, search: str,
+ pointers: Dict[str, str], extra_vars: Dict[str, str], options: Dict[str, str],
+ count: int) -> str:
+ """`hdata_search in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_search>`_
+ ::
+
+ # example
+ hdata = weechat.hdata_get("irc_server")
+ servers = weechat.hdata_get_list(hdata, "irc_servers")
+
+ # search irc server with name "libera"
+ server = weechat.hdata_search(hdata, servers, "${irc_server.name} == ${server_name}",
+ {}, {"server_name": "libera"}, {}, 1)
+ if server:
+ # ...
+ """
+ ...
+
+
+def hdata_char(hdata: str, pointer: str, name: str) -> int:
+ """`hdata_char in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_char>`_
+ ::
+
+ # example
+ weechat.prnt("", "letter = %c" % weechat.hdata_char(hdata, pointer, "letter"))
+ """
+ ...
+
+
+def hdata_integer(hdata: str, pointer: str, name: str) -> int:
+ """`hdata_integer in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_integer>`_
+ ::
+
+ # example
+ hdata = weechat.hdata_get("buffer")
+ buffer = weechat.buffer_search_main()
+ weechat.prnt("", "number = %d" % weechat.hdata_integer(hdata, buffer, "number"))
+ """
+ ...
+
+
+def hdata_long(hdata: str, pointer: str, name: str) -> int:
+ """`hdata_long in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_long>`_
+ ::
+
+ # example
+ weechat.prnt("", "longvar = %ld" % weechat.hdata_long(hdata, pointer, "longvar"))
+ """
+ ...
+
+
+def hdata_string(hdata: str, pointer: str, name: str) -> str:
+ """`hdata_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_string>`_
+ ::
+
+ # example
+ hdata = weechat.hdata_get("buffer")
+ buffer = weechat.buffer_search_main()
+ weechat.prnt("", "name = %s" % weechat.hdata_string(hdata, buffer, "name"))
+ """
+ ...
+
+
+def hdata_pointer(hdata: str, pointer: str, name: str) -> str:
+ """`hdata_pointer in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_pointer>`_
+ ::
+
+ # example
+ hdata = weechat.hdata_get("buffer")
+ buffer = weechat.buffer_search_main()
+ weechat.prnt("", "lines = %lx" % weechat.hdata_pointer(hdata, buffer, "lines"))
+ """
+ ...
+
+
+def hdata_time(hdata: str, pointer: str, name: str) -> int:
+ """`hdata_time in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_time>`_
+ ::
+
+ # example
+ buf = weechat.buffer_search_main()
+ ptr = weechat.hdata_pointer(weechat.hdata_get("buffer"), buf, "lines")
+ if ptr:
+ ptr = weechat.hdata_pointer(weechat.hdata_get("lines"), ptr, "first_line")
+ if ptr:
+ ptr = weechat.hdata_pointer(weechat.hdata_get("line"), ptr, "data")
+ if ptr:
+ date = weechat.hdata_time(weechat.hdata_get("line_data"), ptr, "date")
+ weechat.prnt("", "time of first line displayed = %s" % time.strftime("%F %T", time.localtime(int(date))))
+ """
+ ...
+
+
+def hdata_hashtable(hdata: str, pointer: str, name: str) -> Dict[str, str]:
+ """`hdata_hashtable in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_hashtable>`_
+ ::
+
+ # example
+ hdata = weechat.hdata_get("buffer")
+ buffer = weechat.buffer_search_main()
+ hash = weechat.hdata_hashtable(hdata, buffer, "local_variables")
+ weechat.prnt("", "local variables in core buffer:")
+ for key in hash:
+ weechat.prnt("", " %s == %s" % (key, hash[key]))
+ """
+ ...
+
+
+def hdata_compare(hdata: str, pointer1: str, pointer2: str, name: str, case_sensitive: int) -> int:
+ """`hdata_compare in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_compare>`_
+ ::
+
+ # example
+ hdata = weechat.hdata_get("buffer")
+ buffer1 = weechat.buffer_search("irc", "libera.#weechat")
+ buffer2 = weechat.buffer_search("irc", "libera.#weechat-fr")
+ weechat.prnt("", "number comparison = %d" % weechat.hdata_compare(hdata, buffer1, buffer2, "number", 0))
+ """
+ ...
+
+
+def hdata_update(hdata: str, pointer: str, hashtable: Dict[str, str]) -> int:
+ """`hdata_update in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_update>`_
+ ::
+
+ # example: subtract one hour on last message displayed in current buffer
+ own_lines = weechat.hdata_pointer(weechat.hdata_get("buffer"), weechat.current_buffer(), "own_lines")
+ if own_lines:
+ line = weechat.hdata_pointer(weechat.hdata_get("lines"), own_lines, "last_line")
+ if line:
+ line_data = weechat.hdata_pointer(weechat.hdata_get("line"), line, "data")
+ hdata = weechat.hdata_get("line_data")
+ weechat.hdata_update(hdata, line_data, {"date": str(weechat.hdata_time(hdata, line_data, "date") - 3600)})
+ """
+ ...
+
+
+def hdata_get_string(hdata: str, property: str) -> str:
+ """`hdata_get_string in WeeChat plugin API reference <https://weechat.org/doc/api/#_hdata_get_string>`_
+ ::
+
+ # example
+ weechat.prnt("", "variables in hdata: %s" % weechat.hdata_get_string(hdata, "var_keys"))
+ weechat.prnt("", "lists in hdata: %s" % weechat.hdata_get_string(hdata, "list_keys"))
+ """
+ ...
+
+
+def upgrade_new(filename: str, callback_read: str, callback_read_data: str) -> str:
+ """`upgrade_new in WeeChat plugin API reference <https://weechat.org/doc/api/#_upgrade_new>`_
+ ::
+
+ # example
+ upgrade_file = weechat.upgrade_new("my_file", "", "")
+ """
+ ...
+
+
+def upgrade_write_object(upgrade_file: str, object_id: int, infolist: str) -> int:
+ """`upgrade_write_object in WeeChat plugin API reference <https://weechat.org/doc/api/#_upgrade_write_object>`_
+ ::
+
+ # example
+ weechat.upgrade_write_object(upgrade_file, 1, infolist)
+ """
+ ...
+
+
+def upgrade_read(upgrade_file: str) -> int:
+ """`upgrade_read in WeeChat plugin API reference <https://weechat.org/doc/api/#_upgrade_read>`_
+ ::
+
+ # example
+ weechat.upgrade_read(upgrade_file)
+ """
+ ...
+
+
+def upgrade_close(upgrade_file: str) -> int:
+ """`upgrade_close in WeeChat plugin API reference <https://weechat.org/doc/api/#_upgrade_close>`_
+ ::
+
+ # example
+ weechat.upgrade_close(upgrade_file)
+ """
+ ...