-
Notifications
You must be signed in to change notification settings - Fork 0
/
obashgle.py
59 lines (47 loc) · 1.39 KB
/
obashgle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Omegle
import bash as Bash
from twisted.internet import reactor
class Handler:
def __init__(self):
self.bash = Bash.Bash()
self.client = None
def start(self):
self.client = Omegle.Omegle(self, 0)
print "Connecting..."
self.client.connect()
def on_connected(self, index):
print "Connected to a stranger."
self.bash.changeDir('~')
self.sendPrompt()
def on_message(self, index, message):
print "Stranger: %s" % message
#Handle the command
if message.startswith('cd '):
output = self.bash.changeDir(message)
else:
output = self.bash.runCmd(message)
#print and send output if there is some
if output != "" and output != '\n':
self.client.sendMsg(output)
print output
self.sendPrompt()
def on_typing(self, index):
print "Stranger is typing"
def on_stoppedTyping(self, index):
print "Stranger has stopped typing"
def on_recaptcha(self, index, url):
print "Recaptcha required: %s" % url
self.client.sendCaptcha(raw_input("Response: "))
def on_recaptchaResponse(self, index, accepted):
if accepted: print 'Recaptcha accepted!'
else: print 'Recaptcha rejected!'
def on_disconnected(self, index, reason):
print "Stranger has disconnected\n"
self.client.connect()
def sendPrompt(self):
self.client.sendMsg(self.bash.getPrompt())
print self.bash.getPrompt()
if __name__ == "__main__":
handler = Handler()
handler.start()
reactor.run()