X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fscript.rb;h=7a8c0c84696abc03ab36e2025a03c7577b148e8b;hb=1371de4f0799590c5fc19889fef137acdc53a020;hp=8a3e1e847a0876416906a8b86186ba9a91c95e6a;hpb=55eae6dcf60c8b24452cf5eb75f18aacb3469215;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/script.rb b/data/rbot/plugins/script.rb index 8a3e1e84..7a8c0c84 100644 --- a/data/rbot/plugins/script.rb +++ b/data/rbot/plugins/script.rb @@ -37,10 +37,16 @@ class ScriptPlugin < Plugin if topic == "add" "Scripts are little Ruby programs that run in the context of the script plugin. You can access @bot (class Irc::Bot), m (class Irc::PrivMessage), user (class String, either the first argument, or if missing the sourcenick), and args (class Array, an array of arguments). Example: 'script add greet m.reply( 'Hello ' + user )'. Invoke the script just like a plugin: ': greet'." else - "Create mini plugins on IRC. 'script add ' => Create script named with the Ruby program . 'script list' => Show a list of all known scripts. 'script show ' => Show the source code for . 'script del ' => Delete the script ." + "Create mini plugins on IRC. 'script add ' => Create script named with the Ruby program . 'script list' => Show a list of all known scripts. 'script show ' => Show the source code for . 'script del ' => Delete the script . 'script eval ' => evaluate expression . 'script echo ' => evaluate and display expression ." end end + def report_error(m, name, e) + # ed = e.backtrace.unshift(e.inspect).join(' ') + ed = e.inspect + m.reply( "Script '#{name}' crapped out :( #{ed}" ) + end + def listen( m ) name = m.message.split.first @@ -60,8 +66,7 @@ class ScriptPlugin < Plugin begin eval( code ) rescue Exception => e - m.reply( "Script '#{name}' crapped out :(" ) - m.reply( e.inspect ) + report_error(m, name, e) end } m.replied = true @@ -76,8 +81,7 @@ class ScriptPlugin < Plugin begin eval( code ) rescue Exception => e - m.reply( "Script '#{name}' crapped out :(" ) - m.reply( e.inspect ) + report_error(m, code, e) end } m.replied = true @@ -91,8 +95,7 @@ class ScriptPlugin < Plugin begin m.reply eval( code ).to_s rescue Exception => e - m.reply( "Script '#{name}' crapped out :(" ) - m.reply( e.inspect ) + report_error(m, code, e) end } m.replied = true