Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Help] I'm making a Talk Bot

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Jaak
Expert Cheater
Reputation: 0

Joined: 02 Jul 2008
Posts: 176

PostPosted: Thu Jan 01, 2009 11:28 am    Post subject: [Help] I'm making a Talk Bot Reply with quote

I'm making a talk bot which is going to be very basic to start. It will ask certain questions and store the answers for later on. i have a few questions though. Instead of creating 50million variables for every input how can i make it so that it can recieve infinite input and then respond accordingly. I'd also like to beable to make it in the future so that it can detect keywords and then ask a question according to that or respond. I don't want my code to be messy and my main focus right now is making it so that anything can be inputed and then i can work on how to respond to it.

Few questions:
-What libraries should I use? I have the basic iostream and stdlib
-Should i use string or char? Why?
-Can a loop be used to make infite input occur or is there another way?
-(for the future) is it possible for me to detect if a '?' is used and detect keywords so that it can respond or ask a question?

Thank you Smile
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Jan 01, 2009 11:42 am    Post subject: Reply with quote

If you wan't to store an amount of inputs that isn't fixed to a certain limit you have to keep your input buffer dynamic. Meaning properly allocating and reallocating your buffer.

How you can do this:
HeapAlloc, HeapReAlloc, HeapFree

Include: Windows.h

You should use char, or wchar_t (UNICODE char), or just make it compiler depend and use TCHAR routines.

Include: Tchar.h

If you want to scan for a question mark you can use the handy function _tcsrchr to find the last occurrence of a certain character. In your case a '?'.
Or if you just want it to allow the last character to be a ? then you can check the last character in the buffer.

Code:
if (Buffer[lstrlen(Buffer)-1] == '?')
   ...


And yea, you can loop or you can just have an edit box and a button to allow input, like a send, or enter button. Then you can just filter from your Windows Procedure. (If your using a Window.. If your using console you'll have to stick to looping input).

_________________
Back to top
View user's profile Send private message
Jaak
Expert Cheater
Reputation: 0

Joined: 02 Jul 2008
Posts: 176

PostPosted: Thu Jan 01, 2009 11:46 am    Post subject: Reply with quote

lurc wrote:
If you wan't to store an amount of inputs that isn't fixed to a certain limit you have to keep your input buffer dynamic. Meaning properly allocating and reallocating your buffer.

How you can do this:
HeapAlloc, HeapReAlloc, HeapFree

Include: Windows.h

You should use char, or wchar_t (UNICODE char), or just make it compiler depend and use TCHAR routines.

Include: Tchar.h

If you want to scan for a question mark you can use the handy function _tcsrchr to find the last occurrence of a certain character. In your case a '?'.
Or if you just want it to allow the last character to be a ? then you can check the last character in the buffer.

Code:
if (Buffer[lstrlen(Buffer)-1] == '?')
   ...


And yea, you can loop or you can just have an edit box and a button to allow input, like a send, or enter button. Then you can just filter from your Windows Procedure. (If your using a Window.. If your using console you'll have to stick to looping input).


Wow thank you Smile Im using a console app. (aka: dos window)

1 more question. Can you give an example of code for storing data in the char. thanks
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Jan 01, 2009 12:01 pm    Post subject: Reply with quote

Code:
#include <Windows.h>
#include <Tchar.h>

int _tmain(int argc, TCHAR *argv[])
{
    LPTSTR lpString = (LPTSTR)HeapAlloc(GetProcessHeap(), 0, sizeof(TCHAR)*MAX_PATH);
    if (lpString != NULL)
    {
          _tscanf(_T("%s"), lpString); // Don't remember if this catchs spaces...
          _tprintf(_T("You inputted: %s"), lpString);
          HeapFree(GetProcessHeap(), 0, (LPVOID)lpString);
    }
    return 0;
}


Although, I recommend you use ReadConsole.

First parameter can be obtained by GetStdHandle.

_________________
Back to top
View user's profile Send private message
Jaak
Expert Cheater
Reputation: 0

Joined: 02 Jul 2008
Posts: 176

PostPosted: Thu Jan 01, 2009 12:03 pm    Post subject: Reply with quote

lurc wrote:
Code:
#include <Windows.h>
#include <Tchar.h>

int _tmain(int argc, TCHAR *argv[])
{
    LPTSTR lpString = (LPTSTR)HeapAlloc(GetProcessHeap(), 0, sizeof(TCHAR)*MAX_PATH);
    if (lpString != NULL)
    {
          _tscanf(_T("%s"), lpString); // Don't remember if this catchs spaces...
          _tprintf(_T("You inputted: %s"), lpString);
          HeapFree(GetProcessHeap(), 0, (LPVOID)lpString);
    }
    return 0;
}


Although, I recommend you use ReadConsole.

First parameter can be obtained by GetStdHandle.


Uhh.. I really don't know what all of that means Wink but ill keep working and post when i have problems. thanks Smile
Back to top
View user's profile Send private message
92Garfield
I'm a spammer
Reputation: 57

Joined: 20 Dec 2007
Posts: 5871
Location: Banana Republic Germany

PostPosted: Thu Jan 01, 2009 12:44 pm    Post subject: Reply with quote

You should use an array i guess
And you should already know what it is...

_________________
Back to top
View user's profile Send private message
Jaak
Expert Cheater
Reputation: 0

Joined: 02 Jul 2008
Posts: 176

PostPosted: Thu Jan 01, 2009 3:48 pm    Post subject: Reply with quote

92Garfield wrote:
You should use an array i guess
And you should already know what it is...


Why should I? What if I didn't? how can you assume what i already know...

Ontopic: For those who don't know what im making, this is similiar to an AIM bot. If you want an example google "igod"
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites