mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 12:41:09 +01:00
[MIRROR] Admin verb to send message on PDA [MDB IGNORE] (#17252)
* Admin verb to send message on PDA (#70790) * base * oh, oh. * uh, dots? * no hdd, only computer * kill let in UI(but not in func) * Admin verb to send message on PDA Co-authored-by: Yaroslav Nurkov <78199449+AnywayFarus@users.noreply.github.com>
This commit is contained in:
co-authored by
Yaroslav Nurkov
parent
445d293fd7
commit
4759d84a2e
@@ -0,0 +1,86 @@
|
||||
///Allows an admin to send messages on PDA
|
||||
/client/proc/message_pda()
|
||||
set name = "PDA Message"
|
||||
set category = "Admin.Events"
|
||||
|
||||
if(!holder ||!check_rights(R_ADMIN))
|
||||
return
|
||||
|
||||
holder.message_pda()
|
||||
|
||||
///Opens up the PDA Message Panel
|
||||
/datum/admins/proc/message_pda()
|
||||
if(!check_rights(R_ADMIN))
|
||||
return
|
||||
|
||||
if(!length(GLOB.TabletMessengers))
|
||||
to_chat(usr, span_warning("ERROR: There are no users you can send a message to"))
|
||||
return
|
||||
|
||||
var/datum/admin_pda_panel/ui = new(usr)
|
||||
ui.ui_interact(usr)
|
||||
|
||||
/// Panel
|
||||
/datum/admin_pda_panel
|
||||
/// PDA which have players(and we can send them message)
|
||||
var/available_pdas = list()
|
||||
|
||||
/datum/admin_pda_panel/New()
|
||||
for(var/obj/item/modular_computer/computer in GLOB.TabletMessengers)
|
||||
for(var/datum/computer_file/program/messenger/app in computer.stored_files)
|
||||
if(!computer.saved_identification || !computer.saved_job || app.monitor_hidden || app.invisible)
|
||||
continue
|
||||
available_pdas += list(list("tablet" = computer, "name" = computer.saved_identification))
|
||||
|
||||
/datum/admin_pda_panel/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "AdminPDA")
|
||||
ui.open()
|
||||
|
||||
/datum/admin_pda_panel/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
|
||||
/datum/admin_pda_panel/ui_static_data(mob/user)
|
||||
var/list/data = list()
|
||||
data["users"] = list()
|
||||
|
||||
for(var/username in available_pdas)
|
||||
data["users"] += username["name"]
|
||||
return data
|
||||
|
||||
/datum/admin_pda_panel/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(!check_rights(R_ADMIN))
|
||||
return
|
||||
|
||||
switch(action)
|
||||
if("sendMessage")
|
||||
var/targets = list()
|
||||
var/spam = params["spam"]
|
||||
for(var/target in available_pdas)
|
||||
if(!spam && target["name"] != params["user"])
|
||||
continue
|
||||
targets += target["tablet"]
|
||||
|
||||
if(!length(targets))
|
||||
to_chat(usr, span_warning("ERROR: Target is unavaiable(or not choosed)."))
|
||||
return
|
||||
|
||||
var/datum/signal/subspace/messaging/tablet_msg/signal = new(targets[1], list(
|
||||
"name" = params["name"],
|
||||
"job" = params["job"],
|
||||
"message" = html_decode(params["message"]),
|
||||
"ref" = FALSE,
|
||||
"targets" = targets,
|
||||
"emojis" = FALSE,
|
||||
"rigged" = FALSE,
|
||||
"photo" = FALSE,
|
||||
"automated" = FALSE,
|
||||
))
|
||||
|
||||
signal.send_to_receivers()
|
||||
message_admins("[key_name_admin(usr)] has send custom PDA message to [spam ? "everyone" : params["user"]].")
|
||||
log_admin("[key_name(usr)] has send custom PDA message to [spam ? "everyone" : params["user"]]. Message: [params["message"]].")
|
||||
@@ -95,6 +95,7 @@ GLOBAL_PROTECT(admin_verbs_admin)
|
||||
/client/proc/show_manifest,
|
||||
/client/proc/list_dna,
|
||||
/client/proc/list_fingerprints,
|
||||
/client/proc/message_pda, /*send a message to somebody on PDA*/
|
||||
)
|
||||
GLOBAL_LIST_INIT(admin_verbs_ban, list(/client/proc/unban_panel, /client/proc/ban_panel, /client/proc/stickybanpanel))
|
||||
GLOBAL_PROTECT(admin_verbs_ban)
|
||||
|
||||
@@ -2118,6 +2118,7 @@
|
||||
#include "code\modules\actionspeed\modifiers\status_effects.dm"
|
||||
#include "code\modules\admin\admin.dm"
|
||||
#include "code\modules\admin\admin_investigate.dm"
|
||||
#include "code\modules\admin\admin_pda_message.dm"
|
||||
#include "code\modules\admin\admin_ranks.dm"
|
||||
#include "code\modules\admin\admin_verbs.dm"
|
||||
#include "code\modules\admin\adminmenu.dm"
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
import { useBackend, useLocalState } from '../backend';
|
||||
import { Section, Dropdown, Input, Box, TextArea } from '../components';
|
||||
import { Button, ButtonCheckbox } from '../components/Button';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
export const AdminPDA = (props, context) => {
|
||||
return (
|
||||
<Window title="Send Message on PDA" width={300} height={525} theme="admin">
|
||||
<Window.Content>
|
||||
<ReceiverChoice />
|
||||
<SenderInfo />
|
||||
<MessageInput />
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
|
||||
export const ReceiverChoice = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const receivers = Array.from(data.users).sort();
|
||||
|
||||
const [user, setUser] = useLocalState(context, 'user', '');
|
||||
const [spam, setSpam] = useLocalState(context, 'spam', false);
|
||||
|
||||
return (
|
||||
<Section title="To Who?" textAlign="center">
|
||||
<Box>
|
||||
<Dropdown
|
||||
selected="Pick a target"
|
||||
options={receivers}
|
||||
width="275px"
|
||||
mb={1}
|
||||
onSelected={(value) => {
|
||||
setUser(value);
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
<Box>
|
||||
<ButtonCheckbox checked={spam} fluid onClick={() => setSpam(!spam)}>
|
||||
Should it be sent to everyone?
|
||||
</ButtonCheckbox>
|
||||
</Box>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
export const SenderInfo = (props, context) => {
|
||||
const [name, setName] = useLocalState(context, 'name', '');
|
||||
const [job, setJob] = useLocalState(context, 'job', '');
|
||||
|
||||
return (
|
||||
<Section title="From Who?" textAlign="center">
|
||||
<Box fontSize="14px">
|
||||
<Input
|
||||
placeholder="Sender name..."
|
||||
fluid
|
||||
onInput={(e, value) => {
|
||||
setName(value);
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
<Box fontSize="14px" pt="10px">
|
||||
<Input
|
||||
placeholder="Sender's job..."
|
||||
fluid
|
||||
onInput={(e, value) => {
|
||||
setJob(value);
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
export const MessageInput = (props, context) => {
|
||||
const { act } = useBackend(context);
|
||||
|
||||
const [user, setUser] = useLocalState(context, 'user', '');
|
||||
const [name, setName] = useLocalState(context, 'name', '');
|
||||
const [job, setJob] = useLocalState(context, 'job', '');
|
||||
const [messageText, setMessageText] = useLocalState(context, 'message', '');
|
||||
const [spam, setSpam] = useLocalState(context, 'spam', false);
|
||||
|
||||
const tooltipText = function (name, job, message) {
|
||||
let reasonList = [];
|
||||
if (!name) reasonList.push('name');
|
||||
if (!job) reasonList.push('job');
|
||||
if (!message) reasonList.push('message text');
|
||||
return reasonList.join(', ');
|
||||
};
|
||||
|
||||
const blocked = !name || !job || !messageText;
|
||||
|
||||
return (
|
||||
<Section title="Message" textAlign="center">
|
||||
<Box>
|
||||
<TextArea
|
||||
placeholder="Type the message you want to send..."
|
||||
height="200px"
|
||||
mb={1}
|
||||
onInput={(e, value) => {
|
||||
setMessageText(value);
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
<Box>
|
||||
<Button
|
||||
tooltip={
|
||||
blocked
|
||||
? 'Fill in the following lines: ' +
|
||||
tooltipText(name, job, messageText)
|
||||
: 'Send message to user(s)'
|
||||
}
|
||||
fluid
|
||||
disabled={blocked}
|
||||
icon="envelope-open-text"
|
||||
onClick={() =>
|
||||
act('sendMessage', {
|
||||
name: name,
|
||||
user: user,
|
||||
job: job,
|
||||
message: messageText,
|
||||
spam: spam,
|
||||
})
|
||||
}>
|
||||
Send Message
|
||||
</Button>
|
||||
</Box>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user