Web browser (core)¶
Warning
This can only be used if you are running the framework in a desktop environment. You cannot use it eg. on a Ubuntu server.
The web browser functionality includes the login (via browser) with email and password as well as the automatic guild join (also via browser).
To use the web functionality, users need to install the optional packages with:
pip install discord-advert-framework[web]
The Chrome browser is also required to run the web functionality.
Note
When running the web functionality, the proxy
parameter passed to ACCOUNT
, will also
be used to the browser.
Unfortunetly it is not directly possible for the web driver to accept a proxy with username and password, meaning
just the normal “protocol://ip:port” proxy will work. If you plan to run a private proxy, it is recommened that
you whitelist your IP instead and pass the proxy
paramterer in the “protocol://ip:port” format.
Automatic login¶
To login with username (email) and password instead of the token, users need to provide the ACCOUNT
object with the username
and password
parameters.
import daf
accounts = [
daf.ACCOUNT(
username="[email protected]",
password="TheRiverIsFlowingDownTheHill232",
...
)
]
daf.run(accounts=accounts)
If you run the above snippet, DAF will first open the browser, load the Discord login screen and login, then it will save the token into a file under “daf_web_data” folder and send the token back to the framework. The framework will then run exactly the same as it would if you passed it the token directly.
If you restart DAF, it will not re-login, but will just load the data from the saved storage under “daf_web_data” folder.
Automatic guild discovery and join¶
Error
This feature is currently disabled due to the search provider shutting down its services. It will be reenabled in a future version.
The web layer beside login with username and password, also allows (semi) automatic guild discovery and join.
To use this feature, users need to create an AutoGUILD
instance, where they pass the auto_join
parameter. auto_join
parameter is a GuildDISCOVERY
object, which can be configured how it should
search for new guilds. DAF will join a new guild every 45 seconds until the limit is reached.
Warning
When joining a guild, users may be prompted to complete the CAPTCHA (Completely Automated Public Turing Check to tell Computers and Humans Apart), which is why this is semi-automatic. In the case of this event, the browser will wait 90 seconds for the user to complete the CAPTCHA, if they don’t it will consider the join to be a failure.
from daf import QuerySortBy, QueryMembers
import daf
accounts = [
daf.ACCOUNT(
username="[email protected]",
password="TheRiverIsFlowingDownTheHill232",
servers=[
daf.AutoGUILD(
".*",
auto_join=daf.GuildDISCOVERY("NFT art", daf.QuerySortBy.TOP, limit=5),
...
)
]
)
]
daf.run(accounts=accounts)
With the above example, AutoGUILD
, will search for guilds that match the prompt
parameter and
select the ones that match the other parameters. After finding a guild, it will then check
if the include_pattern
parameter of AutoGUILD
matches with the guild name and if it does,
it will then obtain the invite link and try to join the guild.
The browser will only try to join as many guilds as defined by the limit
parameter of
GuildDISCOVERY
. Guilds that the user is already joined, also count as a successful join, meaning
that if the limit is eg. 5 and the users is joined into 3 of the found guilds, browser will only join 2 new guilds.
Web feature example¶
The following shows an example of both previously described features.
"""
Example shows login with email and password.
The AutoGUILD defines an auto_join parameter, which will be used to (semi) automatically
join new guilds based on a prompt. You as a user still need to solve any CAPTCHA challenges.
"""
# Import the necessary items
from daf.web import QueryMembers
from daf.client import ACCOUNT
from daf.web import GuildDISCOVERY
from daf.web import QuerySortBy
from daf.guild.autoguild import AutoGUILD
from daf.logging.tracing import TraceLEVELS
import daf
# Defined accounts
accounts = [
ACCOUNT(
servers=[
AutoGUILD(
include_pattern=".*",
auto_join=GuildDISCOVERY(
prompt="NFT arts",
sort_by=QuerySortBy.TOP,
total_members=QueryMembers.B100_1k,
limit=30,
),
),
],
username="[email protected]",
password="password",
),
]
# Run the framework (blocking)
daf.run(
accounts=accounts,
debug=TraceLEVELS.NORMAL,
)