Edit message with VideoNote in Telebot - python

How can I edit VideoNote message and change old video note to another one in Telebot? I guess I need edit_message_media method, but I don't understand how to use it for video notes.
I've tried to do it this way:
bot.edit_message_media(chat_id=message.chat.id, message_id=message.message_id,
media=types.VideoNote(open("video.mp4", "rb")))
But it didn't work.

It seems it is impossible as for now (December 2022).
Telegram API has these methods for updating messages: editMessageText, editMessageCaption, editMessageMedia, editMessageReplyMarkup, stopPoll, deleteMessage,
The closest one is editMessageMedia but it expects InputMedia which in turn should be one of InputMediaAnimation, InputMediaDocument, InputMediaAudio, InputMediaPhoto, InputMediaVideo, but not VideoNote
Also, I tried editing this kind of message using the official Android and Windows clients but didn't find such an option.
I assume Telegram doesn't have this option at all.

Related

telethon auto reply messages

i need to write code that will read messages from user and reply but i’ve got to use exactly this function: GetDialogs Request, not event method. please help, can't find any information about it
The request you mention, GetDialogsRequest, is part of what's known as "raw API". Both pages of the documentation contain examples. However, as noted in the first link, you probably want to use client.iter_dialogs (the link again contains an example):
# Print all dialog IDs and the title, nicely formatted
async for dialog in client.iter_dialogs():
print('{:>14}: {}'.format(dialog.id, dialog.title))
This may not be the request you're looking for though, as this returns a list of open conversations. Following the documentation would be a good way to understand what's happening and what you should use.

Getting an image of a custom Discord embed

I need to programmatically get an image of a Discord embed. Here is an example of the kind of embed I mean.
I want to get an image like that without having to take a screenshot of the application myself. I'm hoping there's an easy way to get them, otherwise I may have to generate the images myself. I'm using discord.py.
You can use Message.embeds, then get the embed.image.url from the returned list.
For example, if you have a message object, my_message, you can do the following:
image_url = my_message.embeds[0].image.url
(This is assuming you've already got the message object. You can do this a number of ways, e.g. in your on_message event.)

How would I convert my discord.py discord bots code that I use to get a list of members in a voice channel to the new discord.py version?

I have a command that creates of list of members in a specific voice channel. For example !attendance general for the "general" voice channel. My issue is that some of the parts no longer work since i was using an older version of discord.py.I recently ran the cmd line to upgrade discord.py and it seems a bunch of commands are now different.
My question is how do I get a specific channel and find its member list now? Below is my old code that no longer works.
https://i.imgur.com/TP8He1X.png
The part of code thats causing trouble is in the link. basically it loops through all voice channels for a specific one named general, then goes through each user in voice and checks if they have the tag "guest". If they do it adds to a list.
It seems that im not able to get a list of channels or loop through the members using ch.voice_members anymore, does anyone know the new formatting/commands for these issues?
Im summary I need to find commands for being able to check if a channel matches and then a way to loop through all the users.
I took a look at the discord.py docs - https://discordpy.readthedocs.io/en/latest/api.html
looks like you can change
for user in ch.voice_members
to
for user in ch.members
Looks like there are no longer separate properties for member lists

Python Telegram pytg post content to a channel

I am trying to post some messages on a channel using the pytg library which is also using the vysheng telegram-cli. I tried some options like
sender.send_msg("ChannelName", "Message")
sender.fwd("ChannelName", msg.id)
From these lines I am getting this error message
pytg.exceptions.FailException: Error 71: 'RPC_CALL_FAIL 400: CHANNEL_MESSAGES_DISABLED'
Searching inside Google/GitHub I did find this vysheng issue # 1033 that mentions that we need to send a post to a channel and not a message. But the pytg help(Sender) does not mention anything similar.
I have looked into the possibility of using a bot or other libraries but it's not really what I want.
Is there somebody familiar with pytg that can direct me in the proper direction?
Thx in advance
I was able to achieve this by using the raw command inside pytg, I guess there's a better solution out there but for the moment this one works!
sender.raw("post #nameOfChannel " + msg.text)

Get spotify currently playing track

EDIT : Let's try to clarify all this.
I'm writing a python script, and I want it to tell me the song that Spotify is currently playing.
I've tried looking for libraries that could help me but didn't find any that are still maintained and working.
I've also looked through Spotify's web API, but it does not provide any way to get that information.
The only potential solution I found would be to grab the title of my Spotify (desktop app) window. But I didn't manage to do that so far.
So basically, what I'm asking is whether anyone knows :
How to apply the method I'm already trying to use (get the window's title from a program), either in pure python or using an intermediary shell script.
OR
Any other way to extract that information from Spotify's desktop app or web client.
Original post :
I'm fiddling with the idea of a python status bar for a linux environment, nothing fancy, just a script tailored to my own usage. What I'm trying to do right now is to display the currently playing track from spotify (namely, the artist and title).
There does not seem to be anything like that in their official web API. I haven't found any third party library that would do that either. Most libraries I found are either deprecated since spotify released their current API, or they are based on said API which does not do what I want.
I've also read a bunch of similar question in here, most of which had no answers, or a deprecated solution.
I thought about grabbing the window title, since it does diplay the information I need. But not only does that seem really convoluted, I also have difficulties making this happen. I was trying to get it by running a combination of the linux commands xdotools and xprop inside my script.
It's worth mentionning that since I'm already using the psutil lib for other informations, I already have access to spotify's PID.
Any idea how I could do that ?
And in case my method was the only one you can think of, any idea how to actually make it work ?
Your help will be appreciated.
The Spotify client on Linux implements a D-Bus interface called MPRIS - Media Player Remote Interfacing Specification.
http://specifications.freedesktop.org/mpris-spec/latest/index.html
You could access the title (and other metadata) from python like this:
import dbus
session_bus = dbus.SessionBus()
spotify_bus = session_bus.get_object("org.mpris.MediaPlayer2.spotify",
"/org/mpris/MediaPlayer2")
spotify_properties = dbus.Interface(spotify_bus,
"org.freedesktop.DBus.Properties")
metadata = spotify_properties.Get("org.mpris.MediaPlayer2.Player", "Metadata")
# The property Metadata behaves like a python dict
for key, value in metadata.items():
print(key, value)
# To just print the title
print(metadata['xesam:title'])
For windows:
The library can be found at github: https://github.com/XanderMJ/spotilib. Keep in mind that this is still work in progress.
Just copy the file and place it in your Python/Lib directory.
import spotilib
spotilib.artist() #returns the artist of the current playing song
spotilib.song() #returns the song title of the current playing song
spotilib.artist() returns only the first artist. I started working on an other library spotimeta.py to solve this issue. However, this is not working at 100% yet.
import spotimeta
spotimeta.artists() #returns a list of all the collaborating artists of the track
If an error occurs, spotimeta.artists() will return only the first artist (found with spotilib.artist())

Categories

Resources