Get the latest tech news

Developing a Go bot embedding Ichiban Prolog


Ichiban Prolog is a #golang implementation of an ISO compatible Prolog. To learn how to embed it, I decided to add Prolog support to Hellabot, a simple irc bot. Hellabot design requires to program its triggers using a two step process as described in the code below: type Trigger struct { // Returns true if this trigger applies to the passed in message Condition func(*Bot, *Message) bool // The action to perform if Condition is true // return true if the message was 'consumed' Action func(*Bot, *Message) bool }

Our strategy to remove the recompilation dependency, we will update bot to read Prolog code from a file that can be edited any time by the user. For this we transform the different fields of the*hbot.Message to Prolog terms using a function called MessageToTerms() and store its results in a string to be loaded by the next step. In our code we will have a single solution “This is the Prolog message”, but in case we had multiple ones the for sols.Next() { [...] } loop would ensure we capture all of them and return it to the client via the call irc.Reply().

Get the Android app

Or read this on Hacker News

Read more on:

Photo of bot

bot

Photo of Prolog

Prolog

Photo of ichiban Prolog

ichiban Prolog

Related news:

News photo

A social network where everyone’s a bot

News photo

Ukraine’s Gun-Armed Ground 'Bot Just Cleared A Russian Trench In Kursk

News photo

The future of software? Imagine a bot, stamping on a human face – forever