-
Notifications
You must be signed in to change notification settings - Fork 0
/
nudge.lua
139 lines (129 loc) · 3.46 KB
/
nudge.lua
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
hexchat.register('HexNudge', '1.1', 'Wizz & Nudge for hexchat')
Nudge_Index = 0
-- Preferences init --
Prefs =
{
hexnudge_muted=false,
hexnudge_menublink=true,
hexnudge_windowblink=false,
hexnudge_nudge_speed = 60,
hexnudge_nudge_count = 15
}
PrefsMenu =
{
hexnudge_muted="Activer - Désactiver les wizz",
hexnudge_menublink="Activer - Désactiver le clignotement du menu",
hexnudge_windowblink="Activer - Désactiver le clignotement de la fenêtre"
}
for key,value in pairs(Prefs) do
if (hexchat.pluginprefs[key] == nil) then
if (type(value) == "boolean") then
hexchat.pluginprefs[key] = (value and "ON" or "OFF")
else
hexchat.pluginprefs[key] = value
end
end
end
hexchat.command('MENU DEL "Settings/HexNudge"')
hexchat.command('MENU ADD "Settings/HexNudge"')
for key,value in pairs(PrefsMenu) do
hexchat.command('MENU DEL "Settings/HexNudge/'..value..'" "WZREV '..key..'"')
hexchat.command('MENU ADD "Settings/HexNudge/'..value..'" "WZREV '..key..'"')
end
-- NUDGE & WIZZ Commands --
hexchat.hook_command('NUDGE', function (args)
if (#args ~= 2) then
hexchat.print("Utilisation : NUDGE <pseudo>")
else
hexchat.command('NOTICE '..args[2]..' WIZZ')
DoNudge()
end
return hexchat.EAT_ALL
end)
hexchat.hook_command('WIZZ', function (args)
if (#args ~= 2) then
hexchat.print("Utilisation : WIZZ <pseudo>")
else
hexchat.command('NOTICE '..args[2]..' WIZZ')
DoNudge()
end
return hexchat.EAT_ALL
end)
-- Preferences Settings Command --
hexchat.hook_command('WZSET', function (args)
if (#args == 1) then
for key,value in pairs(hexchat.pluginprefs) do
hexchat.print(key.." = "..value)
end
elseif (#args == 3) then
if (hexchat.pluginprefs[args[2]] ~= nil) then
hexchat.pluginprefs[args[2]] = args[3]
else
hexchat.print("Variable inconnu")
end
else
hexchat.print("Utilisation : WZSET [<variable> <valeur>]")
end
return hexchat.EAT_ALL
end)
hexchat.hook_command('WZREV', function (args)
if (#args == 2) then
if (hexchat.pluginprefs[args[2]] == nil) then
hexchat.print("Variable inconnu")
elseif (type(GetPref(args[2])) ~= "boolean") then
hexchat.print("Variable irreversible")
else
hexchat.pluginprefs[args[2]] = (GetPref(args[2]) and "OFF" or "ON")
end
else
hexchat.print("Utilisation : WZREV <variable>")
end
return hexchat.EAT_ALL
end)
-- NUDGE & WIZZ Button --
hexchat.hook_print('Open Context', function (args)
hexchat.command('DELBUTTON "Wizz" WIZZ %s')
hexchat.command('ADDBUTTON "Wizz" WIZZ %s')
end)
-- NUDGE & WIZZ Reception --
hexchat.hook_server('NOTICE', function (args, args_eol)
if (args_eol[4] == ':WIZZ') then
DoNudge()
end
end)
-- Do a Nudge --
function DoNudge()
if (not GetPref("hexnudge_muted") and Nudge_Index <= 0) then
Nudge_Index = 0
hexchat.hook_timer(GetPref("hexnudge_nudge_speed"), function (args)
hexchat.command('GUI FOCUS')
hexchat.command('GUI FLASH')
if (GetPref("hexnudge_menublink")) then
hexchat.command('GUI MENU TOGGLE')
end
if (GetPref("hexnudge_windowblink")) then
if (Nudge_Index % 2 == 0) then
hexchat.command('GUI HIDE')
else
hexchat.command('GUI SHOW')
end
end
Nudge_Index = Nudge_Index + 1
if (Nudge_Index > GetPref("hexnudge_nudge_count") * 2 + 1) then
Nudge_Index = 0
return false;
end
return true;
end)
end
end
-- Utilities --
function GetPref(pref)
if (hexchat.pluginprefs[pref] == "ON") then
return true
elseif (hexchat.pluginprefs[pref] == "OFF") then
return false
else
return hexchat.pluginprefs[pref]
end
end