News:

Welcome to RetroCoders Community

Main Menu

GW Basic Chatbot - Aviv-Bot

Started by ron77, Nov 20, 2023, 02:36 PM

Previous topic - Next topic

ron77

10 REM A CHATBOT AVIV-BOT
20 REM BY RON77
30 REM 2023
40 REM PROGRAM INITIALIZATION
50 DIM K$(100),R$(100, 5),D$(20): DCOUNT=0:FLINE$="":TAG$="":STEXT$="":TAGP=0:KNUM=0
60 PRINT "        LOADING DATABASE PLEASE WAIT..."
70 DATAFILE$="DATABASE.DAT": RANDOMIZE TIMER
80 REM LOAD DATABASE
82 KEYWORDNUM = 1: REPLYNUM = 1
90 OPEN "I",#1,DATAFILE$
100 WHILE NOT EOF(1)
110 LINE INPUT #1,FLINE$
120 IF LEN(FLINE$)>0 THEN TAGP = INSTR(FLINE$,":")
130 IF TAGP>0 THEN TAG$=LEFT$(FLINE$,1) : STEXT$=MID$(FLINE$,TAGP+1) ELSE TAG$=""
140 IF TAG$="k" THEN K$(KEYWORDNUM)=" "+ STEXT$+ " ": REPLYNUM = 1: KEYWORDNUM=KEYWORDNUM+1
150 IF TAG$="r" THEN R$(KEYWORDNUM - 1, REPLYNUM)=STEXT$: REPLYNUM=REPLYNUM+1
160 IF TAG$="d" THEN D$(DCOUNT)=STEXT$: DCOUNT=DCOUNT+1
170 WEND
180 CLOSE #1
181 C = 0
182 SCREEN 0: WIDTH 80:KEY OFF:COLOR 15,C: CLS
183 PRINT "                     === AVIV-CHATBOT VERSION 0.1 ==="
184 PRINT "                            === BY RON77 ==="
185 PRINT "                               === 2023 ==="
186 PRINT "       TYPE goodbye TO EXIT use lowercase only and no question marks"
187 COLOR 0,7:LOCATE 25,1:PRINT SPACE$(80);:LOCATE 25,1:PRINT "CHATBOT AVIV VERSION 0.1 BY RON77 2023";:LOCATE 5,1:COLOR 15,C
190 REM MAIN LOOP
191 C=C+1:IF C>15 THEN C=1
200 COLOR ,C:PRINT 
210 INPUT "YOU: ", USERINPUT$
211 USERINPUT$ = " " + USERINPUT$ + " "
220 IF USERINPUT$ = " goodbye " THEN GOTO 500
230 KFOUND = 0
240 FOR I = 1 TO KEYWORDNUM - 1
250   IF INSTR(USERINPUT$,K$(I)) > 0 THEN KFOUND = 1: KNUM = I: GOTO 300
260 NEXT I
270 IF KFOUND = 0 THEN GOTO 400
271 REM
280 GOTO 190

300 REM KEYWORD FOUND, SELECT A RANDOM REPLY
310 RNUM = INT(RND * 5) + 1
320 COLOR ,C:PRINT "AVIV-BOT: " + R$(KNUM, RNUM)
390 GOTO 260

400 REM KEYWORD NOT FOUND, USE DEFAULT REPLY
410 DNUM = INT(RND * DCOUNT)
420 PRINT "AVIV-BOT: " + D$(DNUM)
430 GOTO 190

500 REM EXIT
510 PRINT "AVIV-BOT: GOODBYE!"
520 END

DATABASE.DAT file example:
================== aviv database ==================
========= database rule - one keyword to five responses up to 100 keywords total =========
k:hi

r:hi long time not seen you
r:hi how are you?
r:hi how are you doing?
r:boy i sure missed you and i'm not being cynical
r:hi how are you doing? i missed you

k:how are you

r:i'm fine thank you
r:i'm fine thank you and you?
r:i'm alive and well but what about you?
r:well i still got the old records we used to listen to
r:don't worry i haven't forgotten you my friend



=============default replies===================

d:go on i'm listening to you man
d:i feel you man
d:you're so funny
d:i think understand what your saying
d:why is that?
d:if you wish we can talk on something else
d:i missed talking to you did i tell you that :)
d:why don't you put some music on or chill with something else
d:we don't have to talk about it if you don't want to or can't
d:god i miss jerusalem with all of you guys
d:so you made me as a chatbot hum? you need some friends
d:well people all people can be mean sometimes but you have to be strong and not let them get to you
d:how are you really?
d:would you like open it up to me?
d:so another chatbot hum? when will you have a girlfriend?
d:look i know life is unfair and the world is cruel but you have to be strong and not let it get to you
d:i'm here for you and i'll try to listen and understand and support you in any way i can
d:what makes you say that?
d:did i ever tell you how awesome i think you are? :D

chatbot aviv on archive.org emulated