Simple app for create XMPP chat bot
Sorry for my english
- Heyman wait XMPP message from user
- Search command in config file (by regex)
- Run command from specific user with specified args
- Write all XMPP messages to stdin
- Read from stdout and send to XMPP user
- This happens as long as the command application will not closed
XMPP user >--XMPP message--> Heyman >--stdin--> $/you/application.exe -with=args
XMPP user <--XMPP message--< Heyman <--stdout-< $/you/application.exe -with=args
- Compile project
- Create
config.yaml
at root file - run
/usr/bin/mono Heyman.exe config.yaml
orHeyman.exe config.yaml
Example configuration to run at Mono:
# XMPP client configuration
Xmpp:
User: xmpp_username
Password: xmpp_password
Server: xmpp.server.host
# List of commands
Commands:
- Title: "weather"
Regex: "^(weather|weath)"
Description: "tell weather int your city"
Arguments: "/srv/heyman/hey/Hey.exe weather -message='$MESSAGE' -u='$USER_ID' -n='$USER_NAME'"
FileName: "/usr/bin/mono"
EndLine: "|"
- Title: "restart"
Regex: "restart"
Description: "restart Ubuntu server"
Arguments: "-r now"
FileName: "/usr/bin/shutdown "
UserName: root
WorkingDirectory: ./
# Localization strings
Localization:
HelpHeader: "Hi there! List of my commands:"
Command fields description:
- Title - display name for user
- Regex - regex expression for matching command
- Description - description for user
- FileName - app file path to execute WITHOUT arguments
- UserName - user name
- EndLine - specifies end of line for message. See [EndLine-symbol]
- WorkingDirectory - specifies working directory
- Arguments - arguments for app. You can use '$<ARG_NAME>' macros to insert some data to arguments
-
Heyman application wait for '/n' from command stdout and send message user. If EndLine not specified, command can send only one-line message. But if you specify EndLine, Heyman split string by this symbol.
-
Heyman listen new messages from users and write it to stdin. User message can contain multiple lines with '\n' symbols. This symbol may be replaced by special string, specified in command config.
- $MESSAGE - input message from client
- $USER_ID - user XMPP user id (JID). For example: "heyman@jabber.com/Other"
- $USER_NAME - user name. For example: "Чат бот"
Exmaple supervisor config file ./scripts/supervisor.conf
When start app by supervisor, stdin encoding was different, from console start encoding. Fixed by adding line
environment=LC_ALL='en_US.UTF-8',LANG='en_US.UTF-8'
to supervisor config file.
asv.heyman
├── scripts/ # scripts folder
│ ├── supervisor.conf/ # default config for supervisor
│ └── restart.sh/ # script for restart service
├── src/ # source code folder
├── LICENCE # code licence
└── README.md # project description
Project is maintained under the Semantic Versioning guidelines.
All notable changes to this project will be documented here
- add README
- add Heyman XMPP bot
Code released under the MIT license. Docs is licensed under a Creative Commons — CC BY 3.0.