I don't understand how to comment on channels in Pyrogram
I hope you can give me an example of the comment channel. Thank you very much
Commenting on channels is the same as sending message because comments are basically replies to the auto-forwarded message (every channel message is auto forwarded to the linked group). The only difference is users can reply to the message without really being in the group.
If you already have the message (the group message):
await message.reply("See my comment")
Or you can get the message using id of the message in linked group. Look at the documentation of get_discussion_message for further.
You should have access to post on the associated discussion group.
Then you can use the below script to send a message as a comment on Pyrogram 2.0+.
from pyrogram import Client
Credentials = Client(
name="comment_on_channel",
api_id=---,
api_hash="---",
device_model="Comment On Channel",
app_version="CoCh v1.0",
)
with Credentials as app:
# Group's Numeric ID with corresponding -100 [integer]
group_ID = -1001234567890
# ID of the message that you want to reply to (ID of a post in the discussion group) [integer]
msg_ID = 165
app.send_message(
chat_id=group_ID,
reply_to_message_id=msg_ID,
text="My Comment"
)
Related
Is there a way to let the bot send a message and get the ID of the message, so you can delete it a few seconds later?
ps. discord.py
The only possible way I found was, to just delete the last sent message in the channel.
there is two Q here:
yes there is a way to get the id for example:
message = await ctx.send("hi")
message_id = message.id
to delete a message a few seconds later you can use delete_after
for example:
await ctx.send("hi",delete_after = 10)
The channel.send() method has a kwarg exactly for this purpose, delete_after. You set it's value when sending a message and it will automatically delete the message after that time (in seconds). Here's the docs for the channel.send coroutine(/function) https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.send
I have 2 APNs, they share the same provider, same device token. First one is delivered, second one not.
payload={"aps":{"badge":0,"alert":{"action-loc-key":"View","body":"Some guy: Hey man"},"sound":"NewMessage.caf"}} <- this one is delivered
payload={"aps":{"badge":0,"alert":{"action-loc-key":"","body":""}}} <- this one not delivered
I could not find any info about empty body in Apple docs.
So, why it's not delivered?
The payload must include an alert dictionary with title, subtitle, or body information.
Empty values are treated as missing.
I'm trying to response to user on subscribe. By example, in a chatroom when an user connect to subscription, the subscription responses him with data (like a welcome message), but only to same user who just connect (no broadcast).
How can I do that? :(
Update: We resolve to use channels. DjangoChannelsGraphqlWs does not allow direct back messages.
Take a look at this DjangoChannelsGraphQL example. Link points to the part which is there to avoid "user self-notifications" (avoid user being notified about his own actions). You can use the same trick to send notification only to the user who made the action, e.g. who just subscribed.
Modified publish handler could look like the following:
def publish(self, info, chatroom=None):
new_msg_chatroom = self["chatroom"]
new_msg_text = self["text"]
new_msg_sender = self["sender"]
new_msg_is_greetings = self["is_greetings"]
# Send greetings message only to the user who caused it.
if new_msg_is_greetings:
if (
not info.context.user.is_authenticated
or new_msg_sender != info.context.user.username
):
return OnNewChatMessage.SKIP
return OnNewChatMessage(
chatroom=chatroom, text=new_msg_text, sender=new_msg_sender
)
I did not test the code above, so there could be issues, but I think it illustrates the idea quite well.
Trying to update an outgoing caller ID, but running into following error:
*** Twilio::REST::RestError Exception: Unable to fetch record: The requested resource /2010-04-01/Accounts/AC...../OutgoingCallerIds/CA......json was not found
I'm following the docs on Twilio's website:
https://www.twilio.com/docs/api/voice/outgoing-caller-ids#get-outgoing-caller-id-details
#caller_id = #client.account
.outgoing_caller_ids('PNe905d7e6b410746a0fb08c57e5a186f3')
.fetch
What string do I need to pass to .outgoing_caller_ids?
Twilio developer evangelist here.
Outgoing caller IDs are verified numbers that you can use as a caller ID when you're making calls from your account.
I was able to fetch an outgoing caller ID with the following code:
sid = client.outgoing_caller_ids.list.first.sid
caller_id = client.outgoing_caller_ids(sid).fetch
My guess is that you are actually looking for the Incoming Phone Numbers resource, which is the resource you can use to fetch and update numbers that you bought on the Twilio platform.
You can call that with the number SID like this:
client.incoming_phone_numbers(sid).fetch
Let me know if that helps.
I created a bot that replies to mails. I use the Message.CreateReplyMessage(...) method.
The created message will contain the "Re: " prefix in it's subject but the body will not contain the previous messages on the thread, or at least the message sent to the bot.
Is there a way to have the body include the previous messages so it would look more like when we reply from outlook?
Thanks,
Uri
You have the full text of the message in the call to your bot. You can just append it to the end of your reply