Skip to content

Commit 892af91

Browse files
Update Func.cs
1 parent 22f32d0 commit 892af91

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

Scripts/Func.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ public TextMeshProUGUI
5252
versionLbl,
5353
customerPanelLink;
5454

55+
[Header("Chatroom Features")]
56+
private float timeToGatherMsgs = 10f; // the countdown time for when to grab messages again
57+
58+
public TMP_InputField testBox; // the object the messages get displayed on
59+
public TMP_InputField chat_MsgToSend; // the input_field that contains the message you want to send
60+
public TMP_InputField userToMute; // the username of the user that you want to mute
61+
private bool getMessages = false; // status to check if you should be getting messages or not
62+
private string chatchannel = "testing"; // the name of the chatroom (name is created on https://keyauth.win
5563

5664
public void displayUserInformation() // when the user successfully logs in, it will display this information on the user information tab
5765
{
@@ -97,6 +105,14 @@ public string expirydaysleft() // make sure that this is included so that it can
97105
{
98106
KeyAuthApp.init();
99107
}
108+
109+
private void LateUpdate()
110+
{
111+
if (getMessages == true)
112+
{
113+
retrieveMessages();
114+
}
115+
}
100116

101117
public void ExitApplication() // this quits the application
102118
{
@@ -154,4 +170,52 @@ public void licenseType() // method to login and/or register with only a license
154170
licenseOnlyStatusLbl.text = KeyAuthApp.response.message;
155171
}
156172
}
173+
174+
public void sendMsg() // method to send a message in the chatroom
175+
{
176+
if (KeyAuthApp.chatsend(chat_MsgToSend.text, chatchannel))
177+
{
178+
testBox.text += KeyAuthApp.user_data.username + ": " + chat_MsgToSend + "\n\n";
179+
chat_MsgToSend.text = null;
180+
}
181+
}
182+
183+
public void retrieveMessages() // method to gather all messages and place in the chatroom
184+
{
185+
timeToGatherMsgs--;
186+
if (timeToGatherMsgs == 0)
187+
{
188+
testBox.text = null;
189+
if (!String.IsNullOrEmpty(chatchannel))
190+
{
191+
var messages = KeyAuthApp.chatget(chatchannel);
192+
if (messages == null || messages[0].message == "not_found")
193+
{
194+
Debug.Log("No Messages");
195+
}
196+
else
197+
{
198+
foreach (var message in messages)
199+
{
200+
testBox.text += message.author + ": " + message.message + "\n\n";
201+
timeToGatherMsgs = 10f;
202+
}
203+
}
204+
}
205+
else
206+
{
207+
Debug.Log("No msgs");
208+
}
209+
}
210+
}
211+
212+
public void clearAllMessages()
213+
{
214+
KeyAuthApp.webhook("WEBHOOKIDHERE", "&type=clearchannel&name=channelnamehere");
215+
}
216+
217+
public void muteUserInChat()
218+
{
219+
KeyAuthApp.webhook("WEBHOOKDIDHERE", "&type=muteuser&user=" + userToMute.text + "&time=60");
220+
}
157221
}

0 commit comments

Comments
 (0)