File tree 4 files changed +34
-16
lines changed
4 files changed +34
-16
lines changed Original file line number Diff line number Diff line change 1
1
from flask import Flask , request , jsonify
2
2
from judge import runProcess
3
3
from flask_cors import CORS
4
+ from bot import send_message
4
5
5
6
app = Flask ('dexter' )
6
7
CORS (app )
@@ -40,5 +41,15 @@ def interpret():
40
41
return jsonify ({'out' : str (outBuf ), 'err' : str (errBuf )})
41
42
42
43
44
+ @app .route ('/zulip' , methods = ['POST' ])
45
+ def zulip ():
46
+ # email = request.form['email']
47
+ email = 'kuchtohtha@gmail.com'
48
+ content = request .form ['content' ]
49
+ send_message (email , content )
50
+ return 'ok'
51
+
52
+
53
+
43
54
if __name__ == '__main__' :
44
55
app .run (debug = True )
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
2
3
3
import zulip
4
- import sys
5
4
6
5
# Keyword arguments 'email' and 'api_key' are not required if you are using ~/.zuliprc
7
6
client = zulip .Client (email = "mydexter-bot@hack36.zulipchat.com" ,
8
7
api_key = "gX6ulWhAzExkZcYSAtWgpsAMbrXLjcJn" ,
9
8
site = "https://hack36.zulipchat.com" )
10
9
11
10
# Send a private message
12
- client .send_message ({
13
- "type" : "private" ,
14
- "to" : "himanshushekharb16@gmail.com" ,
15
- "content" : "I come not, friends, to steal away your hearts."
16
- })
17
-
18
- # Print each message the user receives
19
- # This is a blocking call that will run forever
20
- client .call_on_each_message (lambda msg : sys .stdout .write (str (msg ) + "\n " ))
21
-
22
- # Print every event relevant to the user
23
- # This is a blocking call that will run forever
24
- # This will never be reached unless you comment out the previous line
25
- client .call_on_each_event (lambda msg : sys .stdout .write (str (msg ) + "\n " ))
11
+ def send_message (message , email ):
12
+ client .send_message ({
13
+ "type" : "private" ,
14
+ "to" : email ,
15
+ "content" : message ,
16
+ })
Original file line number Diff line number Diff line change @@ -79,6 +79,18 @@ function runJavascript() {
79
79
} )
80
80
}
81
81
82
+ function runZulip ( ) {
83
+ let content = editor1 . getValue ( )
84
+ $ . ajax ( {
85
+ url : 'http://localhost:5000/zulip' ,
86
+ type : 'POST' ,
87
+ crossDomain : true ,
88
+ data : { content :content } ,
89
+ success : console . log ,
90
+ error : console . log ,
91
+ } )
92
+ }
93
+
82
94
function commandHandlers ( command ) {
83
95
if ( command == 'dexter_start' ) {
84
96
dexterIsRunning = true
@@ -112,5 +124,7 @@ function commandHandlers(command) {
112
124
} else if ( command == 'dexter_run' ) {
113
125
runPython ( )
114
126
runJavascript ( )
127
+ } else if ( command == 'dexter_zulip' ) {
128
+ runZulip ( )
115
129
}
116
130
}
Original file line number Diff line number Diff line change @@ -63,7 +63,9 @@ var known_commands = [
63
63
64
64
{ id : 'dexter_run' , text : 'dexter run code' } ,
65
65
{ id : 'dexter_run' , text : 'code chala do bhai' } ,
66
- { id : 'dexter_run' , text : 'arey bhai bhai bhai' }
66
+ { id : 'dexter_run' , text : 'arey bhai bhai bhai' } ,
67
+ { id : 'dexter_zulip' , text : 'zulip pe bhej do' } ,
68
+ { id : 'dexter_zulip' , text : 'dexter send to zulip' } ,
67
69
]
68
70
69
71
function IsKnownCommand ( command ) {
You can’t perform that action at this time.
0 commit comments