renfredxh / compilebot Goto Github PK
View Code? Open in Web Editor NEWA bot that executes source code in reddit comments
Home Page: http://reddit.com/r/CompileBot/wiki
License: Apache License 2.0
A bot that executes source code in reddit comments
Home Page: http://reddit.com/r/CompileBot/wiki
License: Apache License 2.0
Add a flask server in deploy.py that responds 200 OK to help keep tabs on when the bot is up and running.
Right now while exceptions are being handled in deploy.py, there is a chance the logging function may cause it's own exceptions and crash the program. On exception, stack traces should be added to a buffer and sent during the try
block at the top of the loop.
Error processing comment 2q5prs Traceback (most recent call last): File "/compilebot/compilebot/compilebot.py", line 473, in main process_unread(new, r) File "/compilebot/compilebot/compilebot.py", line 26, in wrapper return func(args, *kwargs) File "/compilebot/compilebot/compilebot.py", line 454, in process_unread if spam and new.subreddit.display_name not in IGNORE_SPAM: AttributeError: 'NoneType' object has no attribute 'display_name'
Allow for c# unsafe code to be compiled if possible? thank you
It seems that compilebot doesn't reply for the compile request mention if the mention's permalink contains non-ascii character. For example:
I think urllib.quote(comment.permalink)
(link) raises some error because PRAW's comment.permalink()
returns unicode type which may contain non-parcent-encoded unicode characters and urllib.quote()
doesn't accept unicode
type:
>>> comment = next(reddit.get_unread())
>>> comment.permalink
u'https://www.reddit.com/r/:subreddit/comments/:submission_id/\u30c6\u30b9\u30c8\u30b9\u30ec\u30c3\u30c9/:comment_id'
>>> print comment.permalink
https://www.reddit.com/r/:subreddit/comments/:submission_id/テストスレッド/:comment_id
>>> from urllib import quote
>>> quote(comment.permalink)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 1299, in quote
return ''.join(map(quoter, s))
KeyError: u'\u30c6'
Instead of logging to a file, main
should log to stdout by default, so its logs can be accessed easily by containers.
14-11-29 17:56:42: Error processing comment cmg8rry Traceback (most recent call last): File
"/compilebot/compilebot/compilebot.py", line 473, in main processunread(new, r) File
"/compilebot/compilebot/compilebot.py", line 26, in wrapper return func(args, *kwargs) File
"/compilebot/compilebot/compilebot.py", line 383, in process_unread reply = create_reply(new) File
"/compilebot/compilebot/compilebot.py", line 316, in create_reply details = compile(src, lang, stdin=stdin)
File "/compilebot/compilebot/compilebot.py", line 185, in compile details = i.submission_details(sub_link)
File "build/bdist.linux-x86_64/egg/ideone/init.py", line 288, in submission_details with_compilation_info)
File "build/bdist.linux-x86_64/egg/suds/client.py", line 542, in __call_ return client.invoke(args, kwargs)
File "build/bdist.linux-x86_64/egg/suds/client.py", line 602, in invoke result = self.send(soapenv) File
"build/bdist.linux-x86_64/egg/suds/client.py", line 637, in send reply = transport.send(request) File
"build/bdist.linux-x86_64/egg/suds/transport/https.py", line 64, in send return HttpTransport.send(self,
request) File "build/bdist.linux-x86_64/egg/suds/transport/http.py", line 79, in send result = Reply(200,
fp.headers.dict, fp.read()) File "/usr/lib/python2.7/socket.py", line 351, in read data =
self._sock.recv(rbufsize) File "/usr/lib/python2.7/httplib.py", line 567, in read s = self.fp.read(amt) File
"/usr/lib/python2.7/socket.py", line 380, in read data = self._sock.recv(left) error: [Errno 104] Connection
reset by peer
I used your wrapper and I found an error, looks like the first exception should be moved in 3rd position otherwise APIException and ClientException will never be called.
compilebot/compilebot/compilebot.py
Line 30 in 12830c7
Seems there's a Python3 SOAP client so this should be possible now
For a cleaner approach to emulating praw class objects and methods during testing
http://www.toptal.com/python/an-introduction-to-mocking-in-python
Config should be imported via a separate python module (like in Flask) and use environment variables where possible.
Currently the bot prints the stdout in a code-formatted markdown section. It would be nice if there was an option to have stdout set as the bot comment content directly. For example:
Comment invoking the bot:
+/u/CompileBot python3 --raw-output
print("**test**")
Bot response:
test
or
Deal with the following error:
15-02-25 16:56:53: Error processing comment cowt85e Traceback (most recent call last): File
"/compilebot/compilebot/compilebot.py", line 486, in main process_unread(new, r) File
"/compilebot/compilebot/compilebot.py", line 27, in wrapper return func(args, *kwargs) File
"/compilebot/compilebot/compilebot.py", line 383, in process_unread if sender.name.lower() in
BANNED_USERS: TypeError: argument of type 'NoneType' is not iterable
Currently the bot responds with an empty string while Ideone replies with "Time limit exceeded".
Ackermann problem on Reddit.
Here is the Ideone source
Would be a much more readable format for storing configs
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.