Undo "Hidden history for new members" in Telegram group - telegram

Is there a way to revoke hidden history for existing members of a private Telegram group?
Right now, if a new member joins while hidden history is turned ON, there is no way to re-enable it back for them (for example after they have solved a captcha). Strangely enough, if the same member is kicked out, hidden history gets disabled and they rejoin, they still cannot see the historical messages.
I am looking for a solution to this using either the official API or the telethon wrapper (an endpoint would suffice).

You need to use the TogglePreHistoryHiddenRequest function.
from telethon.sync import TelegramClient
from telethon import functions, types
api_id = 121212
api_hash = "97dsakn421hdsapogjdmaewod"
with TelegramClient("anon", api_id, api_hash) as client:
result = client(functions.channels.TogglePreHistoryHiddenRequest(
channel='username',
enabled=False
))
print(result.stringify())
If enabled is False, the chat for new members is visible. Otherwise is hidden.

Related

Add member to telegram channel

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],
})
)

Listen for state changes from redux-thunk action creator

I can't see a clear way to know when a particular action has fired or particular state has updated from the context of a redux-thunk action creator.
I want to do something like this:
Dispatch an action
Detect a possible recoverable error condition
Error condition dispatches a different action signalling recovery process initiating
Wait for recovery to complete
Proceed with current action or re-dispatch it
Concrete example:
User interaction triggers API call action
Note that API call failed, needs login
Dispatch 'LOGIN_REQUIRED' action, which pops up a <dialog> for user.
Wait for logged in state to change (or LOGIN_SUCCESS action to occur, whatever).
Make same API call again
If you want to check for a specific action to be dispatched, you'll need middleware.
If you want to, in effect, "subscribe a given bit of state", Redux doesn't provide a built-in way to do that. There are, however, a number of utilities that implement that kind of logic for you. See the Redux FAQ at http://redux.js.org/docs/FAQ.html#store-setup-subscriptions , and also the list of store subscription addons in my Redux addons catalog. (The list of Redux middlewares may also have something useful for the "listen for an action" scenario.)
for visualizing what happens in store you can use:
import {composeWithDevTools} from 'redux-devtools-extension';
and create your store as: (for instance with thunk middleware)
const store = `createStore(rootReducer,composeWithDevTools(applyMiddleware(thunk)));`
then you can use the extention in browser.
you can have access to your state by {connect} from 'react-redux' as props.
your actions then will change the state via reducers, this will cause your component receive new props so you can have your logic in
componentWillReceiveProps(nextProps) {/*your business logic*/}

Implement web notifications to meteor js app

Hello I'm trying to learn Meteor Js and i started building a simple task manager app.
I want to add a notification (using the notifications api), when a user adds a task from an input. My problem is that I cant find a way to send the notifications between users from the server side.
What i have so far :
Template.listPage.events({
'submit #newItem':function(e){
e.preventDefault();
//variables to insert here here. i dont post for space issues.
// Call server method for insert into db
Meteor.call('addItem',item,d,user,datestring,currentList,listName,assign);
// This is what i m trying to implement
var items = todos.find({name:item}).observe({
added:function() {
var n = new Notification("hello new task added")
}
})
},
The above works as :
The notification is shown only to the user that adds the task (not really useful).
How can I use this in server side, In order to:
Show the notification to all users using the app? Is this possible or I have to use a push notification package?
PS: I ask for users permition to receive notifications on Meteor.startup.
The problem is that you specify the observe within the click event. Therefore, only users who have triggered the event (i.e. clicked the button) will get the notification.
In order to activate the observer for everyone do the following:
Template.listPage.rendered = function(){
todos.find().observe({
added: function() {
... do whatever you want to do here
}
})
};
To add notifications, you could use a package such as yogiben:notifications:
https://atmospherejs.com/yogiben/notifications
(There might be better packages for this nowadays. Search on Atmosphere.)
Alternatively, you can roll your own solution. The basic idea would be add create a collection called Notifications. Then add notifications whenever you feel like it and publish the relevant notifications to whichever user(s) you'd like.
The code in your question will also work as long as you're publishing the relevant todos to different users.

Cloud Endpoints - Google Glass object has no attribute 'mirror_service'

I'm attempting to incorporate cloud enpoints into my app, I'm currently using the Python Quickstart for proof of concept. I'm having an issue when I attempt to call a method to send a card to my glass. Below is my code, please ignore the indentation is missing.
#endpoints.api(name='tasks', version='v1',
description='API for TaskAlert Management',
allowed_client_ids=[CLIENT_ID, endpoints.API_EXPLORER_CLIENT_ID])
class TaskAlertApi(remote.Service):
#endpoints.method(Task, Task,
name='task.insert',
path='tasker',
http_method='POST')
def insert_task(self, request):
TaskModel(author=request.author, content=request.content, date=request.date).put()
themirror = MainHandler()
themirror._insert_map_with_distance_from_home()
return request
So when "themirror._insert_map_with_distance_from_home()" is called I am getting the following error. Does anyone have any suggestions? I am trying to call this from myappspot.com/_ah/api/explorer.
in _insert_map_with_distance_from_home
self.mirror_service.timeline().insert(body=body).execute()
AttributeError: 'MainHandler' object has no attribute 'mirror_service'
I'm afraid you will have to rethink your code quite a bit for this but I'll try to get the basics explained here.
The main problem is that the MainHandler does quite a bit when actually receiving a HTTP request. The most important thing is what happens in the #util.auth_required decorator of the MainHandler's get method, which actually creates the mirror_service, authenticated for the current user. When you access the MainHandler directly from your code, none of this actually happens, so there is no mirror_service available (which results in the error you get).
Since the way endpoints are called is quite different from the way normal RequestHandlers are called, you also can't rely on stored session credentials or similar to match an Endpoints User to the Mirror User.
Basically what you would have to do is to create a new mirror_service inside of your endpoint method.
For this you will have to call your API authenticated (adding the Mirror API scopes to the authentication scopes). You can then extract the used access_token from the request header and use this access_token to create OAuth2Credentials to create the mirror_service.
Some code snippets without promises of completeness since it's hard to tell without knowing your actual code:
import os
from oauth2client.client import AccessTokenCredentials
# extract the token from request
if "HTTP_AUTHORIZATION" in os.environ:
(tokentype, token) = os.environ["HTTP_AUTHORIZATION"].split(" ")
# create simple OAuth2Credentials using the token
credentials = AccessTokenCredentials(token, 'my-user-agent/1.0')
# create mirror_service (using the method from util.py from the quickstart(
mirror_service = create_service('mirror', 'v1', credentials)
Of course you would then also have to change the _insert_map_with_distance_from_home to use this mirror_service object, but moving this method away from your MainHandler would make more sense in this context anyway.

session in class file

Hi I have a list called Event Source. In that am adding new item. Once i added , the background process takes this newly created id and start importing EventFields in the Specific List.In EventSource list item i have an ECB menu item called Sync and I should not click the Sync until the import completes in the EventField list. My Client not accepted creating a flag field in the "Event Source List". So wanna maintain some flag in session until the import finishes. for me oncei created EventSource and Clicked Sync first time the HttpContex.current is null but next time it is not.But i need to maintain the flag very first time. That import code is written in the class library.How to maintain.If i use static it s cleaing the value or another instances.,
You may be wording wrong your question but a Windows Service doesn't have an HttpContext, you simply can't do that.

Resources