visciang / telegram Goto Github PK
View Code? Open in Web Editor NEWTelegram library for the Elixir language
License: MIT License
Telegram library for the Elixir language
License: MIT License
hello, I'm back :)
I am getting the following error:
** (Mix) Could not start application my_app: MyApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: Telegram.Poller
** (EXIT) bad child specification, more than one child specification has the id: Telegram.Bot.ChatBot.Chat.Supervisor.
my Application
:
defmodule MyApp.Application do
use Application
alias MyApp.TelegramBot
@tg_bot_token_bot1 Application.compile_env!(:zuo_shou, :tg_bot_token_bot1)
@tg_bot_token_bot2 Application.compile_env!(:zuo_shou, :tg_bot_token_bot2)
@impl true
def start(_type, _args) do
bots = [
{TelegramBot.Bot1, bot_config(@tg_bot_token_bot1)},
{TelegramBot.Bot2, bot_config(@tg_bot_token_bot2)}
]
children = [{Telegram.Poller, bots: bots}]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
@spec bot_config(String.t()) :: Keyword.t()
defp bot_config(token), do: [token: token, max_bot_concurrency: 1]
end
I've double checked and the two tokens are definitely different (IO.inspect({@tg_bot_token_bot1, @tg_bot_token_bot2})
), so the issue is not the same as #153
first, thanks for the library!
I'm running the ChatBot
in Poller
mode and after a while it starts getting {:error, "Too Many Requests: retry after 5"}
every 10th of a second or so for a couple minutes before eventually dying all together (too many failures I suppose).
Is this an unhandled case that I could contribute somehow? Or can I set a larger polling timeout somewhere?
Would it be possible to implement the handle_info callback in ChatBot ?
Would be pretty useful to be able to update state of conversation based on other event or async processes.
I see the macro command
for example, or inline_query
, and I understand how to make calls from the bot to telegram, but how is the bot getting the calls from telegram?
If a user makes an inline query like @mybot query
, how does the DSL
gets this into the macro inline_query
. Should I call something from the webhook? Or is the bot getting updates instantaneously?
BTW Thank you, it is a pretty interface and better that it supports multiple bots as I understand. Thank you for the effort and I look forward to contributing ❤️
Hi,
thanks for creating this fantastic library.
currently, I'm having this problem.
first, I have two Bots BotA
and BotB
,
then, I add Poller to the Supervisor like this
bot_config = [
token: token,
max_bot_concurrency: 1_000
]
children = [
{Telegram.Poller,
bots: [
{BotA, bot_config},
{BotB, bot_config}
]}
]
Supervisor.init(children, strategy: :one_for_all)
after I start up my server, the error occurs.
** (Mix) Could not start application triforce: Triforce.Application.start(:normal, []) returned an error: shutdown: failed to start child: Triforce.Telegram.BotSupervisor
** (EXIT) shutdown: failed to start child: Telegram.Poller
** (EXIT) bad child specification, more than one child specification has the id: :"Elixir.Telegram.Poller.Task.xxxxxxx".
If using maps as child specifications, make sure the :id keys are unique.
If using a module or {module, arg} as child, use Supervisor.child_spec/2 to change the :id, for example:
children = [
Supervisor.child_spec({MyWorker, arg}, id: :my_worker_1),
Supervisor.child_spec({MyWorker, arg}, id: :my_worker_2)
]
am I using Poller the wrong way?
Hey
Playing around with a bot and trying to send a Photo, the multipart request just never completes. I get the log line before but never the one after.
It has now happened twice that one of my bots terminates due to an unhandled error condition when starting polling from the Telegram API:
09:53:56.481 [info] Running in polling mode
09:53:56.502 [error] Task #PID<0.1914.0> started from Telegram.Poller terminating
** (MatchError) no match of right hand side value: {:error, "Bad Gateway"}
(telegram 0.22.3) lib/poller.ex:113: Telegram.Poller.Task.set_polling/1
(telegram 0.22.3) lib/poller.ex:101: Telegram.Poller.Task.run/2
(elixir 1.14.2) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
(stdlib 4.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Function: &Telegram.Poller.Task.run/2
Args: [D2rBot.Telegram.Bot, "<token>"]
09:53:56.511 [notice] Application d2r_bot exited: shutdown
{"Kernel pid terminated",application_controller,"{application_terminated,d2r_bot,shutdown}"}
Kernel pid terminated (application_controller) ({application_terminated,d2r_bot,shutdown})
Crash dump is being written to: erl_crash.dump...done
I'm not sure what is happening. Maybe network connection is lost on my side. But I also have no idea how I should tolerate that on my side. I would expect the bot to just stay alive until the network connectivity is back or the Telegram API answers correctly. What do you think?
Telegram.Bot.Utils.get_chat/1 can't extract chat field when update type is callback_query due to additional nesting of it
Every time I do a telegram request I receive this message
[warning] Description: 'Authenticity is not established by certificate path validation'
Reason: 'Option {verify, verify_peer} and cacertfile/cacerts is missing'
do you know how can I silent that message?
thanks in advance.
What do you think about function "skip_updates" to prevent messages handling after bot starts? (I mean functionality like aiogram has)
How it is going now:
Bot is stopped --> we send message to bot --> we starting our bot --> it handles all the messages came before.
How it is supposed to be:
(skip_updates=true)
Bot is stopped --> we send message to bot --> we starting our bot --> bot doesn't know nothing about the messages before its start.
hello again :)
opening an issue to discuss a feature proposal. I've already found a workaround, but I thought to start a discussion about this use case & a more kosher api for it.
I have a bot which I would like to start proactively - for a user (me) where the id is known ahead of time. this bot is a ChatBot
and keeps state, messaging me every so often with a question which I respond to. so I want it to message me even if I haven't messaged it since the last restart.
after doing some digging my workaround is to just simulate sending it a message during application start:
bots = [{MyBot, [token: @token, max_bot_concurrency: 1]}]
children = [
{Telegram.Poller, bots: bots},
{Task,
fn ->
MyBot.dispatch_update(
[{:init, %{"chat" => %{"id" => @chat_id_me}, action: :init}}],
@token
)
end}
]
is this use case valid enough that maybe ChatBot
should support it in a non-hacky manner?
I'm not exactly sure what the api would look like if so. maybe some function like ChatBot.start(chatbot_behavior, chat_id)
(ChatBot.start(MyBot, @chat_id_me)
in the example above), which would call Chat.Session.Supervisor.start_child/2
?
hope this made sense!
I know :telegram is taken but I assume it could be published with another name on Hex.pm.
It would be convenient and I think it is a nice and useful library so I find it odd that it is only available via GitHub.
Is there a reason?
Hi. How I can use bot in Webhook mode with phoenix project?
I'm getting this error below with latest master branch could please confirm it?
My Env
OS: Linux
Elixir: 1.9 ~ 1.10.3
Erlang: erts-10.7.1
The Error
===> Verifying dependencies...
Unchecked dependencies for environment dev:
* ssl_verify_hostname (Hex package)
could not find an app file at "_build/dev/lib/ssl_verify_hostname/ebin/ssl_verify_hostname.app". This may happen if the dependency was not yet compiled or the dependency indeed has no app file (then you can pass app: false as option)
** (Mix) Can't continue due to errors on dependencies
I know this isn't a error from this project. if anyone have any idea of the problem please let me know thanks.
Probably am missing something but how do multiple commands work? I defined them as:
command stats do
...
end
command check do
...
end
but I get the following error:
warning: variable "stats" is unused (if the variable is not meant to be used, prefix it with an underscore)
lib/comicbot/telegram.ex:8: Comicbot.Telegram.handle_update/2
warning: this clause cannot match because a previous clause at line 8 always matches
lib/comicbot/telegram.ex:15
Thank you very much!
Use app config values for:
Api: timeout connect_timeout
Bot: poll_timeout, retry_quiet_period, delta_purge
I'm trying to create a Bot and as soon as it tries to make getMe request I receive next error on console until timed out:
[info] TLS :client: In state :hello received SERVER ALERT: Fatal - Handshake Failure
I suspect it's related with new Tesla upgrade missing?
Versions ma using:
Elixir: 1.11
ERL: 23
Telegram: 0.7.1
Cowlib: 2.9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.