Force subscribe to channel to use the bot [aiogram] - python

I have a simple chat-bot writed with aiogram for receiving messages from users and answering to them. I want to make sure that user is subscribed to a particular channel before he can use my bot. How can I implement that?

Use getChatMember method and then check status field of the ChatMember

Related

How to handle messages in a Telegram Bot?

My goal is to make a Telegram Bot using Python that does the following:
The user types a command
The bot explains what the user should type next.
The user types certain information
I use that info to fetch a value in a python dictionary.
The bot replies with that info
I have already created the bot and set the command. The problem is that I don't know how to keep the bot "listening" . I have looked up in the docs but I have only found getUpdates, which gets the user's responses but only when you hit run.
res=requests.get(url=f"https://api.telegram.org/bot{bot_token}/getUpdates")
I would like to set a webhook, and I know there is a method for this but I'm not shure about how this works.
When you are a PHP programmer, setting the webhook through a URL and using setWebhook would do the trick and telegram will send the result to this link whenever a user sends an update to the bot. But, Python programmers have to use a different approach, I think. The main, and while, the easiest approach to make the bot listen permanently to the request is to python-telegram-bot module.
There are a few links that can help to build your first pythonic bot that can respond to users' updates.:
Python-Telegram-Bot Repository, which is the repository of the module.
A few examples of bots created using this module, can give you insight into the process of creating your first bot.
A conversation bot

Python discord webhook doesn't really mention role

I have a problem with mentioning role with discord webhook. I'm using discord_webhook library.
When I try to mention a role webhook tags it and it looks fine but it didn't really ping users from that group. The message isn't also highlighted for them. That's not how the group mention should work
In code my mention looks like this:
<#&823xxxxxxxxxxx01>
But in real webhook:
webhook
Do you know how to make the webhook with notification highlithed for specific group? Of course my ping doesn't make classic discord ping sound (or notification)
You can not ping someone inside embed message. You need to send ping first, embed then (or embed first and ping seccond).
It's because discord is thinking you are doing some kind of role list without mentions (like role shop)

Is it possible to harvest messages from other peoples discord servers?

Can I use the discord API in python to harvest messages from a server (not my own server)? Assuming you have an invite link.
Thanks
Yes, it would be possible. If you look under the TextChannel section of the Discord Models section of the discord.py API Reference, there is the TextChannel history() method. This can be used to parse all the messages in a channel. If the limit argument of the method is set to None, then all the messages in the channel will be returned.
Since you say that the bot already has an invite, that implies they have access to a good part of the server. The method I mentioned requires the following permissions for your bot:
See Text Channels
Read Message History
Well, if your using a discord bot, you need them to invite your bot to their server.
Other than that you could theoretically listen with a bot on your own account but that would be against the discord TOS.
You can achieve this through a discord bot. Given that bots respond to events that fire within servers they reside in, you can listen in to incoming messages.
An example of such event can be found in discord-py documentation.

How to access discord messages from main account instead of bot account

I've got a bluetooth RGB bulb that I want to use for notifications in discord. It seems that following standard guides I would need to get an admin to add a bot account to each discord I wanted this functionality in.
Is there a way to get access to messages accessible in my main account without getting another account/bot added? I only need to be able to read out the messages so I can parse them and trigger RGB stuff.
I would prefer to do this in python if possible but other solutions are fine if need be.
Self bots are against discord's TOS.
You can try using on_message(message) and using that to parse the message.content

Python telegram bot - can the bot send the first message in chat?

Is it possible to get a bot to send the first message in the chat without running a command like "/Start"?
Maybe it possible to save the chat_id of the requested user in advance and send him a message in the future, thus allowing the bot to send a first message in chat according to a predefined condition that will trigger him?
I searched for an answer online but could not find one.
Can you send me a link to a tutorial that explains how to do this?
Thanks in advance
Yoav Giladi :)
One solution is to use a Telegram Bot deeplink to provide an entry point to the Chatbot that does not require the users typing the /Start command.
After the very first interaction you can the obtain the chat_id which can be stored for using it to initiate a message later:
context.bot.send_message(chat_id, text='Howdy')

Categories