Closed cyphunk closed 3 years ago
Hey, @cyphunk! That can be done easily by passing a real instance of garnet.TelegramClient
to garnet.runner.run
as bot
parameter.
you can see the definition
you can also start
your TelegramClient
before you pass it run in order to customize an "early runtime".
LMK if this resolved your question!
I thought I had tried what you suggested. But perhaps I missed a step. In any case I switched to a ipv4 host due to being in a hurry.
thank you for your input though
For anyone interested this was the full code:
from _garnet.client import TelegramClient
bot = TelegramClient(
session=my_SESSION_DSN,
api_id=int(my_APP_ID),
api_hash=my_APP_HASH ,
use_ipv6=True
)
#bot = None # set to none to cause garnet to create ipv4 client instance
from garnet.events import Router
router = Router()
from garnet.runner import run, launch
from garnet.storages import JSONStorage
launch("botname", run(router, JSONStorage('state.json'), bot))
I will probably come back to this in the coming months and could try again. But this issue can probably be closed
Glad that was helpful, closing this now.
Thanks for pointing out your solution to the problem.
Not sure why but the boilerplate example I gave will not work. When I let garnet create the bot instance it works. When I create it as shown it fails. (and I fixed a minor error from before). Failure = no respons to requests from connected client. Success = response from connected clients
Honestly this bug seems strange. There appears to be no reason for this difference. I've double checked all the values, and the initialization. Modified garnet to show and compare resulting created TelegramClient instances. They appear similar or same
When running on ipv6 hosts get following error. Could you direct to where the underlying client option 'use_ipv6' could be set?