Utils
Utilities
Various utility functions 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
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
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
13 14 15 16 17 18 19 20 21 22 | |
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
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 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 | |
Note that cocorum.utils is imported globally into this module.