HTTPS SSH
# Akasaka's Longpoll Server ## Version 1.1 ### A longpoll server for the VK.com social network. Makes it possible for you to have extensive functionality on your chat bot without having to mess with lots of scripts, using a simplified plugin system. *Currently only message events are supported* ### Dependencies * VK_API module * YAPSY * urllib * *Tested on Linux only* ### Included plugins In the `aklpplugin` folder the following plugins are included: * `filesvr` — FTP-alike file server for AKLP. *Command: see README!* **requires configuration** * `passing` — monitor who's online with a command. *Command: !passing* **requires configuration** * `rndphoto` — get a random photo from an album. *Command: !photo* **requires configuration** * `testplugin` — a sample plugin. *Command: !context, !reverse [text], !ping, !say [text]* **!say command requires flite** * `ai` — an AIML chat bot, too poorly documented... ### Configuration Config is located at the top of the `aklongpoll.py` file. * `APIID` and `SECRET`: specify what VK App ID and App Secret Token you've created for your passive system. * `LOGIN` and `PASW`: specify login and password for your passive system's account * `BAN`: array of user IDs of people whose messages will be ignored * `PLUGINDIR`: an array of folders where to look for plugins. *Example: `['/home/longpoll/plugins','/aklpplugins']`* * `MSGPREFIX`: a prefix that identifies the message as a command * `SYCOMMPFX`: a prefix that identifies the message as a **system-value** command (higher priority than contexts and plugins). * `SYSOPID`: a number designating the VK ID of the SysOp. Required for proper operation of secure plugins such as the *filesvr* plugin. Improper configuration may lead to security flaws. * `FORKOFF`: detach process from terminal into background after start. If the process is detached, the only way to stop it is `killall python`, `killall aklongpoll.py` or reboot. * `CRASHY`: when *True*, doesn't wrap plugins into a *try-catch* block and lets them crash either their thread *(see below)* or the whole server process. Useful when debugging your plugins. * `THREADED`: when *True*, puts each plugin query into its own thread. Useful for using plugins with long operations to keep the system responsive for other users. * `UNHANDLED`: Notify the user when their command was prefixed correctly, yet unrecognised. * `UNPREFIXED`: Notify the users who didn't prefix their command or sent a plain message that this is a passive system and not a real person. * `UNPEXCEPT`: Array of numbers of VK IDs of people, who should not be notified with the above setting. * `UNPFORWARD`: Forward unprefixed/plain messages to the SysOp. * `UNPBAN`: Array of VK IDs of people whose unprefixed/plain messages will be completely ignored. * `UNPNOTICE`: A message which will be sent to people when `UNHANDLED` is set to *True*. ### Setup * Download the server * Put it into desired folder * Configure according to the description above * Configure plugins that need configuration, such as *filesvr*. * `python aklongpoll.py` * Enjoy * *optional:* put into cron for `@reboot` or whatever means of auto-restart ### Usage #### Commands To send a command, start the message with the configured prefix. For example if you set the prefix to be `#`, you will need to send `#mycommand`. All plugins then get a command of `mycommand` and if any one supports it, then it will be handled. For example: ``` You: #hello Server (plugin speaking): Hey there, sysop! You: #goodbye Server (engine speaking, if UNHANDLED is set to True): No plugin knows the command 'goodbye'. You: #donothing Server (plugin speaking): Hey, look, I'm doing nothing! ``` #### Contexts If a plugin gets you in a context, you don't have to prefix your commands. For example: ``` You: #!parrot Server (plugin speaking): You are now in a context that says everything back to you. You: Hey there! Server (plugin speaking): Hey there! You: Cool huh Server (plugin speaking): Cool huh You: #!parrot Server (plugin speaking): You have left the context now. You: Cool huh Server (engine speaking, if UNPREFIXED is set to True): This is a passive system, you have to prefix you commands with #. ``` #### System-value commands The system-value commands execute even when the user is in context, and are only available to the sysop. The default `SYCOMMOPFX` for them is `%`. So executing a system level command when all the prefixes are default looks like this: `#%systemcommand`. Currently supported commands: * `send <userID> <message>` — send a message to user with the specified numeric ID. *Example:* `#%send 1 Hello, Pavel!` * `post <text>` — create a wall post with a specified text. *Example:* `#%post This is a wall post. Some important content goes here.` * `repost <oid> [comment]` — create a wall post with the specified object. *Example:* `#%repost wall174350119_6010 LOL!` * `status <text>` — set passive system's status. *Example:* `#%status Один раз оэлютс — всегда оэлютс!` * `sysinfo` — get system status (thermal and disk state). Currently uses `acpi -t` and `hddtemp /dev/sda` for thermal info. So, *works only with the server running as root*. ### Disclaimer This comes AS IS and might not suit your needs, I'm not responsible if this doesn't work as you expected or even explodes your computer. It should work fine but still be considered beta-software. Be a nice person and don't steal others' work, too.