I decided to write this because IRC bot written in Squirrel is buggy. And I don't like reinventing the wheel. So I choose Python since it has many useful libraries.
An IRC bot sample: https://gist.github.com/ysc3839/76418598bb6dd907c227bc7487fe269d
Unlike other plugins, this plugin exposes original functions to Python. Peoples can warp the functions as they like.
Project repository:
https://github.com/ysc3839/vcmp-python-plugin
Test code:
https://github.com/ysc3839/vcmp-python-test
1.0 released: https://github.com/ysc3839/vcmp-python-plugin/releases/tag/v1.0
Note: You may need to rename this plugin because the server can't take long filename.
Heh, wanted to do this myself a few days ago when I looked at the state of that binding library. But then I realized I hate Python's syntax :D
Quote from: . on Aug 26, 2017, 11:06 AMHeh, wanted to do this myself a few days ago when I looked at the state of that binding library. But then I realized I hate Python's syntax :D
Nice Name
Version 1.0 released. Only 64 bit builds now.
https://github.com/ysc3839/vcmp-python-plugin/releases/tag/v1.0
Test code:
https://github.com/ysc3839/vcmp-python-test
Good luck with this project!
Note: You may need to rename this plugin because the server can't take long filename.
31 characters length.
Plugin error >> dlopen() 'plugins/vcmp-python-plugin-cpy36-linux6.so' failed: plugins/vcmp-python-plugin-cpy36-linux6.so: cannot open shared object file: No such file or directory
Failed to load plugin: vcmp-python-plugin-cpy36-linux6
1.0.2 released: download (https://github.com/ysc3839/vcmp-python-plugin/releases/tag/v1.0.2)
This version compatible with 04rel004.
If you call new functions it will raise "NotImplementedError: server does not implement this function".
And new callbacks do not exist.
Changed output name to vcmp-python-plugin-cpyxx-(rel/dbg)(32/64).
Added automated builds.
Linux (https://ci.appveyor.com/project/ysc3839/vcmp-python-plugin/build/1/job/2cj10pf564d08igr/artifacts) Windows (https://ci.appveyor.com/project/ysc3839/vcmp-python-plugin/build/1/job/a10pm3fb5epe5sye/artifacts)
No 32 bit builds for Linux.
Version 1.0.4:
- Python error message will log to server_log.txt.
- The plugin will read "pymodule" from both "server.cfg" and "server32/64.cfg".
Download: Linux (https://ci.appveyor.com/project/ysc3839/vcmp-python-plugin/build/3/job/q2irkc0ojyu9kocc/artifacts) Windows (https://ci.appveyor.com/project/ysc3839/vcmp-python-plugin/build/3/job/oj7i7g4dl48sghgt/artifacts)
Add python type hints stub files (.pyi).
https://github.com/ysc3839/vcmp-python-plugin/commit/4ae6ea2c5e6c9e29621f1de0927b9ff7bf820047
IDEs or editors can read type informations from these files and will not show an "unable to import" error.
If you are using vscode, you need to disable "python.jediEnabled" because jedi ignores .pyi files, or rename .pyi to .py.
Version 1.0.5:
- Fix error message being truncated.
Download: https://github.com/ysc3839/vcmp-python-plugin/releases/tag/v1.0.5
Quick question,
@ysc3839 . Would it be possible for a Squirrel script and a Python script to communicate back to each other? Let's say I want to do an operation on Python by accessing one of the libraries from my Squirrel script. Would this be okay?
@DarkRaZoR^ #11 Yes it's possible.
VCMP has built-in functions for plugin communication. However the squirrel plugin doesn't implement such function.
So available options are:
- Modify squirrel plugin to implement this function.
- Make another plugin as squirrel extension to implement this function.
- Use another communication mechanism. For example: network.
I think the last one is easiest. There's a socket plugin for squirrel.
Quote from: ysc3839 on Mar 13, 2019, 04:44 PM@DarkRaZoR^ #11 Yes it's possible.
VCMP has built-in functions for plugin communication. However the squirrel plugin doesn't implement such function.
So available options are:
- Modify squirrel plugin to implement this function.
- Make another plugin as squirrel extension to implement this function.
- Use another communication mechanism. For example: network.
I think the last one is easiest. There's a socket plugin for squirrel.
How would I send information from the Squirrel script to the Python script, with the usage of sockets? I have never messed with Unix sockets before. :o Is there a socket library for Python?
Quote from: DarkRaZoR^ on Mar 13, 2019, 07:30 PMQuote from: ysc3839 on Mar 13, 2019, 04:44 PM@DarkRaZoR^ #11 Yes it's possible.
VCMP has built-in functions for plugin communication. However the squirrel plugin doesn't implement such function.
So available options are:
- Modify squirrel plugin to implement this function.
- Make another plugin as squirrel extension to implement this function.
- Use another communication mechanism. For example: network.
I think the last one is easiest. There's a socket plugin for squirrel.
How would I send information from the Squirrel script to the Python script, with the usage of sockets? I have never messed with Unix sockets before. :o Is there a socket library for Python?
Yes. The "socket" package. Further discussion of this should probably take place elsewhere as this subforum is not meant for programming help.