mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Check for method before calling
This commit is contained in:
parent
b12701805b
commit
926425c947
@ -66,22 +66,31 @@ ruby_init_hook(ProfPlugin *plugin, const char * const version, const char * cons
|
||||
VALUE v_status = rb_str_new2(status);
|
||||
|
||||
VALUE module = (VALUE) plugin->module;
|
||||
VALUE exists = rb_eval_string("RubyTest.respond_to?(:prof_init)");
|
||||
if (TYPE(exists) == T_TRUE) {
|
||||
rb_funcall(module, rb_intern("prof_init"), 2, v_version, v_status);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ruby_on_start_hook(ProfPlugin *plugin)
|
||||
{
|
||||
VALUE module = (VALUE) plugin->module;
|
||||
VALUE exists = rb_eval_string("RubyTest.respond_to?(:prof_on_start)");
|
||||
if (TYPE(exists) == T_TRUE) {
|
||||
rb_funcall(module, rb_intern("prof_on_start"), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ruby_on_connect_hook(ProfPlugin *plugin)
|
||||
{
|
||||
VALUE module = (VALUE) plugin->module;
|
||||
VALUE exists = rb_eval_string("RubyTest.respond_to?(:prof_on_connect)");
|
||||
if (TYPE(exists) == T_TRUE) {
|
||||
rb_funcall(module, rb_intern("prof_on_connect"), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ruby_on_message_received_hook(ProfPlugin *plugin, const char * const jid, const char * const message)
|
||||
@ -90,8 +99,11 @@ ruby_on_message_received_hook(ProfPlugin *plugin, const char * const jid, const
|
||||
VALUE v_message = rb_str_new2(message);
|
||||
|
||||
VALUE module = (VALUE) plugin->module;
|
||||
VALUE exists = rb_eval_string("RubyTest.respond_to?(:prof_on_message_received)");
|
||||
if (TYPE(exists) == T_TRUE) {
|
||||
rb_funcall(module, rb_intern("prof_on_message_received"), 2, v_jid, v_message);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ruby_check_error(void)
|
||||
|
Loading…
Reference in New Issue
Block a user