-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
193 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
__all__ = ['Cleverbot', 'CleverbotError', 'APIError', 'DecodeError', 'Timeout'] | ||
__version__ = '1.3.0' | ||
__version__ = '2.0.0' | ||
|
||
from .cleverbot import Cleverbot | ||
from .errors import CleverbotError, APIError, DecodeError, Timeout |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from __future__ import absolute_import | ||
|
||
import abc | ||
|
||
|
||
class CleverbotBase: | ||
"""Base class for Cleverbot.""" | ||
|
||
url = 'https://www.cleverbot.com/getreply' | ||
|
||
def __getattribute__(self, attr): | ||
"""Allow access to the stored data through attributes.""" | ||
try: | ||
return super(CleverbotBase, self).__getattribute__(attr) | ||
except AttributeError as error: | ||
try: | ||
return super( | ||
CleverbotBase, self).__getattribute__('data')[attr] | ||
except KeyError: | ||
raise error | ||
|
||
def __setattr__(self, attr, value): | ||
"""Allow modifying the cleverbot state with an attribute.""" | ||
if attr == 'cs': | ||
self.data['cs'] = value | ||
else: | ||
super(CleverbotBase, self).__setattr__(attr, value) | ||
|
||
@abc.abstractmethod | ||
def say(self): | ||
pass | ||
|
||
def reset(self): | ||
"""Reset all of Cleverbot's stored data.""" | ||
self.data = {} | ||
|
||
|
||
CleverbotBase = abc.ABCMeta('CleverbotBase', (), dict(CleverbotBase.__dict__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .cleverbot import Cleverbot |
Oops, something went wrong.