Upgrade for the PhBot API

Hello Community, Hello Ryan,

im an enthusiastic Plugin Developer and have a suggestion/request.

Im currently trying some rather advanced stuff and wanted to ask, if it would be somehow possible to upgrade the Plugin APIs Python Version to be able to use some asynchronous functionality.

Up to 3.6.1, which is the minimum requirement for what i am trying to do, everything should be backwards compatible, at least according to reddit. (Link to a reddit post. (Top 2 Comment))

I dont know, if that is as easy as i think it is, but lets see.

A second minor request would be, if you could enable the Hotkey Registering function from the PhBot for the Plugin API. (Maybe im missing it somewhere or am too blind to find some sufficient python equivalent)

In hope for a respose,
sincerely,
Tosh

Edit: stay safe, stay healthy

I was actually thinking about upgrading it but there’s not that many differences. If I do it there will be infinite posts about why the new version causes plugins to not load because they haven’t upgrade the Python 3.4 scripts to 3.8.

Thanks for the quick reply. :slight_smile:

I was trying to implement websockets (which require 3.6.1 afaik) so bots could actually interact with or exchange information between each other.

I guess I will have to try another approch.

I’m looking into upgrading it but don’t know if I will yet. It will be a massive headache when people don’t understand to install the new libraries.

I kinda feel u there.
Thanks for considering it :slight_smile:

It was very easy to upgrade it so I might as well just do it since it’s been at least 4 years since I first added it. I’m making a tutorial so hopefully there won’t be too many threads.

4 Likes

Using user32 dll from python aka ctypes. GetForeground() could be combined with the library pynput if you can install/make it work.

Then the keybinding could be solved like (consider WinAPI as a simple wrapper for ctypes):

# listener created with pynput
def on_press(key):
    # Look for the current process window handler if you plan to target phBot
    thisBotClientHandle = WinAPI.GetWindowHandlers(os.getpid())[0]
    # Compare the current front window
    if WinAPI.GetForeground() == thisBotClientHandle:
        HandleKey(key)

# Key pressed while the window is focused
def HandleKey(key):
    pass # Do stuffs
3 Likes

Thank you very much, the installation isnt an issue for me.