Utils
Utilities
Various utility functions
This file is part of Rumble Chat Actor.
Rumble Chat Actor is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Rumble Chat Actor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Rumble Chat Actor. If not, see https://www.gnu.org/licenses/.
S.D.G.
get_safe_filename(clip_save_path, filename, extension=static.Clip.save_extension)
Make a filename that will not overwrite other files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
clip_save_path
|
str
|
The path to the folder to save the clip in. |
required |
filename
|
str
|
The desired base filename. |
required |
extension
|
str
|
The file name extension for the type of file to save. Defaults to static.Clip.save_extension |
save_extension
|
Returns:
| Name | Type | Description |
|---|---|---|
safe_filename |
str
|
The base filename with a numeric suffix added as needed. |
Source code in rumchat_actor/utils.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
is_staff(user)
Check if a user is channel staff
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
User
|
A user in the chat (importantly with a badges attribute) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Result |
bool
|
Does the user have staff badges (admin or moderator)? |
Source code in rumchat_actor/utils.py
22 23 24 25 26 27 28 29 30 31 | |
multiple_choice(title, options)
Allow the user to choose between multiple options. Automatically selects a lone option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The question at hand. |
required |
options
|
Sequence[str]
|
A subscriptable of option strings. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
choice |
str
|
The chosen option. |
Source code in rumchat_actor/utils.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
Note that cocorum.utils is imported globally into this module.
This file is part of Rumble Chat Actor.
Rumble Chat Actor is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Rumble Chat Actor is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Rumble Chat Actor. If not, see https://www.gnu.org/licenses/.
S.D.G.