public void Start() { Irc.Connect(Address, Port); Irc.Login("FPGitBot", "FPGitBot", 0, "FPGitBot"); Irc.RfcJoin(Channel); new Thread(o => ((IrcClient)o).Listen()).Start(Irc); }
public async void Connect(Irc irc) { if (IrcHandler.connectedServersList.Contains(irc.server.name)) { return; } if (IrcHandler.connectedServersList.Contains(irc.server.hostname)) { return; } ExtendExecution(); irc.HandleDisconnect += HandleDisconnect; // connect if (((Tabs.Items[0] as PivotItem).Content as Frame).Content is PlaceholderView) { Tabs.Items.RemoveAt(0); } if (Config.GetBoolean(Config.UseTabs)) { CreateNewTab(irc.server.name); } lastAuto = Config.GetBoolean(Config.UseTabs); irc.Connect(); // link the server up to the lists IrcHandler.connectedServers.Add(irc.server.name, irc); IrcHandler.connectedServersList.Add(irc.server.name); serversCombo.SelectedItem = irc.server.name; currentServer = irc.server.name; channelList.ItemsSource = IrcHandler.connectedServers[currentServer].channelList; }
/// <summary> /// Main loop for the CLI demo of the IrcClientCore /// </summary> private void Start() { IrcServer server = null; if (Prompt("Load Server?")) { var name = ReadLine.Read("Server Name: "); server = Serialize.DeserializeObject <IrcServer>(name); } if (server == null) { Console.WriteLine("Creating server..."); server = new IrcServer() { Name = ReadLine.Read("Server Name: "), Hostname = ReadLine.Read("Server Hostname: "), Port = Convert.ToInt32(ReadLine.Read("Server Port: ", "6667")), Ssl = Prompt("Use SSL:"), IgnoreCertErrors = true, Username = ReadLine.Read("Username: "******"Password: "******"Channels to join (format #channel,#other...): ") }; if (Prompt("Save Server?")) { Serialize.SerializeObject(server, server.Name); } } Console.WriteLine($"Connecting to {server.Hostname}"); _socket = new Irc(server); _socket.Initialise(); _socket.Connect(); ((Buffer)_socket.InfoBuffer).Collection.CollectionChanged += ChannelBuffersOnCollectionChanged; var handler = _socket.CommandManager; handler.RegisterCommand("/switch", new SwitchCommand(this)); handler.RegisterCommand("/reconnect", new ReconnectCommand()); handler.RegisterCommand("/users", new UsersCommand()); _autocompleteHandler = new AutocompleteHandler(handler); ReadLine.AutoCompletionHandler = _autocompleteHandler; SwitchChannel(""); _socket.HandleDisplayChannelList = HandleChannelList; while (!_socket.ReadOrWriteFailed) { var prefix = _currentChannel != null ? $"[{_currentChannel} ({_socket.GetChannelUsers(_currentChannel).Count})] " : ""; var line = ReadLine.Read($"{prefix}> "); // Get string from user if (line == "") { continue; } handler.HandleCommand(_currentChannel, line); } }