I want to know, is there a way, to get a of a chat which i'm joining my bot to?(using pyrogram)
like, i created a chat manager bot, and when i'm joining him to chat, i want him to work in this specific chat.
But every function like get_chat_members() needs target id.
how do it get this?
i already found a solution
You can get in through a message form that chat.
Related
I'm developing a telegram bot using telepot, I'm trying to ask the user a question for example: What's your name?
Then wait for the user to type the name, and save it in a variable, but this is not a library method, I think.
So I decided to create my own method.
When asking the question "What is your name?" I will go to the telegram api and I will change the text field to empty so in the next function I will use a loop that does not break until the user's last message is different from empty, understand?
I access: https://api.telegram.org/bot/(enter image description heretoken)getUpdates
and I want to change this session:
(Change a message send by user)enter image description here
"message":{"message_id":1133,"from":{"id":5296812825,"is_bot":false,"first_name":"Vinicius","language_code":"pt-br"},"chat" :{"id":5296812825,"first_name":"Vinicius","type":"private"},"date":1652800679,"text":"Mensagem from User"}}] }
for
"message":{"message_id":1133,"from":{"id":5296812825,"is_bot":false,"first_name":"Vinicius","language_code":"pt-br"},"chat" :{"id":5296812825,"first_name":"Vinicius","type":"private"},"date":1652800679,"text":"EMPTY"}}] }
No; Bot's can't alter messages send by an user
A Telegram bot can only alter/delete his own messages.
Luckily, otherwise every message you send could be altered by some random bot, this would lead to insecure behaviour for sure.
I am looking to delete a photo sent by my bot (reply_photo()), I can't find any specific reference to doing so in the documentation, and have tried delete_message(), but don't know how to delete a photo. Is it currently possible?
It's currently possible in Telegram API, not the Bot API unfortunately. It's a shame :(
I found a workaround (that I am currently still playing with). I named the photo I sent, then when I want to delete it, I delete it using .delete(). For example:
photo = x.message.reply_photo(...)
...
...
photo.delete()
You need to have the chat_id and the message_id of that message sent by bot, then you can delete using context.bot.delete_message(chat_id, message_id).
Note: Bot cannot delete a message if it was sent more than 48 hours ago.
I'm trying to create moderation commands for the telegram bot.
Currently to ban a user I reply to his message with a command, obtaining the user's id from the message.
This is all inconvenient, I'd prefer the command to be structured like this:
/warn <username>.
I couldn't find any way to get the user id from the username.
Is anyone able to point me in the right direction?
You can't do it using bot api - you shall use tdlib or account api except (with real telegram account with phone number).
But I see better option - as your bot exists in a group and you need only to ban users within the group, you can just store pairs username-id all the time from message updates you got by bot api. So then you check the username in your database and that's it
I have a bot that sends embeds that include emojis specific to each embed and it works great on my test server where I uploaded the emojis but they don't show up on other servers since those servers don't have the custom emoji.
using:
emoji = get(ctx.message.guild.emojis, name='emojinamehere')
works of course for the server it's in but is there a way to get and use all emojis from any servers the bot is in?
Because you're specifically using ctx.message.guild.emojis aka you're trying to get the emoji from the context guild (which might not have it).
You can get rid of get finding by name and just use bot.get_emoji() where bot is your bot/client object.
Your bot will store all emojis from all the guilds in internal cache and get_emoji() will retrieve it from there so it will work for all guilds.
You will need emoji ID (integer) to do this, not name as you're currently getting. You could get by name and then get its ID but that's just unnecessary steps.
Just use emoji ID as those are unique and can't change (names can both be duplicate and can change so you can get into problems getting by name).
You can quickly get emoji ID by using Discord client app:
enter custom emoji in the text box input
enter \ before emoji
send message to chat
message will transfom into somemthing like <:emoji_name:emoji_id>
Yes, this is necroposting, but this may help for anyone looking for the answer.
#client.command()
async def emoji(ctx, emojiname):
for i in client.guilds:
emoji = discord.utils.get(i.emojis, name=emojiname)
Of course you have to pass the emoji's name as the first argument.
Basically, in discord.py, I can use the login function like this:
client.login("email", "password") or client.login("token")
now, I have multiple questions (do I need to store the login function in a variable to access the member I log into's data?), but the most important that I would want an answer for, is can I make that member that I logged into join a specific server that I want (given an invite)?
This is no longer possible with the current Discord.py version.
Further clarification here