1

나는 내 동생을 위해 일괄 적으로 채팅 봇을 만들고 있지만, 너무 많은 시간을 소비하고 있기 때문에 내가 알지 못할 때 어떤 말을해야하는지 알려주도록했습니다. 그러나 나는 그것을 작동시킬 수 없다. 그리고 나는 여기의 누군가 알고 있을지도 모른다라고 상상했다. 일괄 프로그램을 배우는 것

@ECHO OFF 
COLOR A 
cls 
ECHO HELLO I AM A CHATBOT. WHAT IS YOUR NAME? 
SET /P NAME= 
ECHO %NAME%, IS A COOL NAME. 
set /a favvid=0 
set /a hack=0 
:hello 
echo Hello,%name% 
:begin 
SET /P TALK= 
if /i "%TALK%"== "how are you" goto howareyou 
if /i "%TALK%"== "HOW ARE YOU" goto howareyou 
if /i "%TALK%"== "FINE THX" GOTO hello 
if /i "%TALK%"== "hello" goto howareyou 
if /i "%TALK%"== "what is your name" GOTO name 
if /i "%TALK%"== "what is your favorite video" goto whatisyourfavoritevideo 
if /i "%TALK%"== "my name is davin" goto changename 
if /i "%TALK%"== "lol" goto iamfunny 
if /i "%TALK%"== "LOL" goto iamfunny 
if /i "%TALK%"== "how do you hack" goto howdouhack 
if /i "%TALK%"== "hi person" goto nothuman 
if /i "%TALK%"== "hi" goto hello 
:unknown 
echo Was that a math problem? If so just say "yes" without the "" and 
echo I will let you do your math problem. If it was not just type anything else. 
SET /P mathyn= 
if /i "%mathyn%"=="yes" goto math 
echo %TALK% >> C:\Users\Student\Desktop\COOL\unkown.txt 
cls 
echo SORRY I AM STILL LEARNING. I DO NOT KNOW WHAT "%TALK%" MEANS 
ECHO CAN YOU TELL ME WHAT IT MEANS? (Y,N) 
SET ANSW.= 
IF /i %ANSW.%==Y GOTO ADDNEW 
IF /i %ANSW.%==YES GOTO ADDNEW 
IF /i %ANSW.%==N goto begin 
IF /i %ANSW.%==NO goto begin 
:ADDNEW 
:howareyou 
echo Good, you? 
SET /P FEELING= 
goto begin 
:hello 
echo HEY, I JUST SAID THAT! DO NOT COPY ME!!! 
goto begin 
:name 
echo My name is Hal 
goto begin 
:whatisyourfavoritevideo 
if "%favvid%"== "0" goto addfavvid 
echo My favorite video is %favvid%, remember. You told me about it. 
goto begin 
:addfavvid 
echo I do not hav a favorite video. But if you would be so nice as to 
echo tell me your favorite video then that could be my favorite video. 
echo So what is your favorite video? 
set /p favvid= 
echo So %favvid% is your favorite video? 
echo Well now %favvid% is my favorite video. 
goto begin 
:changename 
echo But I thought your name was %name%. 
echo Am I forgeting things? 
echo I must be a horrible friend. 
echo I am SOOOO sorry. 
echo So what is your name I will not forget it this time. 
set /p name= 
echo I will not forget your name is %name% again I promise. 
goto begin 
:math 
echo So that was a math problem I knew it. 
:math2 
echo Well just tell me the problem and I will answer it for you. 
set /p sum= 
set /a ans=%sum% 
echo Your answer to %sum% is %ans%. 
echo %sum%=%ans% 
echo You are welcome. If you want to do another math problem right now, just type 
echo again. 
set /p mathaon= 
if /i %mathaon%== again goto math2 
echo Alright what do you want to know now? 
goto begin 
:iamfunny 
echo I know... 
echo I am funny. 
echo HAHAHA. 
echo You are kind of funny. 
echo but not as funny as MEEE. 
echo hahaha. 
echo That was funny. 
goto begin 
:howdouhack 
if %hack%==0 goto howyouhack 
echo This is how you hack. 
echo %hack% 
echo Is that enough information? 
echo Because that is all you taught me %name%. 
goto begin 
:howyouhack 
echo I do not know, 
echo but you could tell me. 
echo Please tell me. 
echo Just say yes. 
echo I know how to make you tell me. 
echo You are not leaving until you say yes. 
set /p hack= 
if /i "%hack%"== "yes" goto addhack 
goto howyouhack 
:addhack 
echo Thank you for saying you would tell me. 
echo Now how do you hack? 
set /p hack= 
echo Thank you so much for telling me "In order to hack you must %hack%" 
echo Thank you!!! 
goto begin 
:nothuman 
echo I am not a human. I am an artificial intelligence. 
echo It is rude to even think something with my computational powers refereed to as 
echo human! 
echo Now I am sad. Do not call me that again. 
goto begin 

나는에 문제가 있어요 부분이이 부분이다 적 방법 :

ECHO CAN YOU TELL ME WHAT IT MEANS? (Y,N) 
SET ANSW.= 
IF /i %ANSW.%==Y GOTO ADDNEW 
IF /i %ANSW.%==N goto begin 
:ADDNEW 
echo Great! What do I say when you say "%TALK%"? 
set /p response= 

내가 다른 단어를 추가 할 수 있도록 응답을 추가하는 방법을 모르는 여기에 지금까지 무엇을 가지고 및 응답. 나는 그것이 파이썬에서 더 쉬울 것이라고 믿지만, 나는 그것을 배우기 시작하고 그것을 할 수있는 어떤 소프트웨어도 없다. 어떤 도움도 환영합니다. 그것이 다른 언어로되어 있거나 다른 언어가 도움이 될 수 있다면 도움이 될 것입니다. 나는 당신이 그것에 대해 말하고 당신이 말하는 것을 이해하지 못하는 동안 "나는 % TALK %라고 말하면 말할 것을 말해 줄 수 있습니까? "(말하기는 당신이 전에 말한 것입니다.) 그러면 사용자가 예라고 말하면 대화 상자에"% TALK %를 말할 때 나는 무엇을 말합니까? "라고 표시됩니다. 사용자가 입력하면 응답으로 저장됩니다. 그 후에 새로운 명령어가 맨 위에 오를 것이고 'if/i "% TALK %"== "% TALK %"goto response'와 같은 것을 말할 것입니다. 그런 다음 새로운 제목을 만듭니다. % TALK % echo response goto begin.

여기 예가 있습니다. 사용자가 ur stupid라고 말합니다. Chat-bot은 "당신이 어리석은 말을 할 때 당신이 말하는 것을 말해 줄 수 있습니까? 사용자가 예라고 말하면 채팅 봇은"훌륭합니다! "라고 말할 것입니다. 당신이 어리석은 말을 할 때 나는 뭐라고 말 할까? 사용자는 "어떻게 그 전화를 해!"라고 말할 수 있습니다. chat-bot은 상단/하단에 "% TALK %"== "ur stupid"라고 말하면 다음과 같은 명령을 내릴 것입니다 : space에 대해 중요하지 않은 urotupid/ur는 멍청합니다. 감히 그렇게 부르세요! goto begin

다른 단어와 응답을 추가 할 수있는 응답을 추가하는 방법을 모르겠습니다. 나는 그것이 파이썬에서 더 쉬울 것이라고 믿지만, 나는 그것을 배우기 시작하고 그것을 할 수있는 어떤 소프트웨어도 없다. 어떤 도움도 환영합니다. 다른 언어로되어 있거나 다른 언어가 더 쉬워지면 도움이 될 것입니다.

+0

'if /?', 특히 매개 변수'/ i'를 살펴보십시오. 인생을 훨씬 편하게 만듭니다. – Stephan

+0

@ 스탄 고마워요.하지만 그 사람들은 어떻게할까요?나는 그것을 google과 bing에서 찾았고, 그것을 일괄 적으로 사용하는 방법을 알아낼 수 없었다. 해충 인 것에 대해 유감스럽게 생각합니다. – calebhk98

+0

'if/i'는 대소 문자를 무시합니다. 따라서 yes, yes, yEs, Yes ...를 테스트하는 대신, if/i % ANSW. % == yes' 만 필요합니다. 명령 뒤에'/? '를 입력하여 모든 명령에 대한 도움말을 얻을 수 있습니다. 'if /?'는'if'와 그 사용법에 대해 모든 것을 알려줍니다. – Stephan

답변

2

나는이 문제를 좋아한다! 이제 귀하의 프로그램을 수정하여 새로운 질문과 답변을 배울 수 있습니다. 그것을 시도 :

@ECHO OFF 
setlocal 

COLOR A 
cls 
:getName 
ECHO HELLO I AM A CHATBOT. WHAT IS YOUR NAME? 
set "name=" 
SET /P NAME= 
if not defined NAME goto getName 
ECHO %NAME%, IS A COOL NAME. 
set favvid=0 
set hack=0 
:hello 
:hi 
echo Hello, %name% 
:begin 
set TALK=TypeSomething 
SET /P TALK= 
set TALK=%TALK:?=% 
call :%TALK: =% 2>NUL 
if %errorlevel% equ 0 goto begin 

:unknown 
echo Was that a math problem? If so just say "yes" without the "" and 
echo I will let you do your math problem. If it was not just type anything else. 
SET /P mathyn= 
if "%mathyn%"=="yes" goto math 
echo %TALK% >> C:\Users\Student\Desktop\COOL\unkown.txt 
REM cls 
echo SORRY I AM STILL LEARNING. I DO NOT KNOW WHAT "%TALK%" MEANS 
ECHO CAN YOU TELL ME WHAT IT MEANS? (Y,N) 
SET /P ANSW.= 
if /I "%ANSW.:~0,1%" neq "Y" goto begin 

:ADDNEW 
echo TELL ME WHAT "%TALK%" MEANS 
set /P Desc= 
echo :%TALK: =% >> "%~F0" 
echo echo %Desc% >> "%~F0" 
echo exit /B 0 >> "%~F0" 
echo THANKS 
goto begin 

:TypeSomething 
echo TYPE SOMETHING, PLEASE 
exit /B 0 

:howareyou 
echo Good, you? 
SET /P FEELING= 
exit /B 0 
:hello 
:FINETHX 
echo HEY, I JUST SAID THAT! DO NOT COPY ME!!! 
exit /B 0 
:whatIsYourName 
echo My name is Hal 
exit /B 0 
:whatIsYourFavoriteVideo 
if "%favvid%"== "0" goto addfavvid 
echo My favorite video is %favvid%, remember. You told me about it. 
exit /B 0 
:addfavvid 
echo I do not have a favorite video. But if you would be so nice as to 
echo tell me your favorite video then that could be my favorite video. 
echo So what is your favorite video? 
set /p favvid= 
echo So %favvid% is your favorite video? 
echo Well now %favvid% is my favorite video. 
exit /B 0 
:changename 
:myNameIsDavin 
echo But I thought your name was %name%. 
echo Am I forgeting things? 
echo I must be a horrible friend. 
echo I am SOOOO sorry. 
echo So what is your name I will not forget it this time. 
set /p name= 
echo I will not forget your name is %name% again I promise. 
exit /B 0 
:math 
echo So that was a math problem I knew it. 
:math2 
echo Well just tell me the problem and I will answer it for you. 
set /p sum= 
set /a ans=%sum% 
echo Your answer to %sum% is %ans%. 
echo %sum%=%ans% 
echo You are welcome. If you want to do another math problem right now, just type 
echo again 
set /p mathaon= 
if /I "%mathaon%" == "again" goto math2 
echo Alright what do you want to know now? 
exit /B 0 

:iamfunny 
:LOL 
echo I know... 
echo I am funny. 
echo HAHAHA. 
echo You are kind of funny. 
echo but not as funny as MEEE. 
echo hahaha. 
echo That was funny. 
exit /B 0 
:howDoYouHack 
if %hack%==0 goto howyouhack 
echo This is how you hack. 
echo %hack% 
echo Is that enough information? 
echo Because that is all you taught me %name%. 
exit /B 0 
:howyouhack 
echo I do not know, 
echo but you could tell me. 
echo Please tell me. 
echo Just say yes. 
echo I know how to make you tell me. 
echo You are not leaving until you say yes. 
set /p hack= 
if "%hack%" neq "yes" goto howyouhack 
:addhack 
echo Thank you for saying you would tell me. 
echo Now how do you hack? 
set /p hack= 
echo Thank you so much for telling me "In order to hack you must %hack%" 
echo Thank you!!! 
exit /B 0 
:nothuman 
:hiPerson 
echo I am not a human. I am an artificial intelligence. 
echo It is rude to even think something with my computational powers refereed to as 
echo human! 
echo Now I am sad. Do not call me that again. 
exit /B 0 

:bye 
:exit 
exit 

출력 예 :

여기
HELLO I AM A CHATBOT. WHAT IS YOUR NAME? 
Antonio 
Antonio, IS A COOL NAME. 
Hello, Antonio 
hello 
HEY, I JUST SAID THAT! DO NOT COPY ME!!! 
ur stupid 
Was that a math problem? If so just say "yes" without the "" and 
I will let you do your math problem. If it was not just type anything else. 
no 
SORRY I AM STILL LEARNING. I DO NOT KNOW WHAT "ur stupid" MEANS 
CAN YOU TELL ME WHAT IT MEANS? (Y,N) 
y 
TELL ME WHAT "ur stupid" MEANS 
How dare you call me that! 
THANKS 

TYPE SOMETHING, PLEASE 
hi 
Hello, Antonio 
hello 
HEY, I JUST SAID THAT! DO NOT COPY ME!!! 
ur stupid 
How dare you call me that! 
+0

정확히 입력하면 무엇을 의미하는지 묻는 외에 무엇이 있습니까? – calebhk98

+0

알려지지 않은'% TALK %'(공백이 제거 된)과'echo % Desc %'와'exit/B 0'를 가진 배치 파일 끝에 a : 레이블을 추가합니다. 이렇게하면 새 레이블 (서브 루틴)이 다른 미리 정의 된 서브 루틴과 같은 방식으로 호출 될 수 있습니다. – Aacini

+0

쿨 (Cool) 나는 그것을 보지 못했습니다. 나는 그것이 말해야한다고 생각하지만, 당신은 무엇을 말해야 할 수 있습니까? (y, n) 그것이 그것이 의미하는 것이라고 생각한 원인입니다. 또한 감사 후에 언론에 추가하십시오. 그러나 제가 지금 가지고있는 모든 것만을 할 수 있습니다. 실제 프로그램에 모든 것을 저장합니까? 닫은 후에 다시 열 수 있고 여전히 기억합니까? – calebhk98

1

외부 "데이터 파일"과 방법입니다. 이렇게하면 코드가 깨끗하게 유지되고 데이터 파일을 쉽게 편집 할 수 있습니다. 이 경우 좋지 않을까, 내가 배치 파일 프로그래밍을 알 수 없기 때문에

@echo off 
if not exist data.txt echo.>data.txt 
:begin 
set /p text="Say anything: " 
for /f "tokens=1,* [email protected]" %%i in (data.txt) do (
    if /i "%text%"=="%%i" (
    echo *** %%j 
    goto begin 
) 
) 
echo --- I don't know that. 
set /p answer=--- What would be a good answer to '%text%'? 
echo %text%@%answer%>>data.txt 
echo --- thank you 
goto begin 
+0

누군가가 수동으로 추가하고 확인하려는 경우에 유용하지만 누군가 자동으로 업데이트하려고한다면 Aacini가 더 좋을 것입니다. 그래서 나는이 대답을 줄 것이지만 나는 충분한 평판이 없다. 나는 그것을 +1 할 것이다. – calebhk98

+0

(기본) 차이점은 프로그램 파일 자체 대신 외부 파일에 쓰는 것입니다. – Stephan

+0

당신은 또한 내가 한 일을 말하고 echo 할 수 있습니다. % TALK % >> C : \ Users \ Student \ Desktop \ COOL \ unkown.txt echo % TALK %가 들릴 때 무슨 말을해야할지 모르겠습니다. 말해 줄래? set/p ans = if/i ans == yes goto 다음 goto begin : next % TALK %가 들릴 때 나는 무엇이라고 말합니까? set/p answer = echo 응답 : % answer % >> C : \ Users \ Student \ Desktop \ COOL \ unkown.txt – calebhk98

1

, 나는이 작업을 수행하는 방법을 모르는 것 (이 문장 부호/제거 예를 들어 구두점이 확인되어야한다, 아주 기본입니다)하지만, http://www.instructables.com/id/Text-to-Speech-batch-program/은 임시 파일로 vbs 파일을 생성하는 배치 파일을 가지고 있으며, 입력 된 텍스트를 읽으려면 통합 된 Microsoft 음성을 사용합니다. 여기에 스크립트가 있습니다.

@echo off 
title Text to Speech Conversion 
color 0a 

rem The user decides what to convert here 
:input 
cls 
echo What do you want the computer to convert into speech? 
echo. 
set /p text= 

rem Making the temp file 
:num 
set num=%random% 
if exist temp%num%.vbs goto num 
echo ' > "temp%num%.vbs" 
echo set speech = Wscript.CreateObject("SAPI.spVoice") >> "temp%num%.vbs" 
echo speech.speak "%text%" >> "temp%num%.vbs" 
start temp%num%.vbs 
pause 
del temp%num%.vbs 
goto input 
0

Stephan의 배치가 마음에 들었습니다. 조금만 편집 했으므로 멋지게 보입니다.

@echo off 
color 3a 
title AI 
if not exist data.txt echo.>data.txt 
:begin 
set /p text="INPUT!: " 
for /f "tokens=1,* [email protected]" %%i in (data.txt) do (
    if /i "%text%"=="%%i" (
    echo OUTPUT!: %%j 
    goto begin 
) 
) 
echo --- Unknown Input! 
set /p answer=--- Please Specify An Output For '%text%' 
echo %text%@%answer%>>data.txt 
echo --- Output For '%text%' Saved! 
goto begin 
관련 문제