vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Guild Event Manager by Kiki (European Cho'gall) (Alliance)
3 CMD module
4 ]]
5  
6 --------------- Saved variables ---------------
7  
8 --------------- Shared variables ---------------
9  
10 --------------- Local variables ---------------
11  
12 --------------- Hooked functions ---------------
13  
14 --------------- Internal functions ---------------
15  
16  
17 --------------- Exported functions ---------------
18  
19 function GEM_CMD_Help()
20 GEM_ChatPrint("/gem toggle : Shows or hides the GUI (you can also assign a key in your shortcuts)");
21 GEM_ChatPrint("/gem join : Rejoin GEM channels, if auto-join failed");
22 GEM_ChatPrint("/gem channels : Lists current GEM channels");
23 GEM_ChatPrint("/gem addchan <Name> [<Password>] : Adds a new GEM channel with password (optional)");
24 GEM_ChatPrint("/gem delchan <Name> : Removes a current GEM channel");
25 GEM_ChatPrint("/gem setdefchan <Name> : Changes the default channel for 'New events'");
26 GEM_ChatPrint("/gem setalias <ChannelName> <Alias> <SlashCmd> : Sets alias/slashcmd for this channel");
27 GEM_ChatPrint("/gem delalias <ChannelName> : Removes alias and slashcmd for this channel");
28 GEM_ChatPrint("--- ADVANCED COMMANDS ---");
29 GEM_ChatPrint("/gem offset <hours> : Forces an offset from the server (in hours, can be negative)");
30 GEM_ChatPrint("--- Debug commands ---");
31 GEM_ChatPrint("/gem debug <1/2/0> : Sets or not debug mode (2=debug+log)");
32 end
33  
34 function GEM_CMD_Command(cmd,param)
35 if(cmd == "toggle")
36 then
37 GEM_Toggle();
38 return true;
39 elseif(cmd == "debug")
40 then
41 if(param == "1")
42 then
43 GEM_DBG_SetDebugMode(1,true);
44 GEM_ChatPrint("Debug mode ON");
45 elseif(param == "2")
46 then
47 GEM_DBG_SetDebugMode(2,true);
48 GEM_ChatPrint("Debug mode ON WITH LOG");
49 else
50 GEM_DBG_SetDebugMode(0,true);
51 GEM_ChatPrint("Debug mode OFF");
52 end
53 return true;
54 elseif(cmd == "join")
55 then
56 GEM_InitChannels(false);
57 return true;
58 elseif(cmd == "channels")
59 then
60 GEM_ChatPrint("GEM channels list : <Name> : <Password> : <Alias> : <SlashCmd>");
61 for channame, tab in GEM_COM_Channels
62 do
63 local def = "";
64 if(channame == GEM_DefaultSendChannel)
65 then
66 def = "(Default channel for 'New events')";
67 end
68 local pwd = tab.password;
69 if(pwd == nil or pwd == "")
70 then
71 pwd = "(no password)";
72 end
73 local alias = tab.alias;
74 if(alias == nil or alias == "")
75 then
76 alias = "(no alias)";
77 end
78 local slash = tab.slash;
79 if(slash == nil or slash == "")
80 then
81 slash = "(no slash)";
82 end
83 GEM_ChatPrint(" - "..channame.." "..def.." : "..pwd.." : "..alias.." : "..slash);
84 end
85 GEM_ChatPrint("End of listing");
86 return true;
87 elseif(cmd == "addchan")
88 then
89 if(not param or param == "")
90 then
91 GEM_ChatPrint("Need to specify a channel name");
92 return true;
93 end
94 local _,_,chan,pwd = string.find(param,"([^%s]+)%s*(.*)");
95 if(not chan)
96 then
97 GEM_ChatPrint("Need to specify a channel name");
98 return true;
99 end
100 GEMOptions_AddChannel(chan,pwd,"","");
101 GEM_ChatPrint("Channel "..chan.." added !");
102 return true;
103 elseif(cmd == "delchan")
104 then
105 if(not param or param == "")
106 then
107 GEM_ChatPrint("Need to specify a channel name");
108 return true;
109 end
110 if(not GEM_COM_Channels[param])
111 then
112 GEM_ChatPrint("Unknown GEM channel "..param);
113 return true;
114 end
115 GEMOptions_RemoveChannel(param);
116 GEM_ChatPrint("Channel "..param.." removed !");
117 return true;
118 elseif(cmd == "setdefchan")
119 then
120 if(not param or param == "")
121 then
122 GEM_ChatPrint("Need to specify a channel name");
123 return true;
124 end
125 if(not GEM_COM_Channels[param])
126 then
127 GEM_ChatPrint("Unknown GEM channel "..param);
128 return true;
129 end
130 GEM_DefaultSendChannel = param;
131 GEM_ChatPrint("Channel "..param.." set as default one for New events !");
132 return true;
133 elseif(cmd == "setalias")
134 then
135 if(not param or param == "")
136 then
137 GEM_ChatPrint("Need to specify a channel");
138 return true;
139 end
140 local _,_,chan,alias,slash = string.find(param,"([^%s]+)%s+([^%s]+)%s+([^%s]+)");
141 if(chan == nil or alias == nil or slash == nil or chan == "" or alias == "" or slash == "")
142 then
143 GEM_ChatPrint("Need to specify a channel, an alias and a slashcmd");
144 return true;
145 end
146 if(not GEM_COM_Channels[chan])
147 then
148 GEM_ChatPrint("Unknown GEM channel "..chan);
149 return true;
150 end
151 for i,chantab in GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].channels
152 do
153 if(chantab.name == chan)
154 then
155 chantab.alias = alias;
156 chantab.slash = slash;
157 break;
158 end
159 end
160 GEM_COM_Channels[chan].alias = alias;
161 GEM_COM_Channels[chan].slash = slash;
162 GEM_COM_AliasChannel(chan,GEM_COM_Channels[chan].alias,GEM_COM_Channels[chan].slash);
163 GEM_ChatPrint("Alias and SlashCmd for channel "..chan.." set to : "..alias.." : "..slash);
164 return true;
165 elseif(cmd == "delalias")
166 then
167 if(not param or param == "")
168 then
169 GEM_ChatPrint("Need to specify a channel");
170 return true;
171 end
172 if(not GEM_COM_Channels[param])
173 then
174 GEM_ChatPrint("Unknown GEM channel "..param);
175 return true;
176 end
177 for i,chantab in GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].channels
178 do
179 if(chantab.name == param)
180 then
181 chantab.alias = "";
182 chantab.slash = "";
183 break;
184 end
185 end
186 GEM_COM_UnAliasChannel(param,GEM_COM_Channels[param].alias,GEM_COM_Channels[param].slash);
187 GEM_COM_Channels[param].alias = "";
188 GEM_COM_Channels[param].slash = "";
189 GEM_ChatPrint("Removed Alias and SlashCmd for channel "..param);
190 return true;
191 elseif(cmd == "offset")
192 then
193 local hours = tonumber(param);
194 if(hours == nil)
195 then
196 GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].ForceHourOffset = nil;
197 GEM_ChatPrint("Removing Forced hours offset !");
198 else
199 if(hours > 24 or hours < -24)
200 then
201 GEM_ChatPrint("Hour offset value must be <24 and >-24");
202 end
203 GEM_Events.realms[GEM_Realm].my_names[GEM_PlayerName].ForceHourOffset = hours;
204 GEM_ChatPrint("Forced hour offset to "..hours.." hours !");
205 end
206 GEM_ServerOffset = 666;
207 GEM_ComputeServerOffset();
208 GEMNew_Reset();
209 return true;
210 end
211 return false;
212 end