From 33953cc6a0fab6a91af293c6838f8a46dd7922da Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 10 Feb 2014 14:42:51 +0000 Subject: HCONTACT, part 3 git-svn-id: http://svn.miranda-ng.org/main/trunk@8081 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Boltun/src/Engine/TalkEngine.cpp | 25 ++++++++++++------------- plugins/Boltun/src/Engine/TalkEngine.h | 29 ++++++++++++++--------------- plugins/Boltun/src/actionQueue.cpp | 2 +- 3 files changed, 27 insertions(+), 29 deletions(-) (limited to 'plugins/Boltun/src') diff --git a/plugins/Boltun/src/Engine/TalkEngine.cpp b/plugins/Boltun/src/Engine/TalkEngine.cpp index a72bbdeb80..d771012a5f 100644 --- a/plugins/Boltun/src/Engine/TalkEngine.cpp +++ b/plugins/Boltun/src/Engine/TalkEngine.cpp @@ -76,7 +76,7 @@ TalkBot::TalkBot(const Mind& goodMind) :mind(goodMind), beSilent(false), makeLowercase(false), understandAlways(false) { - contactDatas = new PerContactData(mind); + contactDatas = new PerContactData(mind); } TalkBot::~TalkBot() @@ -84,7 +84,7 @@ TalkBot::~TalkBot() delete contactDatas; } -tstring TalkBot::GetInitMessage(void* contact) +tstring TalkBot::GetInitMessage(HCONTACT contact) { ContactData* d = contactDatas->GetData(contact); tstring s = d->initial.GetString(); @@ -108,8 +108,7 @@ tstring TalkBot::ReplaceAliases(const tstring &message) for (unsigned j = max; j > 0; j--) { tstring item = sentence.substr(i, j); - if (mind.GetData()->smiles.find(item) - != mind.GetData()->smiles.end()) + if (mind.GetData()->smiles.find(item) != mind.GetData()->smiles.end()) { sm[i] = item; sentence.replace(i, j, _T("\1")); @@ -160,7 +159,7 @@ tstring TalkBot::ReplaceAliases(const tstring &message) return result; } -tstring TalkBot::AllReplies(const tstring &incomingMessage, ContactData* contactData, Level &maxValue, std::multimap &mm) +tstring TalkBot::AllReplies(const tstring &incomingMessage, ContactData *contactData, Level &maxValue, std::multimap &mm) { tstring res; //Part 1 @@ -273,14 +272,14 @@ tstring TalkBot::AllReplies(const tstring &incomingMessage, ContactData* contact return tstring(); } -TalkBot::MessageInfo* TalkBot::Reply(void* contact, tstring incomingMessage, bool saveChoice) +TalkBot::MessageInfo* TalkBot::Reply(HCONTACT contact, tstring incomingMessage, bool saveChoice) { TCHAR* str = new TCHAR[incomingMessage.length()+1]; _tcscpy(str, incomingMessage.c_str()); CharLower(str); incomingMessage = str; delete [] str; - ContactData* contactData = contactDatas->GetData(contact); + ContactData *contactData = contactDatas->GetData(contact); if (incomingMessage == contactData->lastMessage && GetTickCount() < contactData->lastMessageTime + 30*60*1000) { @@ -353,7 +352,7 @@ TalkBot::MessageInfo* TalkBot::Reply(void* contact, tstring incomingMessage, boo return info; } -bool TalkBot::FindExact(ContactData* contactData, const tstring &incomingMessage, +bool TalkBot::FindExact(ContactData *contactData, const tstring &incomingMessage, const multimap& map, tstring& res) { int max = (int)map.count(incomingMessage); @@ -371,9 +370,9 @@ bool TalkBot::FindExact(ContactData* contactData, const tstring &incomingMessage return true; } -void TalkBot::AnswerGiven(void* contact, const TalkBot::MessageInfo& info) +void TalkBot::AnswerGiven(HCONTACT contact, const TalkBot::MessageInfo& info) { - ContactData* contactData = contactDatas->GetData(contact); + ContactData *contactData = contactDatas->GetData(contact); RecordAnswer(contactData, info); contactDatas->PutData(contact); } @@ -441,7 +440,7 @@ tstring LevelToStr(TalkBot::Level target) } #endif -tstring TalkBot::ChooseResult(ContactData* contactData, Level maxValue, const multimap &mm) +tstring TalkBot::ChooseResult(ContactData *contactData, Level maxValue, const multimap &mm) { #ifdef DEBUG_SHOW_VARIANTS AddBotMessage(_T(">>Availabe:")); @@ -470,7 +469,7 @@ tstring TalkBot::ChooseResult(ContactData* contactData, Level maxValue, const mu #endif } -void TalkBot::FindByKeywords(ContactData* contactData, const vector &keywords, tstring& res/*, tstring& ures*/, +void TalkBot::FindByKeywords(ContactData *contactData, const vector &keywords, tstring& res/*, tstring& ures*/, bool isQuestion) { if (keywords.size() == 0) @@ -490,7 +489,7 @@ void TalkBot::FindByKeywords(ContactData* contactData, const vector &ke res = contactData->chooser.Choose(); } -bool TalkBot::FindByOthers(ContactData* contactData, const vector &otherwords, tstring& res, bool isQuestion) +bool TalkBot::FindByOthers(ContactData *contactData, const vector &otherwords, tstring& res, bool isQuestion) { //vector results; const multimap &specs = isQuestion ? mind.GetData()->qspecialEscapes : diff --git a/plugins/Boltun/src/Engine/TalkEngine.h b/plugins/Boltun/src/Engine/TalkEngine.h index b57cb7f89c..9701b09637 100644 --- a/plugins/Boltun/src/Engine/TalkEngine.h +++ b/plugins/Boltun/src/Engine/TalkEngine.h @@ -74,27 +74,26 @@ private: } }; - PerContactData* contactDatas; + PerContactData* contactDatas; const Mind mind; bool beSilent; bool makeLowercase; bool understandAlways; - void UpdateStartChar(std::tstring& str); + void UpdateStartChar(std::tstring &str); typedef std::multimap::const_iterator mm_cit; - bool FindExact(ContactData* contactData, const std::tstring &incomingMessage, - const std::multimap& map, std::tstring& res); - bool FindAny(ValueChooser<> &ch, std::tstring& res); - void FindByKeywords(ContactData* contactData, const std::vector &keywords, std::tstring& res/*, std::tstring& ures*/, bool isQuestion); - bool FindByOthers(ContactData* contactData, const std::vector &otherwords, std::tstring& res, bool isQuestion); - std::tstring AllReplies(const std::tstring &incomingMessage, ContactData* contactData, Level &maxValue, std::multimap &mm); + bool FindExact(ContactData *contactData, const std::tstring &incomingMessage, const std::multimap &map, std::tstring &res); + bool FindAny(ValueChooser<> &ch, std::tstring &res); + void FindByKeywords(ContactData *contactData, const std::vector &keywords, std::tstring &res/*, std::tstring& ures*/, bool isQuestion); + bool FindByOthers(ContactData *contactData, const std::vector &otherwords, std::tstring &res, bool isQuestion); + std::tstring AllReplies(const std::tstring &incomingMessage, ContactData *contactData, Level &maxValue, std::multimap &mm); std::tstring ReplaceAliases(const std::tstring &message); - std::tstring ChooseResult(ContactData* contactData, Level maxValue, const std::multimap &mm); - void RecordAnswer(ContactData *contactData, const TalkBot::MessageInfo& info); + std::tstring ChooseResult(ContactData *contactData, Level maxValue, const std::multimap &mm); + void RecordAnswer(ContactData *contactData, const TalkBot::MessageInfo &info); #ifdef _DEBUG public: #endif - void SplitSectences(const std::tstring &incomingMessage, std::vector& vec); - void SplitAndSortWords(std::tstring sentence, std::vector& keywords, + void SplitSectences(const std::tstring &incomingMessage, std::vector &vec); + void SplitAndSortWords(std::tstring sentence, std::vector &keywords, std::vector& otherwords, bool& isQuestion); public: TalkBot(const Mind& goodMind); @@ -104,9 +103,9 @@ public: void SetLowercase(const bool isLowercase); void SetUnderstandAlways(const bool understandAlways); //const MindData *GetData(); - std::tstring GetInitMessage(void* contact); - MessageInfo* Reply(void* contact, const std::tstring incomingMessage, bool saveChoice); - void AnswerGiven(void* contact, const MessageInfo& info); + std::tstring GetInitMessage(HCONTACT contact); + MessageInfo* Reply(HCONTACT contact, const std::tstring incomingMessage, bool saveChoice); + void AnswerGiven(HCONTACT contact, const MessageInfo &info); }; #endif diff --git a/plugins/Boltun/src/actionQueue.cpp b/plugins/Boltun/src/actionQueue.cpp index 3f0fead59b..fab338a8dc 100644 --- a/plugins/Boltun/src/actionQueue.cpp +++ b/plugins/Boltun/src/actionQueue.cpp @@ -44,7 +44,7 @@ typedef struct _QueueElement { } QueueElement; static list actionQueue; -static set typingContacts; +static set typingContacts; UINT_PTR timerID = 0; CriticalSection cs; -- cgit v1.2.3