UDO6BBW7AQSREMZL2OHBTM6DXJAUCGBGR4Z7SKXTSUU4HHPW6WHQC
case update.message.text do
"/" <> command ->
reply = command(String.split(command))
case update do
%Nadia.Model.Update{message: %Nadia.Model.Message{text: text, chat: chat}} ->
case text do
"/" <> command ->
with {:ok, {reply, opts}} <- command(String.split(command)),
{:ok, _} <- Nadia.send_message(chat.id, reply, opts) do
:ok
else
{:error, err} ->
Logger.error("Error: #{err}")
:ok
end
{:error, err} ->
Logger.error("Telegram error: #{err}")
%Nadia.Model.Update{
callback_query: %Nadia.Model.CallbackQuery{data: data, message: message}
} ->
case data do
"/" <> command ->
with {:ok, {reply, opts}} <- command(String.split(command)),
{:ok, _} <- Nadia.send_message(message.chat.id, reply, opts) do
:ok
else
{:error, err} ->
Logger.error("Error: #{err}")
:ok
end
_ ->
def word_sentence(word) do
res =
Bolt.Sips.query!(
Bolt.Sips.conn(),
"""
MATCH (w:Word {word: $word})-[:OF_SENTENCE]-(s:Sentence)
WITH collect(s) as sentences
WITH apoc.coll.randomItem(sentences) as sentence
return sentence.text as text
""",
%{word: word}
)
[text] = res["text"]
text
end