Group Allow List Commands¶
InJobBot can be added into groups and used by the owner or group admin to send jobs in chat or by group chat members (normal members) to view help and tips messages.
However, to prevent the abuse of the bot, it has a table in the database which is created on deployment or activation that has the list of groups id's that the bot is allowed to be added to.
If the bot was added to a group which is not in the database; it will leave.
Click to view the allow_list schema being created
persistence.py | |
---|---|
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
This can be controlled by the bot's owner using the following commands.
Adding A Group To The List¶
The /addgroup
command followed by the group chat id will add the group to the database. This command calls the execute()
method on the the AddGroupToAllowListCommand(group_id)
database command; adding the group to the allow_list table.
Click to view the AddGroupToAllowListCommand()
database command class
Bases: ICommand
This command adds a group to the allow_list
Source code in src/database/db_commands.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
__init__(*, group_id: str) -> None
¶summary : This method gets the data to initiate the command to add group to the bot's allow list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group_id |
str
|
description : The group_id to allow. |
required |
Source code in src/database/db_commands.py
121 122 123 124 125 126 127 128 129 |
|
execute() -> None
¶This method adds group
Source code in src/database/db_commands.py
131 132 133 134 |
|
Removing A Group From The List¶
The /rmgroup
command followed by the group chat id will remove the group from the database. This command calls the execute()
method on the the DeleteGroupCommand(group_id)
database command; removing the group from the allow_list table.
Click to view the DeleteGroupCommand()
database command class
Bases: ICommand
This command deletes Groups from the database.
Source code in src/database/db_commands.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
__init__(*, group_id: str) -> None
¶summary : This method gets the data to initiate the command to delete group from database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group_id |
str
|
description : Group's id. |
required |
Source code in src/database/db_commands.py
164 165 166 167 168 169 170 171 172 |
|
execute()
¶This method deletes the user from the database using the provided criteria.
Source code in src/database/db_commands.py
174 175 176 177 |
|
Getting Groups In The List¶
The /getgroups
command will list all the groups in the database. This command calls the execute()
method on the the GetGroupCommand(group_id)
database command; listing all the groups in the allow_list table.
Note
Following the /getgroups
command by the group chat id; will return the group id back if it exists in the database.
Click to view the GetGroupCommand()
database command class
Bases: ICommand
This command sends a 'SELECT' query to the allow_list database returning with group in it.
Source code in src/database/db_commands.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
__init__(*, group_id: str = None, order_by: str = 'date_added') -> None
¶summary : This method gets the data to initiate the command to get user from database using group_id as a selection criteria and sort the results back using 'date_added' attribute (columns).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group_id |
str
|
description : group_id. |
None
|
order_by |
str
|
description, by default "date_added" : The criteria in which to sort the returned query results. |
'date_added'
|
Source code in src/database/db_commands.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
execute() -> list
¶This method executes the 'SELECT' statement.
Source code in src/database/db_commands.py
155 156 157 158 |
|