This is a simple bot system for Signal with minimal dependencies. Pure Java and cross platform.
gradlew installDist
should generate a run script at 'build/install/signal-bot/bin/signal-bot'.
- To register the bot on the Signal service, run
signal-bot --register +12223334444
(change the phone number to any number that you can receive an SMS on.) - After receiving the verification SMS, run
signal-bot --verify 123-456
(change the number to the code you received.) - To start the bot, run
signal-bot --listen
. You should be able to then message the bot and see your messages in the log. - To stop the bot, interrupt with Ctrl+C or
kill -2
to allow it to shut down and disconnect gracefully from the Signal service. - To dry-run test the listener, use
signal-bot --test
. This will start a simple input loop that sends your messages to the bot and sends the response to stdout. This doesn't use the Signal service.
- Create a new class that implements
SignalBot.Responder
. For example, this will echo back every message received:
package com.woodencloset.signalbot.responders;
import com.woodencloset.signalbot.SignalBot;
public class EchoResponder implements SignalBot.Responder {
@Override
public String getResponse(String messageText) {
return messageText;
}
}
- Add the line
bot.addResponder(new EchoResponder());
to theMain
class (as an example, there is aDiceRollResponder
included and added already.
- For code simplicity, keys are stored in-memory, so it's mostly suitable for a long running session on a server. If you terminate and re-run, all keys (including identity key) will be re-generated which would neccessitate other parties to re-approve the bot's identity.
- Group info is stored in-memory as well. If you join a group and then re-run the bot, the first message in the group will be ignored as the bot updates its internal group info. This could be solved by using a message queue, but that's currently not implemented, for code simplicity.
- Bot interface only supports receiving and sending simple text responses. No images or other data. Messages are always sent back to the sender, or to the group, if sent from one.