Automatic Generation (core)¶
This documents describes mechanisms that can be used to automatically generate objects.
Shilling scheme generation¶
While the servers can be manually defined and configured, which can be time consuming if you have a lot of guilds to shill into, DAF also supports automatic definition of servers and channels. Servers and channels can be automatically defined by creating some matching rules described in the Matching logic chapter of this guide.
Automatic GUILD generation¶
See also
This section only describes guilds that the user is already joined in. For information about discovering NEW guilds and automatically joining them see Automatic guild discovery and join
For a automatically managed servers, use AutoGUILD
which internally generates GUILD
instances.
Simply create a list of AutoGUILD
objects and then pass it to the servers
parameter of
daf.client.ACCOUNT
.
Warning
Messages that are added to AutoGUILD
should have AutoCHANNEL
for the channels
parameters,
otherwise you will be spammed with warnings and only one guild will be shilled.
# Import the necessary items
from daf.logging.logger_json import LoggerJSON
from daf.client import ACCOUNT
from daf.logic import contains
from daf.guild.autoguild import AutoGUILD
from daf.logic import or_
from daf.logging.tracing import TraceLEVELS
import daf
# Define the logger
logger = LoggerJSON(
path="C:\\Users\\david\\daf\\History",
)
# Define remote control context
# Defined accounts
accounts = [
ACCOUNT(
token="TOKEN_HERE",
is_user=True,
servers=[
AutoGUILD(
include_pattern=or_(
operands=[
contains(keyword="shill"),
contains(keyword="NFT"),
contains(keyword="dragon"),
contains(keyword="promo"),
],
),
logging=True,
),
],
),
]
# Run the framework (blocking)
daf.run(
accounts=accounts,
logger=logger,
debug=TraceLEVELS.NORMAL,
save_to_file=False
)
Automatic channel generation¶
For a automatically managed channels, use AutoCHANNEL
.
It can be passed to xMESSAGE objects to the channels
parameters.
# Import the necessary items
from daf.logging.logger_json import LoggerJSON
from daf.guild.autoguild import AutoGUILD
from daf.logic import or_
from daf.messagedata.textdata import TextMessageData
from datetime import timedelta
from daf.message.autochannel import AutoCHANNEL
from daf.message.messageperiod import FixedDurationPeriod
from daf.message.text_based import TextMESSAGE
from daf.logic import contains
from daf.client import ACCOUNT
from daf.logging.tracing import TraceLEVELS
import daf
# Define the logger
logger = LoggerJSON(
path="C:\\Users\\david\\daf\\History",
)
# Define remote control context
# Defined accounts
accounts = [
ACCOUNT(
token="TOKEN_HERE",
is_user=True,
servers=[
AutoGUILD(
include_pattern=or_(
operands=[
contains(keyword="shill"),
contains(keyword="NFT"),
contains(keyword="dragon"),
contains(keyword="promo"),
],
),
messages=[
TextMESSAGE(
data=TextMessageData(content="Checkout my new Red Dragon NFT! Additionaly, we also have the Golden Dragon - limited time only!"),
channels=AutoCHANNEL(
include_pattern=or_(
operands=[
contains(keyword="nft"),
contains(keyword="shill"),
contains(keyword="self-promo"),
contains(keyword="projects"),
contains(keyword="marketing"),
],
),
),
period=FixedDurationPeriod(duration=timedelta(seconds=5.0)),
),
],
logging=True,
),
],
),
]
# Run the framework (blocking)
daf.run(
accounts=accounts,
logger=logger,
debug=TraceLEVELS.NORMAL,
save_to_file=False
)