diff --git a/bot.py b/bot.py index 0fb66da..14a07f5 100755 --- a/bot.py +++ b/bot.py @@ -1,8 +1,8 @@ #!/usr/bin/python -network = "localhost" -nick = "skybot" -channel = "#test" +network = "irc.synirc.net" +nick = "skybotisgay" +channel = "#cobol" import sys import os diff --git a/plugins/explain.py b/plugins/explain.py index 44fba6b..ebd07e8 100755 --- a/plugins/explain.py +++ b/plugins/explain.py @@ -1,3 +1,4 @@ +from util import hook from pycparser.cdecl import explain_c_declaration @hook.command('explain') @@ -7,8 +8,12 @@ foo is a array of array[8] of pointer to pointer to function() returning pointer to array of pointer to char ''' if not inp: - return None - - result = explain_c_declaration(inp) - if result: return result - else: return None \ No newline at end of file + return "" + + try: + result = explain_c_declaration(inp.rstrip()) + except e: + result = str(e) + + return result + diff --git a/plugins/pycparser/cdecl.py b/plugins/pycparser/cdecl.py index a7aea70..c0dc5b3 100644 --- a/plugins/pycparser/cdecl.py +++ b/plugins/pycparser/cdecl.py @@ -34,14 +34,11 @@ def explain_c_declaration(c_decl): """ parser = c_parser.CParser() - try: - node = parser.parse(c_decl, filename='') - except c_parser.ParseError, e: - return None + node = parser.parse(c_decl, filename='') if ( not isinstance(node, c_ast.FileAST) or not isinstance(node.ext[-1], c_ast.Decl)): - return None + return "Last external node is invalid type" return _explain_decl_node(node.ext[-1])