static void Main(string[] args) { int ircPort; if (args.Length < 7 || !UUID.TryParse(args[3], out _MasterID) || !int.TryParse(args[5], out ircPort) || args[6].IndexOf('#') == -1) Console.WriteLine("Usage: ircgateway.exe <firstName> <lastName> <password> <masterUUID> <ircHost> <ircPort> <#channel>"); else { _Client = new GridClient(); _Client.Network.OnLogin += new NetworkManager.LoginCallback(Network_OnLogin); _Client.Self.ChatFromSimulator += new EventHandler<ChatEventArgs>(Self_ChatFromSimulator); _Client.Self.IM += Self_IM; _ClientLogin = _Client.Network.DefaultLoginParams(args[0], args[1], args[2], "", "IRCGateway"); _AutoJoinChannel = args[6]; _IRC = new IRCClient(args[4], ircPort, "SLGateway", "Second Life Gateway"); _IRC.OnConnected += new IRCClient.ConnectCallback(_IRC_OnConnected); _IRC.OnMessage += new IRCClient.MessageCallback(_IRC_OnMessage); _IRC.Connect(); string read = Console.ReadLine(); while (read != null) read = Console.ReadLine(); } }
/// <summary> /// Initiates; attempts creation of tcp connection using credentials specified in /// credentials file. /// </summary> public Akiraionbotapp() { if (client_id == "") { StreamReader file = new StreamReader(@"streamfolder\credentials.txt"); string userClientPattern = @".*;.*"; string passPassPattern = @"password=\s?.*"; string ownPattern = @"owner=\s?.*"; string clientIDPattern = @"(?<=(;)).*"; string usernamePattern = @"(?=(\w+;))\w+"; string passwordPattern = @"(?<=(password=\s?)).*"; string ownerPattern = @"(?<=(owner=\s?)).*"; string line; while ((line = file.ReadLine()) != null) { if (Regex.IsMatch(line, userClientPattern)) { username = Regex.Match(line, usernamePattern).ToString(); client_id = Regex.Match(line, clientIDPattern).ToString(); } else if (Regex.IsMatch(line, passPassPattern)) { password = Regex.Match(line, passwordPattern).ToString(); } else if (Regex.IsMatch(line, ownPattern)) { owner = Regex.Match(line, ownerPattern).ToString(); } } } irc = new IRCClient("irc.twitch.tv", 6667, username, password); InitializeComponent(); }
internal ChannelUser(IRCClient client, User baseUser, Channel channel) : base(client) { _baseUser = baseUser; _channel = channel; Privileges = ChannelPrivilege.Normal; }
/// <summary> /// Helper to initialise all of the clients we will need /// </summary> private static void InitialiseClients() { _ircClient = new IRCClient( ClientConnectionSettings.IRC_SERVER, ClientConnectionSettings.IRC_PORT, ClientConnectionSettings.IRC_USER, ClientConnectionSettings.IRC_NICK, ClientConnectionSettings.IRC_PASSWORD); // Try and connect to the irc server with a 20 second timeout if (!_ircClient.Connect(20000)) { throw new Exception("Failed to connect to IRC server."); } _ircClient.JoinChannel(ClientConnectionSettings.IRC_CHANNEL); _imgur = new ImgurClient( ClientConnectionSettings.IMGUR_CLIENT_ID, ClientConnectionSettings.IMGUR_CLIENT_SECRET, ClientConnectionSettings.IMGUR_REFRESH_TOKEN); _telegramClient = new TelegramClient( ClientConnectionSettings.TELEGRAM_SERVER, ClientConnectionSettings.TELEGRAM_TOKEN, ClientConnectionSettings.TELEGRAM_CLIENT_ID); }
static void Main(string[] args) { int ircPort; if (args.Length < 7 || !UUID.TryParse(args[3], out _MasterID) || !int.TryParse(args[5], out ircPort) || args[6].IndexOf('#') == -1) { Console.WriteLine("Usage: ircgateway.exe <firstName> <lastName> <password> <masterUUID> <ircHost> <ircPort> <#channel>"); } else { _Client = new GridClient(); _Client.Network.LoginProgress += Network_OnLogin; _Client.Self.ChatFromSimulator += Self_ChatFromSimulator; _Client.Self.IM += Self_IM; _ClientLogin = _Client.Network.DefaultLoginParams(args[0], args[1], args[2], "", "IRCGateway"); _AutoJoinChannel = args[6]; _IRC = new IRCClient(args[4], ircPort, "SLGateway", "Second Life Gateway"); _IRC.OnConnected += new IRCClient.ConnectCallback(_IRC_OnConnected); _IRC.OnMessage += new IRCClient.MessageCallback(_IRC_OnMessage); _IRC.Connect(); string read = Console.ReadLine(); while (read != null) { read = Console.ReadLine(); } } }
public static void Start() { try { InitialiseClients(); StartThreads(); while (true) { Thread.Sleep(10000); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.Write(ex.StackTrace); Console.ReadKey(); } finally { // Dispose of any resources if (_ircClient != null) { _ircClient.Dispose(); _ircClient = null; } if (_telegramClient != null) { _telegramClient.Dispose(); _telegramClient = null; } } }
public RedirectorToIRC(string settingsPath, DiscordClient discordClient, IRCClient ircClient) { if (File.Exists(settingsPath)) { var json = File.ReadAllText(settingsPath); Redirects = JsonConvert.DeserializeObject <List <RedirectToIRC> >(json); } else { Redirects = new List <RedirectToIRC>(); } #region Assign Redirects foreach (var red in Redirects) { discordClient.Client.MessageReceived += async(message) => { if (message.Channel.Id == red.DiscordChannel) { if (red.Attachments) { foreach (var att in message.Attachments) { await ircClient.SendToChannelAsync(red.IRCChannel, $"{red.PrefixForMessage}{att.Url}"); } } if (red.ChannelMessages) { await ircClient.SendToChannelAsync(red.IRCChannel, $"{red.PrefixForMessage}{message.Content}"); } } }; } #endregion }
internal User(IRCClient client) { _client = client; _channelMessages = new ConcurrentDictionary <string, List <string> >(); _channels = new List <Channel>(); Channels = new ReadOnlyCollection <Channel>(_channels); }
public static void Main(string[] args) { string[] configuration = File.ReadAllLines(args[0]); IRCClient = new IRCClient(configuration[0], Convert.ToInt32(configuration[1]), configuration[2], configuration[3], Convert.ToBoolean(configuration[4]), configuration[5]); IRCClient.Connect(); IRCClient.MessageRecieved += IRCClient_OnMessageRecieved; IRCClient.Kicked += IRCClient_OnKicked; IRCClient.BeginListening(); }
static void Main(string[] args) { IConfig config = container.GetRequiredService <IConfig>(); var logger = config.GetLogger("IRCClient"); logger.Error("test"); IRCClient client = new IRCClient("irc.quakenet.org", 6667, "HappyIRC", "HappyIRC", config); client.Connect(); }
private static void VoteThread() { Poll[] pollArray = ActivePolls.ToArray(); for (int i = 0; i < pollArray.Length; i++) { if (pollArray[i].TimesUp()) { var msg = EndPoll(pollArray[i]); IRCClient.SendIRCAnPrintConsoleMessage(msg); } } }
static void Main(string[] args) { PixivDownloader downloader = new PixivDownloader("pixiv.json"); IRCClient ircClient = JsonConvert.DeserializeObject <IRCClient>(File.ReadAllText("irc.json")); ircClient.PixivDownloader = downloader; TelegramClient telegramClient = JsonConvert.DeserializeObject <TelegramClient>(File.ReadAllText("telegram.json")); telegramClient.PixivDownloader = downloader; telegramClient.Setup(); DiscordClient discordClient = JsonConvert.DeserializeObject <DiscordClient>(File.ReadAllText("discord.json")); discordClient.PixivDownloader = downloader; discordClient.IRCClient = ircClient; ircClient.DiscordClient = discordClient; ircClient.Setup(); ircClient.Connect(); var ircRun = new Task(ircClient.Run); ircRun.Start(); discordClient.Client.MessageReceived += async(msgArgs) => { if (msgArgs.Channel.Id == 337692280267997196 && msgArgs.Author.Id != discordClient.Client.CurrentUser.Id) { foreach (var attach in msgArgs.Attachments) { await ircClient.SendAsync($"PRIVMSG #onioniichan :{attach.Url}"); } } }; var discordRun = new Task(async() => await discordClient.Run()); discordRun.Start(); var telegramRun = new Task(async() => await telegramClient.Run()); telegramRun.Start(); var tasks = new List <Task>(); tasks.Add(ircRun); tasks.Add(discordRun); tasks.Add(telegramRun); Task.WaitAll(tasks.ToArray()); //try { // telegramClient.CTS.Cancel(); //} //catch (Exception ex) { } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); Console.WriteLine("Connecting to localhost port 6667..."); IRCClient client = new IRCClient("localhost", 6667); client.OnMotd += msg => { client.Send(IRCMessage.Join("#home")); }; client.OnJoin += (who, channel) => { }; client.Listen(); }
private void btnConnect_Click(object sender, EventArgs e) { client = new IRCClient(txtServer.Text, Convert.ToInt32(txtPort.Text), txtNickname.Text, txtChannel.Text, cbSsl.Checked, txtUsername.Text); if (!client.Connect()) { MessageBox.Show("Failed to connect! Timed out!"); return; } client.MessageRecieved += client_mesageRecieved; new Task(() => client.BeginListening()).Start(); currentChannel = txtChannel.Text; }
public void SendIRCMessage(String writeMessage) { IRCMessage message = new IRCMessage(); message.userName = Twitch.TwitchAPI._channel.Replace("#", ""); message.channel = Twitch.TwitchAPI._channel; IRCClient.SendIRCMessage(writeMessage); message.message = writeMessage; HandleUserCommands(message); //System Only Commands IRCClient.HandleMessages(message); }
public static bool HandleMessages(IRCMessage pMessageInfo) { //New Polls? IRCClient.CheckCommand(pMessageInfo, new String[] { "!newpoll" }, x => { if (x.NumberOfParameters > 2) { String name = x.commandParamSeperated[0].Trim(); List <String> pollOptions = new List <string>(); for (int i = 1; i < x.NumberOfParameters; i++) { pollOptions.Add(x.commandParamSeperated[i]); } MemorySystem._instance.NewPoll(name, pollOptions.ToArray(), DateTime.Now.AddMinutes(5)); var Options = String.Join(" OR ", pollOptions); IRCClient.SendIRCAnPrintConsoleMessage(name + " Poll Created!!!"); IRCClient.SendIRCAnPrintConsoleMessage("Type !" + name + " and one of these options [" + Options + "] to vote"); } else { IRCClient.SendIRCAnPrintConsoleMessage("Not Enough Poll Options >.<"); //Print Angry Message } }); IRCClient.CheckCommand(pMessageInfo, new String[] { "!endpoll" }, x => { var msg = MemorySystem._instance.EndPoll(x.commandParam); if (msg == null) { IRCClient.SendIRCAnPrintConsoleMessage("Poll Not Found >.<"); } else { IRCClient.SendIRCAnPrintConsoleMessage(msg); } }); IRCClient.CheckCommand(pMessageInfo, MemorySystem._instance.CurrentPolls(), x => { MemorySystem._instance.AddUserToPollWithOption(pMessageInfo.command, pMessageInfo.userName, pMessageInfo.commandParam); //Handle Voting On Poll Via SQLite }); return(false); }
public void Go() { _client = new IRCClient(_config); //_client.LineReceived += ClientOnLineReceived; _client.LineSent += ClientOnLineSent; _client.MessageReceived += ClientOnMessageReceived; _client.Connect(); _running = true; _channel = _config.Server.Channels[0]; new Thread(() => { while (_running) { Console.Write("> "); var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { continue; } if (input[0] == '/') { if (input.Length > 1) { var split = input.Split(" ", 2); if (split.Length == 2 && split[0] == "/me") { this._client.SendLine($"PRIVMSG {_channel} {(char)1}ACTION {split[1]}{(char)1}"); } else { this._client.SendLine(input.Substring(1)); } } } else { this._client.SendLine($"PRIVMSG {_channel} :{input}"); } } }).Start(); MainLoop(); }
public SpiffCore(string channel, string botName, string outh, string pluginDirectory) { Channel = channel; BotName = botName; PluginLoader = new PluginLoader(pluginDirectory); Commands = new Dictionary <string, Command>(); Instance = this; IrcClient = new IRCClient(channel, botName, outh, this); IrcClient.OnTwitchEvent += IrcClientOnOnTwitchEvent; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve; }
public static void Main() { var client = new IRCClient(new IRCConfiguration { Username = "******", Hostname = "irc.onlinegamesnet.net", Port = 6667 }); client.Ready += Client_Ready; client.UnhandledDataReceived += ClientOnUnhandledDataReceived; client.Connect(); Thread.Sleep(-1); }
/** * Function: StartBot() * Purpose: * Starts the threads neccessary to run the bot. * */ private void StartBot() { Debug.Log("Creating irc object...."); _irc = new IRCClient(twitchIRCURL, twitchIRCPortNumber, twitchAccountName, twitchOAuthKey, ircChannelName); Debug.Log("Creating ping thread object...."); _pingSender = new PingSender(_irc, pingDelayMillis); Debug.Log("Starting ping thread...."); _pingSender.Start(); Debug.Log("Creating chat polling thread object...."); _chatGetter = new ChatGetter(_irc, chatPollDelayMillis); Debug.Log("Starting chat polling thread...."); _chatGetter.Start(); if (ONIRCConnected != null) { ONIRCConnected(); } }
public void Start() { QuestionUser = ((x) => UserDialog?.Invoke(x)); Write = ((x, z) => WriteToConsole?.Invoke(x, z)); WriteLine = ((x, z) => WriteLineToConsole?.Invoke(x, z)); ThreadPool.QueueUserWorkItem(obj => { if (!FirstTimeSetup(QuestionUser)) { throw new Exception("First Time Params Not Set"); } IRCClient.Start(HandleUserCommands, Twitch.TwitchAPI._channel); TwitchAPI.Init(); VoteSystem.Init(); UserManager.Init(); IRCClient.Init(ConsoleWrite); MemorySystem._instance.Init(); Microphone.Init(); }); }
public void Start(QuestionUser pMethod, WriteToUser pWriteMethod, WriteToUser pWriteLineMethod) { Write = pWriteMethod; WriteLine = pWriteLineMethod; QuestionUser = pMethod; if (!FirstTimeSetup(QuestionUser)) { throw new Exception("First Time Params Not Set"); } IRCClient.Start(HandleUserCommands, Twitch.TwitchAPI._channel); TwitchAPI.Init(); VoteSystem.Init(); UserManager.Init(); IRCClient.Init(ConsoleWrite); MemorySystem._instance.Init(); Microphone.Init(); //IRCMessage message = new IRCMessage(); //message.userName = userName; //message.channel = Twitch.TwitchAPI._channel; }
//Handle Incoming IRC Messages public static bool HandleMessages(IRCMessage pMessageInfo) { try { if (!ActiveUsers.Contains(pMessageInfo.userName)) { ActiveUsers.Add(pMessageInfo.userName); //Shout out DateTime date = MemorySystem._instance.UsersLastActiveDate(pMessageInfo.userName); if (date != DateTime.MinValue) { IRCClient.PrintConsoleMessage(pMessageInfo.userName + " is back. Last seen " + date.ToShortDateString()); } } LoadSettings(); var userName = pMessageInfo.userName.ToLower(); var message = pMessageInfo.message.ToLower(); var result = false; { var split = message.Split(new String[] { "!voice" }, StringSplitOptions.None); if (split.Length > 1) { if (String.IsNullOrEmpty(split[1])) { IRCClient.SendIRCAnPrintConsoleMessage("!Avaliable Voices are: " + String.Join(",", Sync.voiceArray)); } else { var user = ListOfUserSettings.FirstOrDefault(x => x.UserName == userName); if (user != null) { user.Voice = split[1]; } else { ListOfUserSettings.Add(new UserSettings() { UserName = userName, Voice = split[1] }); } SaveSettings(); } } } { var split = message.Split(new String[] { "!lexicon" }, StringSplitOptions.None); if (split.Length > 1) { var user = ListOfUserSettings.FirstOrDefault(x => x.UserName == userName); if (user != null) { user.Lexicon = split[1].Trim(); } else { ListOfUserSettings.Add(new UserSettings() { UserName = userName, Lexicon = split[1].Trim() }); } SaveSettings(); SyncPool.ReloadLexicons(); } } IRCClient.CheckCommand(pMessageInfo, new string[] { "!points" }, x => { IRCClient.SendIRCAnPrintConsoleMessage(MemorySystem._instance.GetUserPoints()); }); return(result); } catch (Exception ex) { Logger.Log(ex.ToString()); return(false); } }
/*some random code I want to save for a bit... int count = Channels.TabCount; MessageBox.Show(count.ToString()); Channels.TabPages.RemoveByKey("#jefe323"); */ public static void Connect(string uServer, int uPort, string uReal, string uNick, string uPassword, string uChannel) { server = uServer; port = uPort; realname = uReal; nick = uNick; password = uPassword; channel = uChannel; irc = new IRCClient(uNick, uNick, uReal); irc.AutoReconnect = true; irc.NumberMessageReceived += new IRCClient.NumberMessageReceivedHandler(irc_NumberMessageReceived); irc.ChannelMessage += new IRCClient.ChannelMessageHandler(irc_ChannelMessage); irc.ServerMessageReceived += new IRCClient.ServerMessageReceivedHandler(irc_ServerMessageReceived); irc.Connect(uServer, uPort); irc.JoinChannel(channel); instance.ChannelList.Nodes[0].Nodes[0].Text = channel; instance.DefaultChannel.Name = channel.ToString(); instance.DefaultChannel.Text = channel.ToString(); }
public void Connect() { _client = new IRCClient(_ircHost, _ircPort, Settings.Username, Settings.OAuth, Settings.Channel.ToLower()); _client.OnPrivMsg += _client_OnPrivMsg; _client.Connect(); }
public void Start(QuestionUser pMethod, WriteToUser pWriteMethod, WriteLineToUser pWriteLineMethod) { Write = pWriteMethod; WriteLine = pWriteLineMethod; string userName = string.Empty; if (!File.Exists("Username.USER")) { userName = pMethod("UserName?"); File.WriteAllText("Username.USER", userName); } else { userName = File.ReadAllText("Username.USER"); } if (!File.Exists("SecretTokenDontLOOK.TOKEN")) { var password = pMethod("Token?"); File.WriteAllText("SecretTokenDontLOOK.TOKEN", password); } if (!File.Exists("Channel.JOIN")) { var channel = pMethod("Channel?(Leave blank for your own channel)"); if (String.IsNullOrEmpty(channel)) { channel = "#" + userName; } if (!channel.StartsWith("#")) { channel = "#" + channel; } File.WriteAllText("Channel.JOIN", channel); Twitch.TwitchAPI._channel = channel; } else { Twitch.TwitchAPI._channel = File.ReadAllText("Channel.JOIN"); } IRCClient.Start(HandleUserCommands, Twitch.TwitchAPI._channel); TwitchAPI.Init(); VoteSystem.Init(); UserManager.Init(); IRCClient.Init(ConsoleWrite); MemorySystem._instance.Init(); Microphone.Init(); IRCMessage message = new IRCMessage(); message.userName = userName; message.channel = Twitch.TwitchAPI._channel; while (true) { try { var writeMessage = Console.ReadLine(); if (writeMessage?.Trim() == "q") { break; } if (writeMessage?.Trim() != string.Empty) { IRCClient.SendIRCMessage(writeMessage); message.message = writeMessage; HandleUserCommands(message); //System Only Commands IRCClient.HandleMessages(message); } } catch (Exception ex) { Logger.Log(ex.ToString()); } } }
public TimeoutService(IRCClient client) { _client = client; LastPing = DateTimeOffset.Now; }
private void Work() { Console.WriteLine("Work thread begun"); while (running) { if (server.Pending()) { IRCClient cl = new IRCClient(server.AcceptTcpClient()); clients.Add(cl); Console.WriteLine("Recieved connection from {0}", clients[clients.Count - 1].HostName); } else if (clientList.NeedsToBeSaved) { foreach (KeyValuePair <ulong, SteamClient> c in clientList.Clients) { if (c.Value.HasMessage()) { IMessage m = c.Value.GetMessage(); Server.IRCCommands.CallCommand(m); } } clientList.Save("clients.list"); } else { IClient[] clientDupe = clients.ToArray(); foreach (IClient c in clientDupe) { if (c == null) { continue; } if (c.IsDisposed) { Console.WriteLine("Client {0} disconnected: {1}", c.UserString, c.DisconnectMsg); ClientHelpers.PartClient(c, c.DisconnectMsg); clients.Remove(c); continue; } if (c.HasMessage()) { IMessage m = c.GetMessage(); if (m.IsCommand && IRCCommands.HasCommand(m.Command)) { if (IRCCommands.ValidCommand(m.Command, m.Params.Length)) { IRCCommands.CallCommand(m); c.LastCommand = DateTime.Now; } else { Console.WriteLine("Invalid command call: \"{0}\"", m.MessageString); c.SendMessage(IRCMessage.GetStatic().CreateMessage(c, c.NickName, Reply.ERR_UNKNOWNCOMMAND, new string[] { c.NickName, m.Command, "Wrong parameters" })); } } else { Console.WriteLine("Unknown command: \"{0}\"", m.MessageString); c.SendMessage(IRCMessage.GetStatic().CreateMessage(c, c.NickName, Reply.ERR_UNKNOWNCOMMAND, new string[] { c.NickName, m.Command, "Unknown command" })); } } if (!c.Greeted && c.NickName != "*" && c.ClientType == ClientType.TYP_CLIENT) { ClientHelpers.MeetAndGreet(c); } else if (!c.Greeted && (DateTime.Now - c.LastCommand).TotalSeconds > 15) { c.Dispose("Never finished handshake"); } else if (c.Greeted && (DateTime.Now - c.LastPing).TotalSeconds > 30) { c.LastPing = DateTime.Now; c.SendMessage(IRCMessage.GetStatic().CreateMessage(c, null, "PING", new string[] { pingRandom.Next().ToString() })); c.MissedPings++; } else if (c.Greeted && c.MissedPings > 5) { c.Dispose("Ping Timeout!"); } } } Thread.Sleep(5); } Console.WriteLine("Work thread finished"); }
//Handle Incoming IRC Messages public static bool HandleMessages(IRCMessage pMessageInfo) { var message = pMessageInfo.message.ToLower(); var result = false; //New Polls? var split = message.Split(new String[] { "!newpoll" }, StringSplitOptions.None); if (split.Length > 1) { //New Poll Detected. var nameAndOptions = split[1].Split(','); if (nameAndOptions.Length > 2) { String name = nameAndOptions[0].Trim(); var poll = new Poll(name, "!" + name); for (int i = 1; i < nameAndOptions.Length; i++) { poll.AddOption(nameAndOptions[i]); } StartPoll(poll); var Options = String.Join(" OR ", nameAndOptions, 1, nameAndOptions.Length - 1); IRCClient.SendIRCAnPrintConsoleMessage(name + " Poll Created!!!"); IRCClient.SendIRCAnPrintConsoleMessage("Type !" + name + " and one of these options [" + Options + "] to vote"); result = true; } else { IRCClient.SendIRCAnPrintConsoleMessage("Not Enough Poll Options >.<"); //Print Angry Message } } //End Polls? var split2 = message.Split(new String[] { "!endpoll" }, StringSplitOptions.None); if (split2.Length > 1) { var poll = ActivePolls.FirstOrDefault(w => split2[1].Contains(w.PollName)); //New Poll Detected. if (poll != null) { var msg = EndPoll(poll); IRCClient.SendIRCAnPrintConsoleMessage(msg); result = true; } else { IRCClient.SendIRCAnPrintConsoleMessage("Poll Not Found >.<"); //Print Angry Message } } foreach (var poll in ActivePolls) { if (poll.HandleMessages(pMessageInfo)) { result = true; } } return(result); }
public InputManager(IRCClient cl) { this.client = cl; inputThread = new Thread(new ThreadStart(this.getInput)); inputThread.Start(); }