Add member to telegram channel - telegram

I have been looking for a way to add a number of users to a telegram channel (with users id) for a long time and I didn't find anything. (I'm sure there is such a thing because I know people who do it but IDK and they don't tell me how it is done).

First of all, please note that only the first 200 members can be added to a Telegram channel, and you should be aware that you are subject to get limited or banned if you abuse the Telegram API.
You can add members to a Telegram channel by calling the channels.inviteToChannel method.
If you use Python, you can do that easily with Pyrogram:
client.add_chat_members(
channel_id,
[user_ids],
)
You can also call the method easily with GramJS, if using JavaScript:
client.invoke(
new Api.channels.InviteToChannel({
channel: channelId,
users: [userIds],
})
)

Related

read a direct message when arrival using telegram_api

i am working with an app and it needs to read direct messages from telegram when they arrive.
i searched on google but all i got was how to send a message not how to read brand new dms.
Thanks!
Telethon: Make sure you read the basics in the Docs to understand how to handle events.
I'm assuming you meant "mark as read", if not, read the docs, else read below:
in the event object you get to your callback, you have multiple unique convenience methods, and all the ones available on a Message object, one of them is event.mark_read()
to limit it only to send read requests to private chats; configure handler as needed, a minimal example:
#client.on(events.NewMessage(func=lambda e: e.is_private))
async def read_it_callback(event):
await event.mark_read()
you can also use client.send_read_acknowledge()

How to invoke an intent through a custom event by calling it from the dialogflow's inline fulfillment code?

Here is the image link of my problem statement better explained through a flow.
problem statement flow
I couldn't understand How this can be achieved.
Just starting with web-hooks and dialog flow.
Thanks in advance
In most cases, you probably don't want or need to trigger a different Intent.
Remember - Intents should match the user's input (usually what they say), not necessarily what you do or how you reply.
If you need to access the database for certain values - access it in the webhook for the Intent where you get the value. If you need to reply certain ways for some values and different ways for others - go ahead and do it.
You can use conv.followup in your dialogflow fulfillment to invoke the intent with custom event as below :
database().ref('/path').on('value', function(snapshot) {
if(snapshot.val == 'val'){
conv.followup('triggering-event'); //enter your event name here
// make sure you have defined the event in the intent to trigger !
}
});
Consider reading this before dealing with intents.
Hope that helps!

Granular domain events

Initially we were using Domain events to handle communications with external systems. For instance, every time a user was updating his phone number OR his name we raise a PhoneNumberUpdated AND a NameUpdated event. These are then caught by handlers processed and sent to other systems.
public void SetName(Name name)
{
if (Name == name) return;
(...)
RaiseEvent(new NameUpdated(Id, name));
}
public void SetPhoneNumber(PhoneNumber number, PhoneNumberType type)
{
RaiseEvent(new PhoneNumberUpdated());
}
It works great as long as we do not need to "aggregate" events. For example, we got a new requirement asking us to to send one single email whenever a user updates his name and/or his phone number. With the current structure, our handlers would be notified multiples times (one time for each event raised) and this would result in multiple emails sent.
Making our events more generic don't seem to be a good solution. But then how would we aggregate several events raised within one transaction?
Thx
Seb
I believe your new requirement is a separate concern from your actual domain. Your domain generates events that describe what has happened. User notification, on the other hand, is a projection of that stream of events into email form. Just like you would keep your read model requirements separate from your domain, you should keep this separate as well.
A simple solution would be to capture the events you care about into a table and then once a day, on a schedule, and send one email per aggregate.

Firebase client-side fan-out performance

for my new app i use this method
https://firebase.googleblog.com/2015/10/client-side-fan-out-for-data-consistency_73.html
i think that is a good method for a person that have a number of followers less than 1 million. i try and up to this number is fine. but for person that have 10kk
of followers the client get in crash because you get a big array of 10kk followers and short it to create another big array of 10kk of path activities.
I just wanted to point out this point, i think that this is a solution that work only with app that have a few numbers of users. finally We're forced to use server-side solutions. and this is bad for the general app efficency
would be a nice feature a function that allow this thing by firebase side with less cost in the client side. i think a feature like this. i make an example in javascript
var obj = { created: time } var path = "FollowersActivity/uid/" var followers = 'root.child("Followers").child("uid").val()' function massSaved(obj, path, followers)
by firebase server side the server get all childs by "followers" path and by foreach cycle append every follower name at the "path" string and save all objects. in this mode the client send only fews strings at firebase server without get all followers and make other big array of activity. probably my example not work because i not know the firebase infrastructure but is only an example to suggest an idea to conclude these operations entirely on the server side

Efficient pattern for updating a subscription limit argument

I'm using subs-manager, but the answer to this may be independent of that lib.
I have a subscription with a single limit argument. Currently, when I call subs.subscribe 'subname', newLimit, another subscription is added.
The old subscriptions are still there. I don't want Meteor to spend time maintaining the old, lower-limit subscriptions. Instead of adding a new subscription, I want to update the argument of the old subscription. What is the best way to do this?
Note that I also don't want to completely tear down eg 'subname', 20 before subscribing to 'subname', 40, because I don't want Meteor to do the extra work of resending the first 20 docs – I want it to just send docs 21 - 40.
You could have a look at your subscription's stop() method. According to the docs:
stop() [cancels] the subscription. This will typically result in the server directing the client to remove the subscription's data from the client's cache.
So the way I see it, you could maybe manage to do:
// globals or whatever
var previousSub, newSub;
// somewhere else
newSub = Meteor.subscribe('subname', newLimit, function () {
if (previousSub)
previousSub.stop();
previousSub = newSub;
});

Resources