예제 #1
0
def bashServer(baseID,pause=1):
	cat = baseID+"_cat"
	hat = baseID+"_hat"
	connect(cat,hat)
	while True:
		base.chat(hat,cat,"Look at me NOW!")
		base.keep(cat)
		response = base.keep(hat)
		if 'events' in response:
			for event in response['events']:
				print('e')
				print(event)
				if event['type'] == 'connected':
					1
				elif event['type'] == 'disconnected':
					connect(cat,hat)
				elif event['type'] == 'msg':
					if event['from'] == None:
						name = event['content'].splitlines()[0]
						command = '\n'.join(event['content'].splitlines()[1:])
						try:
							stdoutdata = sub.check_output(command,shell=True)
							output = stdoutdata.decode('ascii', 'ignore')
						except:
							output = 'ERROR'
						base.chat(None,name,output)
				elif event['type'] == 'question':
					1
		time.sleep(pause)
예제 #2
0
def getRequest(ID,target,request):
	base.chat(None,target,ID+'\n'+request)
	return getResponse(ID)['events'][0]['content']