I don't understand what the module wants from me and how to get this attribute - http

I don't understand what they want from me and what he needs why he doesn't see this attribute, I don't know either
File "C:\Users\Антон\Desktop\бот дс\bot\main.py", line 26, in on_member_update
channel = client.get_channel(1064939728023080970) # notification channel
AttributeError: module 'http.client' has no attribute 'get_channel'
I tried to install the http module and http-client, but nothing helps

Related

How to change irazasyed/telegram-bot-sdk's default request values of BASE_BOT_URL and the handler's verify option?

In order to connect my bot to the local bot API server and in order to turn curl's SSL verify_host and verify_peer off, how can I change irazasyed/telegram-bot-sdk's default request values of BASE_BOT_URL and the handler's verify option, not hard coding?
I know that I can change the BASE_BOT_URL constant in telegram-bot-sdk's TelegramClient class. And I know that I can change the verify option of my request handler to be false in guzzle's CurlFactory class. But, I'm not interested in hard-coding or overwriting these vendor files to avoid any update challenges in the future. I am more interested in something like longman/telegram-bot's setCustomBotApiUri function. The closest I could get is working with telegram-bot-sdk's setHttpClientHandler function, but I'm having trouble how to work with that.
Appreciate any help
P.S. I am using irazasyed/telegram-bot-sdk:^3.6 in my laravel:^9.2 app.

pyTelegramBotAPI message handlers can't see photo

I need my telegram bot to forward messages from the private chat to the customer care staff group.
I run this code:
#bot.message_handler(func=lambda message: message.chat.type=='private')
def forwarder(message):
bot.forward_message(group, message.chat.id, message.id)
bot.send_message(group, '#id'+str(message.chat.id))
It works smoothly with text messages, but does nothing with photos.
Even if I remove all previous message handlers, so there is no conflict with them to handle photos, it still keeps doing nothing.
If I use the get.updates() method I can check "manually" if the photo has arrived and I find it.
Edit: Even if i just run this code only
import telebot
bot = telebot.TeleBot("MY TOKEN")
#bot.message_handler(func=lambda message: True)
def trivial(message):
print('yes')
bot.polling()
I get 'yes' for text messages and absolutely nothing, not even raised exceptions for photos.
If you add content_types as a parameter you will receive whatever is specified in the argument (which takes an array of strings). Probably the default value for that parameter is set to ['text']. Which will only listen for 'text' messages.
To get the results you're looking for
your test code will look like:
import telebot
bot = telebot.TeleBot("MY TOKEN")
#bot.message_handler(func=lambda, message: True, content_types=['photo','text'])
def trivial(message):
print('yes')
bot.polling()
And your working code:
#bot.message_handler(func=lambda, message: message.chat.type=='private', content_types=['photo','text'])
def forwarder(message):
bot.forward_message(group, message.chat.id, message.id)
bot.send_message(group, '#id'+str(message.chat.id))
In Telegram Bot API there is a resource /sendphoto
See:
Sending message in telegram bot with images
Try to find the related method in the PyTelegramBotApi.
Or implement the function to send a photo your own (e.g. using requests library in Python). Then you can use it in the message-handlers of your bot, to forward images.

AttributeError: 'grpc._cython.cygrpc._ServicerContext' object has no attribute 'add_done_callback'

I am using grpc.aio.server(). My objective is to detect a client disconnect on the server side.
I'm trying to register a callback using the context on server side using add_done_callback(), but it does not seem it exposed for grpc._cython.cygrpc._ServicerContext
The documentation here mentions the callback, but I can't seem to be able to get it to work.
Note, if I use grpc.server() instead, I can set add_callback()
I'm using:
aiogrpc 1.8
grpcio 1.36.1
grpcio-tools 1.35.0
Any help appreciated.

SAFE template Elmish redux dev tools message always "UserMsg"

I'm quite new to Elmish. Did a sample template using dotnet new SAFE. When I open the app and use redux dev tools Chrome extension I always get message which is "UserMsg". Is there a way to make it "Increment" or "Decrement" when I click the button "-" or "+"?
The elmish-browser Navigation module wrap all messages in the Parser type which is a union of either Change (for a URL change) or UserMsg (for everything else).
This breaks the reflection in both withDebugger and withConsoleTrace... they are unable to grab the name of the underlying message, and hence display the wrapped name instead.
The work-around is to invoke toNavigable after withDebugger in the program initialization pipeline:
Program.mkProgram init update view
#if DEBUG
|> Program.withConsoleTrace
#endif
|> Program.withReactBatched "elmish-app"
#if DEBUG
|> Program.withDebugger
#endif
|> Program.toNavigable (parseHash route) urlUpdate
|> Program.run
However, by doing this the "Change" messages are no longer sent to the debugger. This could be a problem if your urlUpdate function is updating the model state directly. It may be better for your urlUpdate function to raise a new command with a message to be handled by the main update function.
See https://github.com/elmish/browser/issues/26

What is causing the exception HRESULT: 0xC0C01B22 when attempting to enlist a send port with a filter?

This is a simple send port, in which I'm trying to setup a filter over a promoted property. Whenever I attempt to enlist this port, I get the following error:
===================================
Could not update Send Port 'SendPort1' in Message Box. Exception from HRESULT: 0xC0C01B22 (Microsoft.BizTalk.ExplorerOM)
------------------------------
For help, click: http://go.microsoft.com/fwlink/?LinkId=47400&ProdName=Microsoft+BizTalk+Server+2013&ProdVer=3.10.229.0&EvtSrc=Microsoft.BizTalk.ExplorerOM.Resources&EvtID=IDS_ERR_SENDPORT_UPDATE
------------------------------
Program Location:
at Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer.SaveChangesWithTransaction(Object transactionObj)
at Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer.SaveChanges()
at Microsoft.BizTalk.Administration.SnapIn.Forms.Common.ExplorerPropertyPagesContainer.CommitChanges()
at Microsoft.BizTalk.SnapIn.Framework.Forms.PropertyPagesContainer.Store()
at Microsoft.BizTalk.SnapIn.Framework.Forms.SheetFramework.Store()
The filter simply checks for existence of the promoted property in the incoming message. There's only one post in MSDN forums about this exception: HRESULT 0xC0C01B22
Any idea what is causing this?
The answer is in this page: https://learn.microsoft.com/en-us/biztalk/core/promoting-properties
The note there says the following:
XSD Data Type of base64Binary, duration, ENTITES, hexBinary, IDREFS, long, NMTOKENS, and unsignedLong are not supported for promotion.
Turns out, in our case, the promoted property is of xs:long type. I changed the element type to xs:string then the issue in the question went away.
It would make sense to prevent the promotion of the elements if they are of unsupported type, in the beginning itself. But we don't get to see any alerts during the promotion phase for such elements.
Hope this helps someone.

Resources