Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reetou/mnogobot
DSL for writing social media bots
https://github.com/reetou/mnogobot
Last synced: about 1 month ago
JSON representation
DSL for writing social media bots
- Host: GitHub
- URL: https://github.com/reetou/mnogobot
- Owner: reetou
- Created: 2020-10-27T01:00:13.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-28T13:13:18.000Z (about 4 years ago)
- Last Synced: 2024-12-04T03:08:02.953Z (about 1 month ago)
- Language: Elixir
- Homepage:
- Size: 142 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mnogobot
Elixir-based DSL for writing bots
## Usage
```elixir
# apps/mnogobot/lib/mnogobot.exdefmodule Mnogobot do
import MnogobotDSLbot do
dialog Hey do
say "heyyy!" # Send message and wait for user response
reply "Yo bro" # Reply with mention: @user, Yo bro
name = ask "Whats your name?" # Store user answers
balance = 12 # Define custom variable
say "Hello #{name}, your balance is #{balance}" # Use your variables in messages
image "https://i.imgur.com/qo9nKso.jpeg" # Send media
sticker ":yo:", only: [:slack] # Define platform-specific logic
enddialog privet, [trigger: "!elo"] do # Trigger dialogs by user message
say "Your elo is"
enddialog buy, [trigger: starts_with("buy")] do # Much flexible
say "You are buying..."
enddialog sell, each: [120, :message] do
say "I am selling something to you"
end
end
end
```## Get started
- Install deps: `mix deps.get`
- Write some code in `apps/mnogobot/lib/mnogobot.ex`
- Execute: `mix generate_actions`
- You will have something like that in terminal:
```
Created dialog with name dialog_hey_actions, containing 6 actions, 1 variables and trigger: nil
Created dialog with name dialog_privet_actions, containing 1 actions, 0 variables and trigger: "!elo"
Created dialog with name dialog_buy_actions, containing 1 actions, 0 variables and trigger: ["starts_with", "buy"]
Created dialog with name dialog_sell_actions, containing 1 actions, 0 variables and trigger: nil
File generated: actions_encoded.json
```
- Then move generated `.json` file to `apps/mnogobot_DESIRED_INTEGRATION/priv/`
- Configure your bot in `config.exs`
- Start your integration app and enjoy