Page 1 of 1

Lua and Skype

Posted: Mon Nov 05, 2012 4:12 pm
by Nixola
A friend of mine has found a dice roller that asks Skype permissions to access the messages sent and received, parses them and if it finds something like //XdY[+Z] it throws that/those di(c)e and prints the results. Is there something like a Lua interpreter that works the same way or a compiled library loadable in Lua that allows the script to access Skype messages?

Re: Lua and Skype

Posted: Mon Nov 05, 2012 11:53 pm
by Inny
You probably want to start here: https://developer.skype.com/
I'm sure that with Lua and something like Alien or FFI, you could hook into skype's API and do some interesting things.

As for dice rolling, that's easy. "2D6+1" would be parsed like so:

Code: Select all

function dice_check( s )
  local dice, sides, bonus = string.match(s, "(%d+)[dD](%d+)(.*)")
  assert(dice and sides)
  local sum = bonus and tonumber(bonus) or 0
  for i = 1, tonumber(dice) do
    sum = sum + math.random(1, tonumber(sides))
  end
  return sum
end
Good luck and I wish you a +2 on your Programming Skill.

Re: Lua and Skype

Posted: Tue Nov 06, 2012 1:22 pm
by Nixola
I already tried there, but I couldn't figure out how to use it so I gave up after a couple of hours, thanks anyway

I don't want to create a diceroller, I'd like to have a lua interpreter that works through Skype, but thanks for the code ^^