Otann / morse

📡 Clojure interface for Telegram Bot API
Eclipse Public License 1.0
257 stars 48 forks source link

Message is sent but throws an exception #55

Closed ayush000 closed 3 years ago

ayush000 commented 4 years ago

I tried sending the message as per the example in the docs

(api/send-text token chat-id "Hello, fellows")

When I run the code using TELEGRAM_TOKEN="..." TELEGRAM_CHAT_ID="..." lein run, although I receive the message on my telegram, I get the exception (attached below). It seems it's trying to parse a JSON that isn't valid. When I comment the above line of code, everything is working.

{:clojure.main/message
 "Syntax error (NullPointerException) compiling at (/private/var/folders/n5/nsp1_zz15_39bkr4d8n97j3c0000gn/T/form-init7703393975619659398.clj:1:125).\nnull\n",
 :clojure.main/triage
 {:clojure.error/phase :compile-syntax-check,
  :clojure.error/line 1,
  :clojure.error/column 125,
  :clojure.error/source "form-init7703393975619659398.clj",
  :clojure.error/path
  "/private/var/folders/n5/nsp1_zz15_39bkr4d8n97j3c0000gn/T/form-init7703393975619659398.clj",
  :clojure.error/class java.lang.NullPointerException},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message
    "Syntax error compiling at (/private/var/folders/n5/nsp1_zz15_39bkr4d8n97j3c0000gn/T/form-init7703393975619659398.clj:1:125).",
    :data
    {:clojure.error/phase :compile-syntax-check,
     :clojure.error/line 1,
     :clojure.error/column 125,
     :clojure.error/source
     "/private/var/folders/n5/nsp1_zz15_39bkr4d8n97j3c0000gn/T/form-init7703393975619659398.clj"},
    :at [clojure.lang.Compiler load "Compiler.java" 7648]}
   {:type java.lang.NullPointerException,
    :at [clojure.core$apply invokeStatic "core.clj" 665]}],
  :trace
  [[clojure.core$apply invokeStatic "core.clj" 665]
   [clojure.core$apply invoke "core.clj" 660]
   [clj_http.client$json_decode invokeStatic "client.clj" 131]
   [clj_http.client$json_decode doInvoke "client.clj" 127]
   [clojure.lang.RestFn invoke "RestFn.java" 421]
   [clj_http.client$decode_json_body invokeStatic "client.clj" 457]
   [clj_http.client$decode_json_body invoke "client.clj" 449]
   [clj_http.client$coerce_json_body invokeStatic "client.clj" 465]
   [clj_http.client$coerce_json_body doInvoke "client.clj" 460]
   [clojure.lang.RestFn invoke "RestFn.java" 445]
   [clj_http.client$eval3960$fn__3961 invoke "client.clj" 527]
   [clojure.lang.MultiFn invoke "MultiFn.java" 234]
   [clj_http.client$output_coercion_response
    invokeStatic
    "client.clj"
    561]
   [clj_http.client$output_coercion_response invoke "client.clj" 558]
   [clj_http.client$wrap_output_coercion$fn__4004
    invoke
    "client.clj"
    572]
   [clj_http.client$wrap_exceptions$fn__3801 invoke "client.clj" 249]
   [clj_http.client$wrap_accept$fn__4057 invoke "client.clj" 726]
   [clj_http.client$wrap_accept_encoding$fn__4064
    invoke
    "client.clj"
    748]
   [clj_http.client$wrap_content_type$fn__4051 invoke "client.clj" 709]
   [clj_http.client$wrap_form_params$fn__4160 invoke "client.clj" 950]
   [clj_http.client$wrap_nested_params$fn__4181
    invoke
    "client.clj"
    984]
   [clj_http.client$wrap_flatten_nested_params$fn__4190
    invoke
    "client.clj"
    1008]
   [clj_http.client$wrap_method$fn__4118 invoke "client.clj" 884]
   [clj_http.cookies$wrap_cookies$fn__415 invoke "cookies.clj" 131]
   [clj_http.links$wrap_links$fn__1929 invoke "links.clj" 63]
   [clj_http.client$wrap_unknown_host$fn__4198
    invoke
    "client.clj"
    1037]
   [clj_http.client$request_STAR_ invokeStatic "client.clj" 1165]
   [clj_http.client$request_STAR_ invoke "client.clj" 1158]
   [clj_http.client$post invokeStatic "client.clj" 1183]
   [clj_http.client$post doInvoke "client.clj" 1179]
   [clojure.lang.RestFn invoke "RestFn.java" 423]
   [morse.api$send_text invokeStatic "api.clj" 73]
   [morse.api$send_text invoke "api.clj" 67]
   [morse.api$send_text invokeStatic "api.clj" 69]
   [morse.api$send_text invoke "api.clj" 67]
   [github_amazon_bot.core$_main invokeStatic "core.clj" 28]
   [github_amazon_bot.core$_main invoke "core.clj" 19]
   [clojure.lang.Var invoke "Var.java" 380]
   [user$eval140 invokeStatic "form-init7703393975619659398.clj" 1]
   [user$eval140 invoke "form-init7703393975619659398.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7177]
   [clojure.lang.Compiler eval "Compiler.java" 7167]
   [clojure.lang.Compiler load "Compiler.java" 7636]
   [clojure.lang.Compiler loadFile "Compiler.java" 7574]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$init_opt invokeStatic "main.clj" 477]
   [clojure.main$init_opt invoke "main.clj" 477]
   [clojure.main$initialize invokeStatic "main.clj" 508]
   [clojure.main$null_opt invokeStatic "main.clj" 542]
   [clojure.main$null_opt invoke "main.clj" 539]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :phase :compile-syntax-check}}
zackteo commented 4 years ago

Sorry by chat-id you mean telegram id right? :o From this I can't quite identify what's wrong but perhaps you could look at my implementation of a angel and mortal bot https://github.com/zackteo/Angel-N-Mortal-telebot

Sandarr95 commented 4 years ago

Hi, I ran into the same issue. Fixed it by removing my own dependency on [clj-http "3.10.1"]. Don't have time to further investigate what's exactly going wrong right now. But maybe this will also fix it for you.

ayush000 commented 3 years ago

Thanks @Sandarr95. That worked. I'm no longer getting the exception.