Skip to content
No description, website, or topics provided.
CSS HTML JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
css
fonts
img
js
README.md
index.html

README.md

Quokkas on Demand

This will send you quokkas on demand (if you ask nicely).

This is a bot built with Twilio and their WhatsApp API for Twilio Engage in Sydney.

Currently running on Twilio Functions using the following code:

exports.handler = function(context, event, callback) {
	let twiml = new Twilio.twiml.MessagingResponse(),
		request = event.Body,
		message = twiml.message()

	console.log(event.Body)

	let photo = Math.floor(Math.random() * 12),
		type = 'jpg'

	if (RegExp(/\d+/).test(request) && request.match(/(\d+)/)[0] < 12) {
		photo = request.match(/(\d+)/)[0]
	}

	if (RegExp('quokka', 'i').test(request)) {
		message.body(`This is a quokka`)
		message.media(`https://quokkas.amyskapers.dev/img/quokka_(${photo}).${type}`)
	} else {
		if (photo > 9) {
			type = 'gif'
			message.body(`This is not a quokka https://quokkas.amyskapers.dev/img/not_quokka_(${photo}).${type}`)
		} else {
			message.body(`This is not a quokka`)
			message.media(`https://quokkas.amyskapers.dev/img/not_quokka_(${photo}).${type}`)
		}
	}

	callback(null, twiml)
}
You can’t perform that action at this time.