Even though the idea is brilliant, I did not like the way the original was implemented. I came up with this solution while rewriting our company’s dialplan in Lua.
So naturally, you will need the pbx_lua interpreter. You also need the music by Rick Astley himself. A preformated .gsm file can be found here. I use pbx_spool for .call files.
extensions.lua:
function rickroll()
app.answer()
app.background("rick")
sleep(math.random(180))
file = io.open("/var/spool/asterisk/outgoing/rickroll" .. math.random(9999) .. ".call","w")
file:write("Channel: SIP/" .. channel.CALLERID("num"):get() .."\nApplication: PlayBack\nData: rick\n")
file:close()
end
And then just assign it to some context:
extensions = {
some_context = {
["_X."] = rickroll;
};
So what does it do? It plays Rick Astleys “Never gonna let you down”. And then it waits random amount of seconds (0-180) before it calls back – and does the rickroll all over again. Thanks to Andy Goodwin for the inspiration, and Calle for the heads up.
Caveats:
- It does not check the caller ID. Call will be returned no matter what.
- It uses random, not unique values for call-files. Possible race condition.
- You can always use channel["CALLERID(num)"]:set(“value”) to change the callerid.
But as an added bonus, it seems to work with most voicemails.