You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
49 lines
1.2 KiB
module TelegramMarkov
|
|
|
|
function initialize end
|
|
function make_sentence end
|
|
function list_usernames end
|
|
|
|
function fetch_in_env(varname)
|
|
if !(varname in keys(ENV))
|
|
error_string = """
|
|
Please, set $varname in your environment. You can either set it in Julia by doing `ENV["$varname"]=something` or in your shell `export $varname=something`.
|
|
"""
|
|
@error error_string
|
|
""
|
|
else
|
|
ENV[varname]
|
|
end
|
|
end
|
|
|
|
|
|
include("bot.jl")
|
|
|
|
include("markov.jl")
|
|
|
|
include("server.jl")
|
|
|
|
import .Markov: initialize, make_sentence, list_usernames
|
|
|
|
function run_server()
|
|
@info "Initializing bot"
|
|
Markov.initialize()
|
|
application = Server.application()
|
|
@info "Starting Telegram not now"
|
|
Bot.run_bot(Bot.TELEGRAM_BOT) do message
|
|
@debug "Got a message" message
|
|
request = Dict(:message=>message[:message], :params=>Dict())
|
|
ret = application(request)
|
|
@debug "I got this ret" ret
|
|
if !isnothing(ret)
|
|
chat_id = message[:message][:chat][:id]
|
|
reply_to = message[:message][:message_id]
|
|
Bot.sendMessage(Bot.TELEGRAM_BOT, chat_id=chat_id, text=ret, reply_to_message_id=reply_to)
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
export run_server
|
|
|
|
end
|
|
|