Python で IRC ボットを作成していますが、コンソール コマンドが必要です。
main 関数が while ループに入っているため、 を入れることができませんinput_raw()
。ループを中断せずにユーザー入力を取得する方法を知っている人はいますか?
ありがとう!
質問が解決され、スレッドが使用されました、ソース:FaceBotソース
でノンブロッキング ソケットの使用を試すことができますselect
。何かのようなもの:
from sys import stdin
from select import select
while True:
print "Enter command> ",
# Add on_write sockets as necessary
on_read, _, _ = select([stdin], [], [], 5)
if on_read:
command = stdin.readline()
print "Now I can process you command..."
else:
print "No command, we can do here something else..."