Skip to content

Commit

Permalink
discord_verification
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemchik542 committed Jul 22, 2024
1 parent 3a4a212 commit 1cdbdd5
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 34 deletions.
33 changes: 10 additions & 23 deletions code/_onclick/hud/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,31 +97,21 @@
var/highlighted = FALSE
/// The ref of the mob that owns this button. Only the owner can click on it.
var/owner
var/requires_discord = TRUE //MASSMETA EDIT ADDITION (discord verification)

/atom/movable/screen/lobby/button/Click(location, control, params)
//MASSMETA EDIT CHANGE START (discord verification)
var/force_verification = CONFIG_GET(number/force_verification)
var/discord = SSdiscord.lookup_id(usr.ckey)
if (force_verification && !discord && requires_discord)
if(tgui_alert(usr, "Для игры на сервере МассМета нужен привязанный аккаунт дискорда(OOC → Verify Discord). Желаете ли Вы открыть ссылку в браузере?",, list("Да","Нет"))!="Да")
return
DIRECT_OUTPUT(usr, link("https://discord.gg/WRJ8bns7X7")) //прямая ссылка в канал верификации
else
if(owner != REF(usr))
return
if(owner != REF(usr))
return

if(!usr.client || usr.client.interviewee)
return
if(!usr.client || usr.client.interviewee)
return

. = ..()
. = ..()

if(!enabled)
return
flick("[base_icon_state]_pressed", src)
update_appearance(UPDATE_ICON)
return TRUE
//MASSMETA EDIT CHANGE END
if(!enabled)
return
flick("[base_icon_state]_pressed", src)
update_appearance(UPDATE_ICON)
return TRUE

/atom/movable/screen/lobby/button/MouseEntered(location,control,params)
if(owner != REF(usr))
Expand Down Expand Up @@ -339,7 +329,6 @@
icon_state = "settings"
base_icon_state = "settings"
screen_loc = "TOP:-122,CENTER:+29"
requires_discord = FALSE //MASSMETA EDIT ADDITION (discord verification)

/atom/movable/screen/lobby/button/bottom/settings/Click(location, control, params)
. = ..()
Expand All @@ -356,7 +345,6 @@
icon_state = "changelog"
base_icon_state = "changelog"
screen_loc ="TOP:-122,CENTER:+57"
requires_discord = FALSE //MASSMETA EDIT ADDITION (discord verification)

/atom/movable/screen/lobby/button/bottom/changelog_button/Click(location, control, params)
. = ..()
Expand Down Expand Up @@ -464,7 +452,6 @@
layer = LOBBY_BELOW_MENU_LAYER
screen_loc = "TOP:-82,CENTER:-54"
always_shown = TRUE
requires_discord = FALSE //MASSMETA EDIT ADDITION (discord verification)

var/blip_enabled = TRUE

Expand Down
6 changes: 0 additions & 6 deletions code/controllers/configuration/entries/general.dm
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,6 @@

/datum/config_entry/flag/irc_first_connection_alert // do we notify the irc channel when somebody is connecting for the first time?

//MASSMETA EDIT ADDITION BEGIN (discord verification) - FORCED DISCORD VERIFICATION
/datum/config_entry/number/force_verification
default = null
min_val = 0
//MASSMETA EDIT ADDITION END

/datum/config_entry/string/ipintel_base
default = "check.getipintel.net"

Expand Down
14 changes: 12 additions & 2 deletions code/modules/discord/accountlink.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,24 @@
// Simple sanity check to prevent a user doing this too often
var/cached_one_time_token = SSdiscord.reverify_cache[usr.ckey]
if(cached_one_time_token && cached_one_time_token != "")
message = "Введите свой сгенерированный одноразовый токен <span class='code user-select'>[cached_one_time_token]</span> в Дискорд-канал #верификация. Если по каким-либо причинам вам нужен новый - дождитесь окончания раунда и повторите все заново." //MASSMETA EDIT CHANGE (discord verification)
//MASSMETA EDIT CHANGE BEGIN (discord_verification)
/*ORIGINAL
message = "You already generated your one time token, it is [cached_one_time_token]. If you need a new one, you will have to wait until the round ends, or switch to another server; try verifying yourself on Discord by copying this command: <span class='code user-select'>[prefix]verify [cached_one_time_token]</span> and pasting it into the verification channel."
*/
message = "Введите свой сгенерированный одноразовый токен <span class='code user-select'>[cached_one_time_token]</span> в Дискорд-канал #верификация. Если по каким-либо причинам вам нужен новый - дождитесь окончания раунда и повторите все заново."
//MASSMETA EDIT CHANGE END


else
// Will generate one if an expired one doesn't exist already, otherwise will grab existing token
var/one_time_token = SSdiscord.get_or_generate_one_time_token_for_ckey(ckey)
SSdiscord.reverify_cache[usr.ckey] = one_time_token
message = "Ваш одноразовый токен: [one_time_token]. Теперь вы можете пройти верификацию, перейдя в канал #верификация в дискорде, нажав соответствующую кнопку у Бота и вписав там данный токен: <span class='code user-select'>[one_time_token]</span>" //MASSMETA EDIT CHANGE (discord verification)
//MASSMETA EDIT CHANGE BEGIN (discord_verification)
/*ORIGINAL
message = "Your one time token is: [one_time_token]. Assuming you have the required living minutes in game, you can now verify yourself on Discord by using the command: <span class='code user-select'>[prefix]verify [one_time_token]</span>"
*/
message = "Ваш одноразовый токен: [one_time_token]. Теперь вы можете пройти верификацию, перейдя в канал #верификация в дискорде, нажав соответствующую кнопку у Бота и вписав там данный токен: <span class='code user-select'>[one_time_token]</span>"
//MASSMETA EDIT CHANGE END

//Now give them a browse window so they can't miss whatever we told them
var/datum/browser/window = new/datum/browser(usr, "discordverification", "Discord Verification")
Expand Down
2 changes: 1 addition & 1 deletion config/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ NOTIFY_NEW_PLAYER_ACCOUNT_AGE 1
## Discord ID of a role that should be pinged when a new player makes their first connection
#NEW_PLAYER_ALERT_ROLE_ID 1138188190604341308

## Whether discord verification is forced or not (for Massmeta)
## Whether discord verification is forced or not (MASSMETA discord_verification)
FORCE_VERIFICATION 0

## Deny all new connections by ckeys we haven't seen before (exempts admins and only denies the connection if the database is enabled and connected)
Expand Down
13 changes: 12 additions & 1 deletion interface/skin.dmf
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,18 @@ window "infowindow"
saved-params = "is-checked"
text = "Wiki"
command = "wiki"
//MASSMETA EDIT CHANGE BEGIN (forum -> discord)
//MASSMETA EDIT CHANGE BEGIN (discord_verification)
/*
elem "forum"
type = BUTTON
pos = 275,5
size = 90x20
anchor1 = 43,0
anchor2 = 57,0
saved-params = "is-checked"
text = "Forum"
command = "forum"
*/
elem "discord"
type = BUTTON
pos = 275,5
Expand Down
3 changes: 3 additions & 0 deletions massmeta/features/discord_verification/code/config_force.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/datum/config_entry/number/force_verification
default = null
min_val = 0
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/client/verb/discord()
set name = "discord"
set desc = "Visit the discord."
set hidden = TRUE

if(alert("This will open our Discord in your browser. Are you sure?", "Discord", "Yes", "No") != "Yes")
Expand Down
34 changes: 34 additions & 0 deletions massmeta/features/discord_verification/code/master_new_player.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//ORIGINAL FILE: code/_onclick/hud/new_player.dm
/atom/movable/screen/lobby/button
var/requires_discord = TRUE

/atom/movable/screen/lobby/button/Click(location, control, params)
var/force_verification = CONFIG_GET(number/force_verification)
var/discord = SSdiscord.lookup_id(usr.ckey)
if (force_verification && !discord && requires_discord)
if(tgui_alert(usr, "Для игры на сервере МассМета нужен привязанный аккаунт дискорда(OOC → Verify Discord). Желаете ли Вы открыть ссылку в браузере?",, list("Да","Нет"))!="Да")
return
DIRECT_OUTPUT(usr, link("https://discord.gg/WRJ8bns7X7")) //прямая ссылка в канал верификации
else
if(owner != REF(usr))
return

if(!usr.client || usr.client.interviewee)
return

. = ..()

if(!enabled)
return
flick("[base_icon_state]_pressed", src)
update_appearance(UPDATE_ICON)
return TRUE

/atom/movable/screen/lobby/button/bottom/settings
requires_discord = FALSE

/atom/movable/screen/lobby/button/bottom/changelog_button
requires_discord = FALSE

/atom/movable/screen/lobby/button/collapse
requires_discord = FALSE
3 changes: 3 additions & 0 deletions massmeta/features/discord_verification/includes.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "code\config_force.dm"
#include "code\discord.dm"
#include "code\master_new_player.dm"
32 changes: 32 additions & 0 deletions massmeta/features/discord_verification/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Module ID: discord_verification

### Description:

Принудительная привязка Discord аккаунта к Byond аккунту для игры на сервере.

### TG Proc/File Changes:

- interface/skin.dmf
- code/modules/discord/accountlink.dm
- добавлен FORCE_VERIFICATION в config/config.txt



### Modular Overrides:

- code/_onclick/hud/new_player.dm


### Defines:

- N/A


### TGUI Files:

- N/A


### Credits:

- Huz2e
2 changes: 1 addition & 1 deletion massmeta/modular_meta_features.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// BEGIN_INCLUDE
#include "features\additional_circuit\includes.dm"
#include "features\cheburek_car\includes.dm"
#include "features\discord_verification\includes.dm"
#include "features\hierophant_club_resprite\includes.dm"
#include "features\kvass\includes.dm"
#include "features\lead_pipe\includes.dm"
Expand All @@ -32,7 +33,6 @@

#include "code\_globalvars\lists\names.dm"
#include "code\__HELPERS\names.dm"
#include "interface\interface.dm"
#include "code\modules\clothing\clothing.dm"
#include "code\modules\surgery\organs\tongue.dm"
#include "code\modules\clothing\suits\chaplainsuits.dm"
Expand Down

0 comments on commit 1cdbdd5

Please sign in to comment.