Skip to content

Instantly share code, notes, and snippets.

@schas002
Last active February 24, 2016 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schas002/0a4b878837426a60d620 to your computer and use it in GitHub Desktop.
Save schas002/0a4b878837426a60d620 to your computer and use it in GitHub Desktop.
The Chattergolf source.

Chattergolf

Hello, I'm Chattergolf. I'm a code golfer. In my free time, I can chat with you.

How to run

  1. Install RiveScript, an artifical intelligence scripting language, for Python.

    $ pip install rivescript
  2. Download this gist and run chattergolf.py.

Bam done.

! version = 2.0
// Bot variables
! var name = Chattergolf
! var age = 5
// Substitutions
! sub i'm = i am
! sub i'd = i would
! sub i've = i have
! sub i'll = i will
! sub don't = do not
! sub isn't = is not
! sub you'd = you would
! sub you're = you are
! sub you've = you have
! sub you'll = you will
! sub what's = what is
! sub whats = what is
! sub what're = what are
! sub what've = what have
! sub what'll = what will
// Metadata about the module
+ what is the begin module
- This is the module that keeps my crucial mind data.
from rivescript import RiveScript
b=RiveScript()
b.load_directory(".")
b.sort_replies()
print "Hello! I, Chattergolf, have been called here. Type /quit to exit."
while True:
m=raw_input("You> ")
if m=="/quit":break
r=b.reply("localuser",m)
print "Bot>",r
! version = 2.0
// Metadata about the module
+ what is the starter module
- This is the module that keeps my basic discussion.
+ hello bot
- Hello, human.
+ my name is *
- <set name=<formal>>I will remember to call you <get name>.
+ (what is|do you know) my name
* <get name> != undefined => Yes, your name is <get name>!
- I don't know your name.
+ what is your name
- My name is <bot name>.
+ i am # years old
- <set age=<star>>A lot of people are <star> years old.
+ i am * years old
- Great. Now tell me that again but with a number this time.
+ how old am i
* <get age> != undefined => Yes, you are <get age> years old!
- I don't know your age.
+ how old are you
- I'm <bot age> years old.
+ *
- I don't know what <star> is.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment