-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPowderIM.lua
More file actions
109 lines (89 loc) · 3.27 KB
/
PowderIM.lua
File metadata and controls
109 lines (89 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
100
101
102
103
104
105
106
107
108
109
--to do
--o add im/custom chat "servers"
--o rename it because it sounds like 2000's
--o um
--o fix the backend issues with purple
--o add autoclear if chat >= 9
--o giant wall of text
--o jacbob what is your opinion on the name
local chatwindow = Window:new(-1, -1, 280, 200)
local loadingwindow = Window:new(-1, -1, 100, 50)
local currentY = 10
--======================--
local testLabel = Label:new(40, currentY, (select(1, chatwindow:size())/2)-20, 16, "PowderIM v1 (Server hosted by aaccbb)")
local testLabel2 = Label:new(10, 20, (select(1, chatwindow:size())/2)-20, 16, "Sending...")
loadingwindow:addComponent(testLabel2)
currentY = currentY + 17
local chat1 = Label:new(150, 80, -20, 16, "")
currentY = currentY + 123
local textboxInfo = Label:new(10+((select(1, chatwindow:size())/2)-20), currentY, (select(1, chatwindow:size())/2)-20, 16, "0 characters")
local testTextbox = Textbox:new(10, currentY, (select(1, chatwindow:size())/2)-20, 16, "", "...")
testTextbox:onTextChanged(
function(sender)
end
)
local testButton = Button:new(150, currentY, (select(1, chatwindow:size())/4)-20, 16, "Send")
testButton:action(
function(sender)
interface.showWindow(loadingwindow)
msg = testTextbox:text()
fetch = http.post("https://script.tiny-warthog-19.telebit.io/chat/chat.php?user=".. tpt.get_name() .."&msg=".. msg)
--interface.closeWindow(chatwindow)
while fetch:status() == "running" do
end
interface.closeWindow(loadingwindow)
--interface.showWindow(chatwindow)
chat, tmp = fetch:finish()
if (tmp == 404) then
chat:text("404, server down!\nNotify aaccbb.")
else
fetch = http.get("https://script.tiny-warthog-19.telebit.io/chat/chat.txt")
interface.showWindow(loadingwindow)
while fetch:status() == "running" do
end
interface.closeWindow(loadingwindow)
chat, tmp = fetch:finish()
if (tmp == 404) then
chat:text("404, server down!\nNotify aaccbb.")
else
chat = string.gsub(chat, "\x0A", "")
chat = string.gsub(chat, "○", "\n")
chat1:text(chat)
end
end
end
)
local reloadButton = Button:new(217, currentY, (select(1, chatwindow:size())/4)-20, 16, "Reload")
reloadButton:action(
function(sender)
fetch = http.get("https://script.tiny-warthog-19.telebit.io/chat/chat.txt")
interface.showWindow(loadingwindow)
while fetch:status() == "running" do
end
interface.closeWindow(loadingwindow)
chat, tmp = fetch:finish()
if (tmp == 404) then
chat:text("404, server down!\nNotify aaccbb.")
else
chat = string.gsub(chat, "\x0A", "")
chat = string.gsub(chat, "○", "\n")
chat1:text(chat)
end
end
) --end
local closeButton = Button:new(10, select(2, chatwindow:size())-26, 100, 16, "Close")
closeButton:action(function() interface.closeWindow(chatwindow) end)
chatwindow:onTryExit(function() interface.closeWindow(chatwindow) end) -- Allow the default exit events
--====================--
chatwindow:addComponent(testLabel)
chatwindow:addComponent(chat1)
chatwindow:addComponent(testButton)
chatwindow:addComponent(testTextbox)
chatwindow:addComponent(reloadButton)
chatwindow:addComponent(closeButton)
local function keypressed(key, keynum, mod, evt)
if evt == 2 and key == "/" then
interface.showWindow(chatwindow)
end
end
tpt.register_keypress(keypressed)