Intents
Register global before and after handlers for Telegram links, deeplinks, and custom intents.
The intents module provides IntentsManager, a global API for reacting to links and intents handled by exteraGram.
This manager is available only on exteraGram 66999 (12.6.4) and newer.
It lets you register:
beforehandlers, called before the original methodafterhandlers, called after the original method
Import
new_global_before_handler(...)
Registers a global handler that runs in beforeHookedMethod.
new_global_after_handler(...)
Registers a global handler that runs in afterHookedMethod.
Filters
Both registration methods accept the same filter arguments.
scheme
Matches intent.data.scheme.
host
Matches intent.data.host.
path
Matches intent.data.path.
If the value does not start with /, the SDK adds it automatically.
path also supports template variables like {user_id}.
required_path_args_names
Despite the name, this currently means required query arguments.
If one of these query arguments is missing, the handler does not run.
This matches tg://chat?id=123 and does not match tg://chat.
action
Matches intent.getAction().
whitelist_flags
Requires every listed flag to be present in intent.getFlags().
blacklist_flags
Rejects the intent if any listed flag is present in intent.getFlags().
type
Matches intent.getType().
categories
Requires every listed category to be present in intent.getCategories().
priority
Handlers are sorted by ascending priority.
Lower numbers run first.
Callback Arguments
The SDK inspects your callback signature and only passes values that the function explicitly asks for.
Available standard names:
intentschemehostpathquery_argsactionflagstypecategories
In addition, the SDK exposes:
- every query argument by name, such as
idorplugin - every path-template variable by name, such as
user_idfrom/user/{user_id}
Requesting only one named value
Requesting the full common context
Receiving query arguments by name
Receiving path variables by name
Using **kwargs
If the callback accepts **kwargs, the SDK passes the full available named context.
Using *args
If the callback accepts *args, the SDK also passes the standard positional bundle:
intentschemehostpathquery_argsactionflagstypecategories
Combining named parameters and **kwargs
Stopping Further Handling
before handlers can stop the rest of the Python handlers and also stop the original Java intent handling.
To do that, return True from the callback.
Behavior:
- only
beforehandlers can stop handling - once a
beforecallback returnsTrue, later handlers are not called - the SDK returns
truefrom the Xposed hook by callingparam.setResult(true)
Returning any value other than True does not stop handling.
after handlers cannot stop the original intent flow.
HandlerHandle
Both registration methods return a HandlerHandle.
Call unhandle() on it to remove the registered handler.
unhandle(handler_id)
You can also remove a handler manually by its id.
parse(url: str)
parse(...) is a small helper for parsing URL-like strings.
It returns a dictionary with at least:
schemehost
It may also include:
pathquery
Exceptions
IM.unhandle(...) raises IntentsManager.HandlerNotRegistered if the handler id does not exist.
Notes
- matching by
scheme,host,path, required query arguments,action,flags,type, andcategorieshappens on the Java side - only matching handler ids are dispatched to Python
- handlers are executed in ascending
priorityorder required_path_args_namescurrently means required query-argument namesbeforehandlers may stop both later handlers and the original Java intent handling by returningTrue