0

I'm pretty new to Python and I'm trying to do something. I'm using a Python IRC bot which let's me build functions that are used as commands on the channel. I have obtained a python version of Cleverbot and would like to link these 2 together. But becuase I'm not good with Python I'm not sure how to do it.

To use the cleverbot python I would simply type in a terminal:

python cleverbot.py

And it would give me a "> " where I can input. Then I say on that line "Hello" and the cleverbot script will print the result using a print command.

So, I've been messing around and have discovered I can use the Python IRC bot commands to print a string, so it will simply print the results string for me. The problem is I can't get it to input anything to the cleverbot script. I was hoping it was possible to do something like:

print python cleverbot.py "hello"

And it would simply print the response from Cleverbot, does that make sense? I could then simply use the IRC commands to print the response to the channel.

Thanks in advance, and I hope it was possible to understand.

2 Answers 2

1

inside cleverbot.py you can you these statements to print the command line argument provided:

   import sys
   print(sys.argv[1])  #or print(' '.join(sys.argv[1:])) if the arguments are more than one

so now python cleverbot.py hello will print hello

Sign up to request clarification or add additional context in comments.

Comments

0

Try

echo "hello" | python cleverbot.py

3 Comments

that worked but the script retuned also a EOFError for some reason. Now can I do something like: return echo "hello" | python cleverbot.py
How exactly does this effect files which contain and rely on a loop? Would the loop be activated and would it stay in place on the cleverbot.py?
@user1176160 that command simply feeds string "hello\n" into stdin of python script. If the script is not ready to process stdin handling EOF properly it will result in the behavior you're seeing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.