Advertisement
Guest User

Untitled

a guest
May 4th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.23 KB | None | 0 0
  1.  
  2. Property changes on: .
  3. ___________________________________________________________________
  4. Modified: svn:ignore
  5. - obj
  6. WCell.IRCAddon.suo
  7.  
  8. + obj
  9. WCell.IRCAddon.suo
  10. IRCAddon.4.1.resharper.user
  11. IRCAddon.suo
  12. _ReSharper.IRCAddon
  13.  
  14.  
  15. Index: ChannelInfo.cs
  16. ===================================================================
  17. --- ChannelInfo.cs (revision 0)
  18. +++ ChannelInfo.cs (revision 0)
  19. @@ -0,0 +1,13 @@
  20. +using System;
  21. +using System.Collections.Generic;
  22. +using System.Linq;
  23. +using System.Text;
  24. +
  25. +namespace IRCAddon
  26. +{
  27. + public class ChannelInfo
  28. + {
  29. + public string ChannelName;
  30. + public string Password;
  31. + }
  32. +}
  33. Index: IRCAddon.csproj
  34. ===================================================================
  35. --- IRCAddon.csproj (revision 46)
  36. +++ IRCAddon.csproj (working copy)
  37. @@ -3,7 +3,7 @@
  38. <PropertyGroup>
  39. <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  40. <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  41. - <ProductVersion>9.0.30729</ProductVersion>
  42. + <ProductVersion>9.0.21022</ProductVersion>
  43. <SchemaVersion>2.0</SchemaVersion>
  44. <ProjectGuid>{E8F36B44-3596-42A5-9380-4386CF04EDD6}</ProjectGuid>
  45. <OutputType>Library</OutputType>
  46. @@ -64,6 +64,7 @@
  47. -->
  48. <ItemGroup>
  49. <Compile Include="AccountAssociationsList.cs" />
  50. + <Compile Include="ChannelInfo.cs" />
  51. <Compile Include="Commands\AccountAssociationsCommand.cs" />
  52. <Compile Include="Commands\IrcCommands.cs" />
  53. <Compile Include="Commands\RealmServerCommands.cs" />
  54. Index: IrcAddonConfig.cs
  55. ===================================================================
  56. --- IrcAddonConfig.cs (revision 46)
  57. +++ IrcAddonConfig.cs (working copy)
  58. @@ -1,39 +1,65 @@
  59. &#65279;using System.Collections.Generic;
  60. using Squishy.Irc;
  61. using WCell.RealmServer;
  62. +using WCell.Util.Variables;
  63. +using System;
  64.  
  65. namespace IRCAddon
  66. {
  67. - public class IrcAddonConfig
  68. - {
  69. - public static string[] ChannelList = {"#ChannelName,ChannelKey"};
  70. - // Note: All the channels you want the client to connect to, key being the channel's key.
  71. - // Note: If the key is empty (""), it will presume there is no key and connect normally
  72. - // Note: Example 1) "#WCell," (will join the channel #WCell without a key)
  73. - // NOTE: Example 2) "#WCell,password12" (will join the channel #WCell with the key "password12" (no spaces)
  74. - /// <summary>
  75. - /// Channels you want to keep updated according to the latest server status
  76. - /// Broadcasts are also posted in these channels.
  77. - /// </summary>
  78. - public static string[] UpdatedChannels = {"#ChannelName"};
  79. + public class IrcAddonConfig
  80. + {
  81. + public static string[] ChannelList = { "#ChannelName,ChannelKey" };
  82. + // Note: All the channels you want the client to connect to, key being the channel's key.
  83. + // Note: If the key is empty (""), it will presume there is no key and connect normally
  84. + // Note: Example 1) "#WCell," (will join the channel #WCell without a key)
  85. + // NOTE: Example 2) "#WCell,password12" (will join the channel #WCell with the key "password12" (no spaces)
  86.  
  87. - public static string[] ExceptionChan = {"#ExceptionChannel,ChannelKey"};
  88. - public static string Info = "ChangeMe";
  89. - public static string Network = "euroserv.fr.quakenet.org"; //The network the client will connect to.
  90. - public static string[] Nicks = new[] { RealmServerConfiguration.RealmName, RealmServerConfiguration.RealmName + "2", RealmServerConfiguration.RealmName + "3"}; //The nicks the client will try and use.
  91. - public static int Port = 6667; //The port the client will connect to.
  92. + private static string[] updatedChannelNames = { "#ChannelName" };
  93.  
  94. - public static Privilege RequiredStaffPriv = Privilege.HalfOp;
  95. - public static string UserName = "Mokbot";
  96. + /// <summary>
  97. + /// Channels you want to keep updated according to the latest server status
  98. + /// Broadcasts are also posted in these channels.
  99. + /// </summary>
  100. + [Variable("UpdatedChannels")]
  101. + public static string[] UpdatedChannelNames
  102. + {
  103. + get { return updatedChannelNames; }
  104. + set
  105. + {
  106. + updatedChannelNames = value;
  107. + UpdatedChannels = new ChannelInfo[value.Length];
  108. + for (var i = 0; i < value.Length; i++)
  109. + {
  110. + var chan = value[i].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  111.  
  112. - public static bool PerformOnConnect = true;
  113. - public static string[] PerformMethods = {"!msg #asda Just testing Perform"};
  114. + UpdatedChannels[i] = new ChannelInfo
  115. + {
  116. + ChannelName = chan[0].Trim(),
  117. + Password = chan.Length > 1 ? chan[1] : ""
  118. + };
  119. + }
  120. + }
  121. + }
  122.  
  123. - public static bool CallOnChannelJoin = true;
  124. + public static ChannelInfo[] UpdatedChannels = new ChannelInfo[0];
  125.  
  126. - public static string[] CallOnJoin = {
  127. + public static string[] ExceptionChan = { "#ExceptionChannel,ChannelKey" };
  128. + public static string Info = "ChangeMe";
  129. + public static string Network = "euroserv.fr.quakenet.org"; //The network the client will connect to.
  130. + public static string[] Nicks = new[] { RealmServerConfiguration.RealmName, RealmServerConfiguration.RealmName + "2", RealmServerConfiguration.RealmName + "3" }; //The nicks the client will try and use.
  131. + public static int Port = 6667; //The port the client will connect to.
  132. +
  133. + public static Privilege RequiredStaffPriv = Privilege.HalfOp;
  134. + public static string UserName = "Mokbot";
  135. +
  136. + public static bool PerformOnConnect = true;
  137. + public static string[] PerformMethods = { "!msg #asda Just testing Perform" };
  138. +
  139. + public static bool CallOnChannelJoin = true;
  140. +
  141. + public static string[] CallOnJoin = {
  142. "#asda:!someCommand;!AnotherCommand arg1 arg2;#WCellCommand arg1 arg2",
  143. "#chan2:!someCommand;!AnotherCommand arg1 arg2;#WCellCommand arg1 arg2"
  144. };
  145. - }
  146. + }
  147. }
  148. \ No newline at end of file
  149. Index: IrcConnection.cs
  150. ===================================================================
  151. --- IrcConnection.cs (revision 46)
  152. +++ IrcConnection.cs (working copy)
  153. @@ -81,30 +81,32 @@
  154. ProtocolHandler.PacketReceived += OnReceive;
  155. RealmServer.Shutdown += OnShutdown;
  156. RealmServer.Instance.StatusChanged += OnStatusNameChange;
  157. - World.Broadcasted += World_Broadcasted;
  158. + World.Broadcasted += OnBroadcast;
  159. _maintainConnTimer = new Timer(MaintainCallback);
  160. LogUtil.ExceptionRaised += LogUtilExceptionRaised;
  161. - Client.Disconnected += Client_Disconnected;
  162. + Client.Disconnected += OnDisconnect;
  163. }
  164.  
  165. - void World_Broadcasted(IChatter sender, string message)
  166. + void OnBroadcast(IChatter sender, string message)
  167. {
  168. if (EchoBroadcasts)
  169. {
  170. - foreach (var chan in IrcAddonConfig.UpdatedChannels)
  171. + foreach (var chanInfo in IrcAddonConfig.UpdatedChannels)
  172. {
  173. + var chan = GetChannel(chanInfo.ChannelName);
  174. + if (chan == null) continue;
  175. if(sender != null)
  176. {
  177. - GetChannel(chan).Msg(sender.Name + ": " + ChatUtility.Strip(message));
  178. + chan.Msg(sender.Name + ": " + ChatUtility.Strip(message));
  179. }
  180. else
  181. {
  182. - GetChannel(chan).Msg(ChatUtility.Strip(message));
  183. + chan.Msg(ChatUtility.Strip(message));
  184. }
  185. }
  186. }
  187. }
  188. - void Client_Disconnected(Connection con, bool connectionLost)
  189. + void OnDisconnect(Connection con, bool connectionLost)
  190. {
  191. if(connectionLost && ReConnectOnDisconnect)
  192. {
  193. @@ -141,10 +143,10 @@
  194. WCellUtil.Init(client);
  195. client.BeginConnect(IrcAddonConfig.Network, IrcAddonConfig.Port);
  196. }
  197. -
  198. catch (Exception e)
  199. {
  200. - Console.WriteLine("Exception: {0}", e);
  201. + //Console.WriteLine("Exception: {0}", e);
  202. + LogUtil.ErrorException(e, "[IRCAddon] Unable to connect to {0}", IrcAddonConfig.Network);
  203. }
  204. }
  205.  
  206. @@ -195,11 +197,11 @@
  207.  
  208. // We want the bot to join each channel that the user wants updated,
  209. // just in case s/he forgot to put them on ChannelList
  210. - foreach(var chan in IrcAddonConfig.UpdatedChannels)
  211. + foreach(var info in IrcAddonConfig.UpdatedChannels)
  212. {
  213. - if(!Channels.Keys.Contains(chan))
  214. + if(!Channels.Keys.Contains(info.ChannelName))
  215. {
  216. - CommandHandler.Join(chan);
  217. + CommandHandler.Join(info.ChannelName, info.Password);
  218. }
  219. }
  220.  
  221. @@ -384,33 +386,31 @@
  222.  
  223. protected override void OnUsersAdded(IrcChannel chan, IrcUser[] users)
  224. {
  225. - Console.WriteLine("Topic was set {0} by {1}", chan.TopicSetTime, chan.TopicSetter);
  226. - Console.WriteLine("Topic is: {0}", chan.Topic);
  227. - if (IrcAddonConfig.UpdatedChannels.Length != 0)
  228. - {
  229. - foreach (var channel in IrcAddonConfig.UpdatedChannels)
  230. - {
  231. - if (chan.Name == channel)
  232. - {
  233. - UpdateTopic(chan, chan.Topic);
  234. - }
  235. - }
  236. - }
  237. - if (AutoAuth)
  238. - {
  239. - if (AuthAllUsersOnJoin)
  240. - foreach (var usr in users)
  241. - {
  242. - if (AnnounceAuthToUser)
  243. - {
  244. - usr.Msg("Resolving User...".Colorize(IrcColorCode.Red));
  245. - }
  246. - AuthMgr.ResolveAuth(usr);
  247. - }
  248. - }
  249. + Console.WriteLine("Topic was set {0} by {1}", chan.TopicSetTime, chan.TopicSetter);
  250. + Console.WriteLine("Topic is: {0}", chan.Topic);
  251. + foreach (var channel in IrcAddonConfig.UpdatedChannels)
  252. + {
  253. + if (chan.Name == channel.ChannelName)
  254. + {
  255. + UpdateTopic(chan, chan.Topic);
  256. + }
  257. + }
  258. +
  259. + if (AutoAuth)
  260. + {
  261. + if (AuthAllUsersOnJoin)
  262. + foreach (var usr in users)
  263. + {
  264. + if (AnnounceAuthToUser)
  265. + {
  266. + usr.Msg("Resolving User...".Colorize(IrcColorCode.Red));
  267. + }
  268. + AuthMgr.ResolveAuth(usr);
  269. + }
  270. + }
  271. }
  272.  
  273. - // Try and update the topic of the channel after the bot has been privileged
  274. + // Try and update the topic of the channel after the bot has been privileged
  275. // Useful when the bot joined and wasn't privileged to change the topic and if
  276. // afterwards a user/network service/bot opped the bot, it will try and update the topic
  277. // Bear in mind this will update the status of *any* channel he is given op or higher priv
  278. @@ -702,20 +702,17 @@
  279.  
  280. private void UpdateImportantChannels()
  281. {
  282. - if (IrcAddonConfig.UpdatedChannels.Length != 0)
  283. - {
  284. - foreach (var chan in IrcAddonConfig.UpdatedChannels)
  285. - {
  286. - if (_watchedChannels.Contains(chan))
  287. - {
  288. - var channel = GetChannel(chan);
  289. - UpdateTopic(channel, channel.Topic);
  290. - }
  291. - }
  292. - }
  293. + foreach (var chan in IrcAddonConfig.UpdatedChannels)
  294. + {
  295. + if (_watchedChannels.Contains(chan.ChannelName))
  296. + {
  297. + var channel = GetChannel(chan.ChannelName);
  298. + UpdateTopic(channel, channel.Topic);
  299. + }
  300. + }
  301. }
  302.  
  303. - /// <summary>
  304. + /// <summary>
  305. /// Formats the channel's topic and adds server status
  306. /// Only used in OnTopic
  307. /// </summary>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement