Advertisement
Protocol_

CleverBOT

Sep 29th, 2013
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import random, string
  4.  
  5. #####
  6. #bot.py
  7. #author ~ Donny
  8. #version ~ 2.1.0
  9. #Editing and publishing of script is permitted
  10.  
  11. class ai:      
  12.     def __init__(self):
  13.         self.ctgs = 'dn'
  14.         try:
  15.             self.bot(raw_input("-> "))
  16.         except EOFError:
  17.             pass
  18.     def botp(self, x):
  19.         #Prints the reply
  20.         self.x = x
  21.         print "# %s" % (string.capitalize(self.x))
  22.     def as(self):
  23.         #Artificial stupidity
  24.         self.randmsg = ['hello.', 'do you love cheese?', 'LOL', 'IKR', '<3',
  25.                         'do you have a gf? :o', 'what\'s your name',
  26.                         'maths sucks', 'do you have a life', 'yolo', 'swag']
  27.         self.botp(random.choice(self.randmsg))
  28.         self.__init__()
  29.     def bot(self, msg):
  30.         random.seed()
  31.         self.msg = msg.lower()
  32.         #Answers for some questions C:
  33.         self.ans = {'are you a bot':'NO!', 'are you a human':'YES',
  34.                     'what\'s your name':'my name is SAM',
  35.                     'who made you':'DONNY <3'}
  36.         self.s = self.msg.split(' ')
  37.         self.l = len(self.s)
  38.         self.arr = []
  39.         self.i = 0
  40.         while self.i < self.l:
  41.             self.arr.append(self.s[self.i])
  42.             self.i += 1
  43.         #The main part
  44.         self.c = ['shit', 'nigga', 'fuck', 'bitch']
  45.         self.g = ['hi', 'hey', 'hello', 'hola']
  46.         self.ctgs = 'n'
  47.         for i in self.g:
  48.             if i in self.arr:self.ctgs='g'
  49.         for i in self.c:
  50.             if i in self.arr:self.ctgs='c'
  51.         if self.ctgs == 'g':self.botp("Hi!");self.__init__()
  52.         elif self.ctgs == 'c':self.botp("Don't use bad words..:X");self.__init__()
  53.         else:
  54.             try:
  55.                 if self.ans[self.msg]:self.botp(self.ans[self.msg])
  56.                 self.__init__()
  57.             except:
  58.                 self.as()
  59. ObjB = ai()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement