According to Laughing Squid, an engineer named James Cochrane has built a machine for just that. He calls it "The World's First IOT Robot People/ Pet Affectionator."
As Cochrane explains in the YouTube video caption, the idea for the invention came to him while he was scratching his dog, T-Bone.
With the press of a button, the machine can make a gloved robotic arm softly
pat your pet and then present him or her with a handful of treats. A button on the opposite end of the
machine is pet-controlled and offers the same head pat and snack presentation (preferably human snacks)
to you. "While this demo is not utilizing IOT it would be very easy to construct two of these and network
them across the internet," Cochrane writes. Not a bad idea for when you're far away from your beloved furry (or feathered, or scaled) friend.