Python plugin

Started by ysc3839, Aug 26, 2017, 10:38 AM

Previous topic - Next topic

ysc3839

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
.

Mahmoud Tornado

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

ysc3839


ℛḝξ☂

Good luck with this project!
I may be a slow walker but I am always walking.

ysc3839

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

ysc3839

1.0.2 released: download

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).

ysc3839

#7
Added automated builds.
Linux Windows
No 32 bit builds for Linux.

ysc3839

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 Windows

ysc3839

#9
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.

ysc3839


D4rkR420R

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?

ysc3839

@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.

D4rkR420R

#13
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?

dracc

Quote from: DarkRaZoR^ on Mar 13, 2019, 07:30 PM
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?

Yes. The "socket" package. Further discussion of this should probably take place elsewhere as this subforum is not meant for programming help.