Callback_Querys sollten nun wie ewartet funktionieren

This commit is contained in:
Andreas Bielawski
2016-07-02 14:58:04 +02:00
parent 862335dc77
commit 88cc3f5e6b
3 changed files with 32 additions and 19 deletions

View File

@ -94,15 +94,31 @@ function bot:on_callback_receive(callback, msg, config) -- whenever a new callba
utilities.answer_callback_query(self, callback, 'Nachricht älter als eine Stunde, bitte sende den Befehl selbst noch einmal.', true)
return
end
print('Callback Query, ausgelöst von '..callback.from.first_name..' ('..callback.from.id..')')
if not callback.data:find(':') then
return
end
local called_plugin = callback.data:match('(.*):.*')
local param = callback.data:sub(callback.data:find(':')+1)
print('Callback Query "'..param..'" für Plugin "'..called_plugin..'" ausgelöst von '..callback.from.first_name..' ('..callback.from.id..')')
msg = utilities.enrich_message(msg)
for _,plugin in ipairs(self.plugins) do
-- called_plugin:callback(callback, msg, self, config, param)
-- if is_plugin_disabled_on_chat(plugin.name, msg) then return end
for _, plugin in ipairs(self.plugins) do
if plugin.name == called_plugin then
if is_plugin_disabled_on_chat(plugin.name, msg) then return end
plugin:callback(callback, msg, self, config, param)
end
--plugin.callback(callback, msg, self, config, para)
end
-- called_plugin:callback(callback, msg, self, config, param)
--[[ for _,plugin in ipairs(self.plugins) do
if plugin.callback and msg then
plugin:callback(callback, msg, self, config)
end
end
end]]--
end
function bot:run(config)
@ -340,4 +356,4 @@ function create_cred()
print ('saved credentials into reds hash telegram:credentials')
end
return bot
return bot