#!/bin/env julia
using Telegrambot
using UUIDs

include("Tofrak.jl")

botApi="bot<your_api_key>"

txtCmds = Dict{String,Function}( name => ( s -> s == " " ?
										  "You have to pass text to the command like: `/$name Hello World`" :
										  tostyle(s) )
								for (name, tostyle) in Tofrak.styles )

txtCmds["start"] = _ -> """Hi!
This Bot converts Text to various different unicode scripts.
Available Commands are:
 - /frak - ð�”‰ð�”¯ð�”žð�”¨ð�”±ð�”²ð�”¯
 - /bb - ð�”»ð�• ð�•¦ð�•“ð�•�ð�•–ð�•¤ð�•¥ð�•£ð�•¦ð�•”ð�•œ
 - /scr - ð�’®ð�’¸ð�“‡ð�’¾ð�“…ð�“‰
 - /mono - ð�™¼ð�š˜ð�š—ð�š˜ð�šœð�š™ð�šŠð�šŒð�šŽ
 - /sans - ð�–²ð�–ºð�—‡ð�—Œ-ð�—Œð�–¾ð�—‹ð�—‚ð�–¿
 - /b - ð���ð��¨ð��¥ð���
 - /it - ð��¼ð�‘¡ð�‘Žð�‘™ð�‘–ð�‘�
 - /bi - ð�‘©ð�’�ð�’�ð�’… ð�’Šð�’•ð�’‚ð�’�ð�’Šð�’„
 - /bfrak - ð�•­ð�–”ð�–‘ð�–‰ ð�•±ð�–—ð�–†ð�–�ð�–™ð�–šð�–—
 - /bscr - ð�“‘ð�“¸ð�“µð�“­ ð�“¢ð�“¬ð�“»ð�“²ð�“¹ð�“½
 - /bsans - ð�—•ð�—¼ð�—¹ð�—± ð�—¦ð�—®ð�—»ð�˜€
 - /isans - ð�˜�ð�˜µð�˜¢ð�˜­ð�˜ªð�˜¤ ð�˜šð�˜¢ð�˜¯ð�˜´
 - /bisans - ð�˜½ð�™¤ð�™¡ð�™™ ð�™žð�™©ð�™–ð�™¡ð�™žð�™˜ ð�™Žð�™–ð�™£ð�™¨"""

txtCmds["help"] = _ -> """Available Commands:
 - /frak - ð�”‰ð�”¯ð�”žð�”¨ð�”±ð�”²ð�”¯
 - /bb - ð�”»ð�• ð�•¦ð�•“ð�•�ð�•–ð�•¤ð�•¥ð�•£ð�•¦ð�•”ð�•œ
 - /scr - ð�’®ð�’¸ð�“‡ð�’¾ð�“…ð�“‰
 - /mono - ð�™¼ð�š˜ð�š—ð�š˜ð�šœð�š™ð�šŠð�šŒð�šŽ
 - /sans - ð�–²ð�–ºð�—‡ð�—Œ-ð�—Œð�–¾ð�—‹ð�—‚ð�–¿
 - /b - ð���ð��¨ð��¥ð���
 - /it - ð��¼ð�‘¡ð�‘Žð�‘™ð�‘–ð�‘�
 - /bi - ð�‘©ð�’�ð�’�ð�’… ð�’Šð�’•ð�’‚ð�’�ð�’Šð�’„
 - /bfrak - ð�•­ð�–”ð�–‘ð�–‰ ð�•±ð�–—ð�–†ð�–�ð�–™ð�–šð�–—
 - /bscr - ð�“‘ð�“¸ð�“µð�“­ ð�“¢ð�“¬ð�“»ð�“²ð�“¹ð�“½
 - /bsans - ð�—•ð�—¼ð�—¹ð�—± ð�—¦ð�—®ð�—»ð�˜€
 - /isans - ð�˜�ð�˜µð�˜¢ð�˜­ð�˜ªð�˜¤ ð�˜šð�˜¢ð�˜¯ð�˜´
 - /bisans - ð�˜½ð�™¤ð�™¡ð�™™ ð�™žð�™©ð�™–ð�™¡ð�™žð�™˜ ð�™Žð�™–ð�™£ð�™¨"""

stylenames = [ name |> uppercasefirst |> tostyle for (name, tostyle) in Tofrak.styles ]

function inlineQueryHandle(s)
	return InlineQueryResultArticle[ InlineQueryResultArticle(string(UUIDs.uuid4()),
					name, tostyle(s)) 
				for (name, tostyle) in zip(stylenames, values(Tofrak.styles)) ]
end

t = @async startBot(botApi; textHandle = txtCmds, inlineQueryHandle=inlineQueryHandle)

println("Ready...")

while true sleep(.1) end
