From 3405b0c1635843cbb81f042364bfcf238d7dc930 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Thu, 5 May 2016 14:59:28 +0200 Subject: Adds the current code. It's been running for close to a month on one of the IRC channels I frequent and seems to be working fine. One should be aware that, among other missing features, this version does not store permanently what the bot learns. Indeed, I am currently using a file with 431848 lines as its initial knowledge bank, making this particular feature not a high priority one. Also consider the fact that Zero of One converts text to underscore before reading it but will not change its own aliases. This could potentially be a cause for surprises when using uppercase letters in the latter. --- src/pervasive.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/pervasive.h (limited to 'src/pervasive.h') diff --git a/src/pervasive.h b/src/pervasive.h new file mode 100644 index 0000000..d2b0344 --- /dev/null +++ b/src/pervasive.h @@ -0,0 +1,59 @@ +#ifndef _ZoO_PERVASIVE_H_ +#define _ZoO_PERVASIVE_H_ + +#include + +#ifndef ZoO_NETWORK_TIMEOUT + #define ZoO_NETWORK_TIMEOUT 200 +#endif + +#ifndef ZoO_MAX_REPLY_WORDS + #define ZoO_MAX_REPLY_WORDS 64 +#endif + +#ifndef ZoO_DEFAULT_DATA_FILENAME + #define ZoO_DEFAULT_DATA_FILENAME "./memory.txt" +#endif + +#ifndef ZoO_DEFAULT_IRC_SERVER_ADDR + #define ZoO_DEFAULT_IRC_SERVER_ADDR "irc.foonetic.net" +#endif + +#ifndef ZoO_DEFAULT_IRC_SERVER_PORT + #define ZoO_DEFAULT_IRC_SERVER_PORT "6667" +#endif + +#ifndef ZoO_DEFAULT_IRC_SERVER_CHANNEL + #define ZoO_DEFAULT_IRC_SERVER_CHANNEL "#theborghivemind" +#endif + +#ifndef ZoO_DEFAULT_IRC_USERNAME + #define ZoO_DEFAULT_IRC_USERNAME "zeroofone" +#endif + +#ifndef ZoO_DEFAULT_IRC_REALNAME + #define ZoO_DEFAULT_IRC_REALNAME "Zero of One (bot)" +#endif + +#ifndef ZoO_DEFAULT_REPLY_RATE + #define ZoO_DEFAULT_REPLY_RATE 8 +#endif + +typedef unsigned int ZoO_index; +#define ZoO_INDEX_MAX UINT_MAX + +/* ZoO_char = UTF-8 char */ +typedef char ZoO_char; +/* Functions that can handle UTF-8 'char' will use this symbol. */ +#define ZoO_CHAR_STRING_SYMBOL "%s" + +#define ZoO__TO_STRING(x) #x +#define ZoO_TO_STRING(x) ZoO__TO_STRING(x) +#define ZoO_ISOLATE(a) do {a} while (0) + +/* strncmp stops at '\0' and strlen does not count '\0'. */ +#define ZoO_IS_PREFIX(a, b) (strncmp(a, b, strlen(a)) == 0) + +#define ZoO_STRING_EQUALS(a, b) (strcmp(a, b) == 0) + +#endif -- cgit v1.2.3-70-g09d2