public static void InitIrc() { if (!File.Exists(AccountAssociationsList.FilePath)) { var list = new AccountAssociationsList(); list.SaveAs(AccountAssociationsList.FilePath); } AccountAssociationsList.LoadDictionary(AccountAssociationsList.AccountAssociationFileName); try { var client = new IrcConnection { Nicks = IrcAddonConfig.Nicks, UserName = IrcAddonConfig.UserName, // the name that will appear in the hostmask before @ e.g. [email protected] Info = IrcAddonConfig.Info,// The info line: [email protected] : asd (<- this bit) ServerPassword = IrcAddonConfig.ServerPassword }; WCellUtil.Init(client); client.BeginConnect(IrcAddonConfig.Network, IrcAddonConfig.Port); client.CommandHandler.AddCmdsOfAsm(typeof(IrcConnection).Assembly); } catch (Exception e) { //Console.WriteLine("Exception: {0}", e); LogUtil.ErrorException(e, "[IRCAddon] Unable to connect to {0}", IrcAddonConfig.Network); } }
private static void TryExecuteWCellCommand(IrcUser user, IrcChannel chan, string text) { var uArgs = user.Args as WCellArgs; if (uArgs != null && uArgs.CmdArgs != null) { WCellUtil.HandleCommand((WCellUser)uArgs.CmdArgs.User, user, chan, text); } }
/// <summary> /// Dumps the packet to string form, using hexadecimal as the formatter /// </summary> /// <returns>hexadecimal representation of the data parsed</returns> public string ToHexDump() { FinalizeWrite(); //var segment = Segment; //return Utility.ToHex(PacketID, segment.Buffer.Array, segment.Offset + HeaderSize, ContentLength); var content = ((MemoryStream)BaseStream).ToArray(); return(WCellUtil.ToHex(PacketId, content, HeaderSize, ContentLength)); }
public override void Process(CmdTrigger <RealmServerCmdArgs> trigger) { long totalBytesSent = ClientBase.TotalBytesSent; long totalBytesReceived = ClientBase.TotalBytesReceived; int totalSegmentCount = BufferManager.Default.TotalSegmentCount; int availableSegmentsCount = BufferManager.Default.AvailableSegmentsCount; long globalAllocatedMemory = BufferManager.GlobalAllocatedMemory; trigger.Reply("[Network] Total data sent: {0}, Total data received: {1}", (object)WCellUtil.FormatBytes(totalBytesSent), (object)WCellUtil.FormatBytes(totalBytesReceived)); trigger.Reply("[Buffers] {0} available packet buffers out of {1}", (object)availableSegmentsCount.ToString(), (object)totalSegmentCount.ToString()); trigger.Reply("[Buffers] {0} allocated globally", (object)WCellUtil.FormatBytes(globalAllocatedMemory)); }
public override void Process(CmdTrigger <RealmServerCmdArgs> trigger) { long totalDataSent, totalDataReceived, totalAllocMemory; int bufferPoolSize, bufferPoolAvail; totalDataSent = RealmClient.TotalBytesSent; totalDataReceived = RealmClient.TotalBytesReceived; bufferPoolSize = BufferManager.Default.TotalSegmentCount; bufferPoolAvail = BufferManager.Default.AvailableSegmentsCount; totalAllocMemory = BufferManager.GlobalAllocatedMemory; trigger.Reply("[Network] Total data sent: {0}, Total data received: {1}", WCellUtil.FormatBytes(totalDataSent), WCellUtil.FormatBytes(totalDataReceived)); trigger.Reply("[Buffers] {0} available packet buffers out of {1}", bufferPoolAvail.ToString(), bufferPoolSize.ToString()); trigger.Reply("[Buffers] {0} allocated globally", WCellUtil.FormatBytes(totalAllocMemory)); }
/// <summary> /// Dumps the packet to string form, using hexadecimal as the formatter /// </summary> /// <returns>hexadecimal representation of the data parsed</returns> public string ToHexDump() { this.FinalizeWrite(); return(WCellUtil.ToHex(this.PacketId, ((MemoryStream)this.BaseStream).ToArray(), this.HeaderSize, this.ContentLength)); }
/// <summary> /// Dumps the packet to string form, using hexadecimal as the formatter /// </summary> /// <returns>hexadecimal representation of the data parsed</returns> public string ToHexDump() { FinalizeWrite(); return(WCellUtil.ToHex(PacketId, ((MemoryStream)BaseStream).ToArray(), HeaderSize, ContentLength)); }
/// <summary> /// </summary> /// <returns></returns> public string ToHexDump() { return(WCellUtil.ToHex(PacketId, _segment.Buffer.Array, _segment.Offset + _offset, Length)); }
protected override void OnText(IrcUser user, IrcChannel chan, StringStream text) { //Any new command prefixes set by the user //i.e using the "cfg s -a irc IrcCmdPrefixes newprefix" command CommandHandler.RemoteCommandPrefixes = IrcCmdPrefixes; if (!HideChatting) { //Display any received text in the console Console.WriteLine("<{0}> {1}", user, text); } // Just text! if (!HasCommandPrefix(text, IrcCmdPrefixes)) { return; } //Remove any spaces that follow the command prefix text.ConsumeSpace(); //we need to clone the text stream in case we have //a wcell command, otherwise the processing we do will //consume anything after the prefix var commandText = text.CloneStream(); //create a command trigger var trigger = new PrivmsgCmdTrigger(text, user, chan); //check if we can find a command matching the //provided alias with any IRC commands var cmd = CommandHandler.GetCommand(trigger); //Is this command an IRC command? if (cmd != null) { //Yep it is! Now check if wcell also has this command? if (WCellUtil.CommandExists(trigger.Alias)) { //WCell also has the command, now we must //enforce case sensitivity on the command alias if (trigger.Alias.ToUpper() != trigger.Alias) //anything other than an upper case alias { trigger.Reply("Dont forget commands are case sensitive!"); trigger.Reply("Running IRC command; to execute the WCell command use {0} {1} [args]", IrcCmdPrefixes[0], trigger.Alias.ToUpper()); m_CommandHandler.Execute(trigger, cmd, false); return; } else //an upper case alias { trigger.Reply("Running WCell command; to execute the IRC command use {0} {1} [args]", IrcCmdPrefixes[0], trigger.Alias.ToLower()); text = commandText; CheckAuthAndTryExecuteWCellCommand(user, chan, text); return; } } //We have a unique IRC command, this is easy //just execute it! m_CommandHandler.Execute(trigger, cmd, false); } //If we couldn't find an IRC command try to execute it //as a wcell command! text = commandText; //reset the text first though :) CheckAuthAndTryExecuteWCellCommand(user, chan, text); }
/// <summary> /// </summary> /// <returns></returns> public string ToHexDump() { return(WCellUtil.ToHex(this.PacketId, this._segment.Buffer.Array, this._segment.Offset + this._offset, this.Length)); }