Timmy

Project on SourceForge Number of Downloads on SourceForge

Timmy is a Pascal unit for creating chat bots. It provides the TTimmy object, which is a data type that you can assign your variables to to make bots. Once that is done, you can start adding keywords for messages, and get the bot answers to the end user’s messages.

Creating bots with Timmy is as easy as 1 2 3.

How to create a bot with Timmy

  1. Declare timmy unit
  2. Declare a TTimmy variable
  3. Initialize your TTimmy
  4. Add some keywords for your messages, and possible replies to those messages
  5. Start answering

Example program

Program MyFirstBot;
Uses timmy;
Var MyBot: TTimmy;

BEGIN
    MyBot.Init(70, 'I gave up', False);
    MyBot.Add(StrSplit('Hello', ' '), StrSplit('Greetings!|Hello to you!|Hi!', '|'));
    MyBot.Add('How are you', 'I am fine!;Never better!;I''m doing great.');
    MyBot.Add('What 2 + 2', 'The answer is 4', ' ', '@');

    Writeln(MyBot.Answer('Hello!'));
    Writeln(MyBot.Answer('How are you?'));
    Writeln(MyBot.Answer('What is 2 + 2?'));
    Writeln(MyBot.Answer('What is the meaning of life?'));
END.

If we compile and execute the program, we should get something like this as the output:

Hi!
I'm doing great
The answer is 4
I gave up.

For more examples, check out the examples folder.

Variables, functions and procedures of TTimmy

constructor Init(Percent: Integer; DefaultRep: String; DpCheck: Boolean)

function Init()

Enabled

procedure Enable()

procedure Disable()

MKeywordsList

ReplyList

NOfEntries

procedure Update()

TPercent

NoUdstdRep

function Add(MKeywords, Replies: TStrArray)

function Add(KeywordsStr, RepStr: String)

function Add(KeywordsStr, RepStr: String; KStrDeli, MStrDeli: Char)

DupesCheck

function Remove(MKeywords: TStrArray)

function Remove(KeywordsStr: String)

function Remove(KeywordsStr: String; KStrDeli: Char)

function Remove(AIndex: Integer)

function Answer(TMessage: String)

Other functions provided by the unit & TStrArray

TStrArray

TStrArray is Array of Array of String. In Timmy, it is used instead of Array of Array of String to avoid type incompatible compile error.

function StrTrim(S: String)

function StrSplit(S: String; delimiter: Char)

function CompareStrArrays(ArrayA, ArrayB: TStrArray)

License

License logo

Timmy is licensed under the GNU LGPL v3.