Advertisement
Guest User

Untitled

a guest
Sep 4th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 23.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading;
  5. using ChatSharp;
  6. using System.Runtime.InteropServices;
  7. using Microsoft.Win32;
  8.  
  9.  
  10.  
  11.  
  12.  
  13. namespace Tim_s_IRC_bot
  14. {
  15.     class Program
  16.     {
  17.  
  18.  
  19.         static void Main(string[] args)
  20.         {
  21.  
  22.  
  23.             {
  24.                
  25.                 Console.Title = "Tim's IRC Bot";
  26.                 string combine = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
  27.  
  28.                 if (System.IO.File.Exists (System.IO.Path.Combine (combine, "TimsBot/settings.ini"))) {
  29.                 }
  30.                 else
  31.                 {
  32.                     Console.Title = "Tim's IRC Bot Setup";
  33.                     Console.WriteLine("Welcome to Tims IRC bot, press enter to continue");
  34.                     Console.ReadLine();
  35.                     Console.Clear();
  36.                     Console.WriteLine("Which server do you want the bot to join?");
  37.                     string Server = Console.ReadLine();
  38.                     Console.Clear();
  39.                     Console.WriteLine("Which channel do you want the bot to join?");
  40.                     string Channel = Console.ReadLine();
  41.                     Console.Clear();
  42.                     Console.WriteLine("Which nickname do you want to have?");
  43.  
  44.                     string Nickname = Console.ReadLine();
  45.                     Console.Clear();
  46.                     Console.WriteLine("Which username do you have?(NEEDED!)");
  47.                     string username = Console.ReadLine();
  48.                     Console.Clear();
  49.                     Console.WriteLine("Which password do you have for the account?(NEEDED!)");
  50.                     string password = Console.ReadLine();
  51.                     Console.WriteLine("What is your username on the irc server? Then you have access to all the admin commands.");
  52.                     string Owner = Console.ReadLine();
  53.                     Console.Clear();
  54.                     System.IO.Directory.CreateDirectory((System.IO.Path.Combine(combine,"TimsBot/")));
  55.                     System.IO.Directory.CreateDirectory((System.IO.Path.Combine(combine,"TimsBot/data")));
  56.                     System.IO.Directory.CreateDirectory((System.IO.Path.Combine(combine,"TimsBot/data/logs/")));
  57.                     System.IO.Directory.CreateDirectory((System.IO.Path.Combine(combine,"TimsBot/data/systems/warnsystem/warning/")));
  58.                     System.IO.Directory.CreateDirectory((System.IO.Path.Combine(combine,"TimsBot/data/systems/warnsystem/offtopic/")));
  59.                     System.IO.Directory.CreateDirectory((System.IO.Path.Combine(combine,"TimsBot/data/access/")));
  60.                     System.IO.Directory.CreateDirectory((System.IO.Path.Combine(combine,"TimsBot/data/access/commands/")));
  61.                     System.IO.Directory.CreateDirectory((System.IO.Path.Combine(combine,"TimsBot/data/access/commands/owner/")));
  62.                     System.IO.Directory.CreateDirectory((System.IO.Path.Combine(combine,"TimsBot/data/access/commands/users/")));
  63.                     System.IO.File.WriteAllText((System.IO.Path.Combine(combine,"TimsBot/settings.ini")),"Server="+ Server + Environment.NewLine + "Channel=" + Channel + Environment.NewLine + "Botname=" + Nickname + Environment.NewLine + "username=" + username + Environment.NewLine + "password=" + password);
  64.                     System.IO.File.Copy(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName, (System.IO.Path.Combine(combine,"TimsBot/TimsBot.exe")));
  65.                     System.IO.File.WriteAllText((System.IO.Path.Combine(combine,"TimsBot/data/logs/log.txt")), "This is the log File" + Environment.NewLine);
  66.                     System.IO.File.WriteAllText((System.IO.Path.Combine(combine,"TimsBot/data/access/commands/owner/" + Owner)), "Owner" );
  67.                     Console.Clear();
  68.                     Console.WriteLine("You can open the ControlPanel by right clicking on the new system tray icon, when you run the program.");
  69.                     Console.ReadLine();
  70.  
  71.                     Console.WriteLine("Install successfull, you can open the program by going to the desktop and click on the shortcut or navigate to TimsBot/ and run TimsBot.exe.");
  72.                     Console.ReadLine();
  73.                     Environment.Exit(0);
  74.                 }
  75.                     try
  76.                 {
  77.  
  78.  
  79.  
  80.                 string readvalue = System.IO.File.ReadAllText((System.IO.Path.Combine(combine,"TimsBot/settings.ini")));
  81.  
  82.                 string modify1 = readvalue.Replace("Server=","").Replace("Channel=", "").Replace("Botname=", "").Replace("username=", "").Replace("password=", "");
  83.  
  84.                 string[] splitvalue = modify1.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
  85.  
  86.  
  87.                 Console.ForegroundColor = ConsoleColor.DarkGreen;
  88.                 Console.Clear();
  89.  
  90.                 Console.Title = "Tim's IRC Bot is connecting";
  91.                 Console.WriteLine("Connecting to the server.");
  92.                 var client = new IrcClient(splitvalue[0], new IrcUser(splitvalue[2], splitvalue[3], splitvalue[4]));
  93.                 client.ConnectionComplete += (s, e) =>
  94.                 {
  95.                        
  96.  
  97.                     Console.ForegroundColor = ConsoleColor.DarkGreen;
  98.                     Console.WriteLine("Connected to the server.");
  99.                     client.JoinChannel(splitvalue[1]);
  100.                     Console.Title = "Tim's IRC Bot is connected";
  101.                     Console.WriteLine("Joining channel.");
  102.                     Console.ResetColor();
  103.  
  104.                         Console.Clear();
  105.                         Console.ForegroundColor = ConsoleColor.Green;
  106.                         Console.WriteLine("[][][] [] [][] [][] []  [][][]   [] [][]    [][][]   [][]   [][][] [][][]");
  107.                         Console.WriteLine("  []      [] []  []  [] []          [] []  [][]      [] []  []  []   []");
  108.                         Console.WriteLine("  []   [] [] []  []     [][][]   [] [][]   []        [][]]  []  []   []");
  109.                         Console.WriteLine("  []   [] [] []  []         []   [] [] []  [][]      [] []  []  []   []");
  110.                         Console.WriteLine("  []   [] [] []  []     [][][]   [] []  []  [][][]   [][]   [][][]   []");
  111.                         Console.ForegroundColor = ConsoleColor.Blue;
  112.                         Console.WriteLine("The current date is: " + DateTime.Now.ToString("dd.MM.yyy"));
  113.                         Console.ResetColor();
  114.  
  115.                 };
  116.                 Console.ResetColor();
  117.                     client.PrivateMessageRecieved += (s, f) =>
  118.                     {
  119.                         if (f.PrivateMessage.Message == "!commands")
  120.                         {
  121.                             if (System.IO.File.Exists(System.IO.Path.Combine(combine,"TimsBot/data/access/commands/owner/" + f.PrivateMessage.Source)))
  122.                             {
  123.                                 client.SendMessage("Owner Commands + syntax: !add_mod (nick), !say (channel/nick) (message) ,!add_mod (nick), !del_mod (nick)", f.PrivateMessage.Source);
  124.                                 Console.ForegroundColor = ConsoleColor.DarkYellow;
  125.                                 Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  126.                                 Console.ResetColor();
  127.                                 Console.ForegroundColor = ConsoleColor.Red;
  128.                                 Console.Write("!commands in pm requested by ");
  129.                                 Console.ResetColor();
  130.                                 Console.ForegroundColor = ConsoleColor.Blue;
  131.                                 Console.Write("[OWNER]" + f.PrivateMessage.Source + Environment.NewLine);
  132.                             }
  133.                             else if (System.IO.File.Exists(System.IO.Path.Combine(combine,"TimsBot/data/access/commands/users/" + f.PrivateMessage.Source)))
  134.                             {
  135.                                 client.SendMessage("Mod commands are the !commands commands.", f.PrivateMessage.Source);
  136.                                 Console.ForegroundColor = ConsoleColor.DarkYellow;
  137.                                 Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  138.                                 Console.ResetColor();
  139.                                 Console.ForegroundColor = ConsoleColor.Red;
  140.                                 Console.Write("!commands requested by ");
  141.                                 Console.ResetColor();
  142.                                 Console.ForegroundColor = ConsoleColor.Blue;
  143.                                 Console.Write("[MOD]" + f.PrivateMessage.Source + Environment.NewLine);
  144.                             }
  145.                                
  146.  
  147.  
  148.                         }
  149.                         if (f.PrivateMessage.Message.StartsWith("!add_mod "))
  150.                         {
  151.                             if (System.IO.File.Exists(System.IO.Path.Combine(combine,"TimsBot/data/access/commands/owner/" + f.PrivateMessage.Source)))
  152.                             {
  153.                                 System.IO.File.Create((System.IO.Path.Combine(combine,"TimsBot/data/access/commands/users/" + f.PrivateMessage.Message.Substring(9))));
  154.                                 client.SendMessage("You have been made a moderator by " + f.PrivateMessage.Source, f.PrivateMessage.Message.Substring(9));
  155.                                 Console.ForegroundColor = ConsoleColor.DarkYellow;
  156.                                 Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  157.                                 Console.ResetColor();
  158.                                 Console.ForegroundColor = ConsoleColor.Red;
  159.                                 Console.Write(f.PrivateMessage.Message.Substring(9) + " has been made a moderator by ");
  160.                                 Console.ResetColor();
  161.                                 Console.ForegroundColor = ConsoleColor.Blue;
  162.                                 Console.Write("[OWNER]" + f.PrivateMessage.Source + Environment.NewLine);
  163.                             }
  164.                         }
  165.                         if (f.PrivateMessage.Message.StartsWith("!del_mod "))
  166.                         {
  167.                             if (System.IO.File.Exists(System.IO.Path.Combine(combine,"TimsBot/data/access/commands/owner/" + f.PrivateMessage.Source)))
  168.                             {
  169.                                 System.IO.File.Delete((System.IO.Path.Combine(combine,"TimsBot/data/access/commands/users/" + f.PrivateMessage.Message.Substring(9))));
  170.                                 client.SendMessage("You have removed as a moderator by " + f.PrivateMessage.Source, f.PrivateMessage.Message.Substring(9));
  171.                                 Console.ForegroundColor = ConsoleColor.DarkYellow;
  172.                                 Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  173.                                 Console.ResetColor();
  174.                                 Console.ForegroundColor = ConsoleColor.Red;
  175.                                 Console.Write(f.PrivateMessage.Message.Substring(9) + " has been removed as a moderator by ");
  176.                                 Console.ResetColor();
  177.                                 Console.ForegroundColor = ConsoleColor.Blue;
  178.                                 Console.Write("[OWNER]" + f.PrivateMessage.Source + Environment.NewLine);
  179.                             }
  180.                         }
  181.                     };
  182.  
  183.                 client.ChannelMessageRecieved += (s, e) =>
  184.                 {
  185.  
  186.                     var channel = client.Channels[e.PrivateMessage.Source];
  187.  
  188.                     /*if (e.PrivateMessage.Message == "!list")
  189.                         channel.SendMessage(string.Join(", ", channel.Users.Select(u => u.Nick)));*/
  190.                     if (e.PrivateMessage.Message.StartsWith("!ban "))
  191.  
  192.                     {
  193.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  194.                         {
  195.                             var target = e.PrivateMessage.Message.Substring(5);
  196.                             client.WhoIs(target, whois => channel.ChangeMode("+b *!*@" + whois.User.Hostname));
  197.                             channel.Kick(e.PrivateMessage.Message.Substring(5));
  198.                             client.SendMessage("You got banned from " + splitvalue[1], e.PrivateMessage.Message.Substring(5));
  199.                             Console.ForegroundColor = ConsoleColor.DarkYellow;
  200.                             Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  201.                             Console.ResetColor();
  202.                             Console.ForegroundColor = ConsoleColor.Red;
  203.                             Console.Write(e.PrivateMessage.Message.Substring(5) + " is banned in " + splitvalue[1] + " by ");
  204.                             Console.ResetColor();
  205.                             Console.ForegroundColor = ConsoleColor.Blue;
  206.                             Console.Write(e.PrivateMessage.User.Nick + Environment.NewLine);
  207.                             channel.Kick(e.PrivateMessage.Message.Substring(5));
  208.                         }
  209.  
  210.  
  211.  
  212.                     }
  213.                     else if (e.PrivateMessage.Message.StartsWith("!unban "))
  214.                     {
  215.  
  216.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  217.                         {
  218.  
  219.                             var target = e.PrivateMessage.Message.Substring(7);
  220.                             client.WhoIs(target, whois => channel.ChangeMode("-b *!*@" + whois.User.Hostname));
  221.                             Console.WriteLine(e.PrivateMessage.Message.Substring(7) + " " + "is unbanned");
  222.                             client.SendMessage("You got unbanned from " + splitvalue[1], e.PrivateMessage.Message.Substring(7));
  223.                             Console.ForegroundColor = ConsoleColor.DarkYellow;
  224.                             Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  225.                             Console.ResetColor();
  226.                             Console.ForegroundColor = ConsoleColor.Red;
  227.                             Console.Write(e.PrivateMessage.Message.Substring(7) + " is unbanned in " + splitvalue[1] + " by ");
  228.                             Console.ResetColor();
  229.                             Console.ForegroundColor = ConsoleColor.Blue;
  230.                             Console.Write(e.PrivateMessage.User.Nick + Environment.NewLine);
  231.  
  232.                         }
  233.  
  234.                     }
  235.                     else if (e.PrivateMessage.Message == "!leave")
  236.                     {
  237.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  238.                         {
  239.                             channel.Part();
  240.                             Console.ForegroundColor = ConsoleColor.DarkYellow;
  241.                             Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  242.                             Console.ResetColor();
  243.                             Console.ForegroundColor = ConsoleColor.Red;
  244.                             Console.Write("!leave requested by ");
  245.                             Console.ResetColor();
  246.                             Console.ForegroundColor = ConsoleColor.Blue;
  247.                             Console.Write(e.PrivateMessage.User.Nick + Environment.NewLine);
  248.                         }
  249.                     }
  250.                     else if (e.PrivateMessage.Message == "!cycle")
  251.                     {
  252.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  253.                         {
  254.                                
  255.                                 channel.Part();
  256.                            
  257.                                 client.JoinChannel(splitvalue[1]);
  258.                             Console.ForegroundColor = ConsoleColor.DarkYellow;
  259.                             Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  260.                             Console.ResetColor();
  261.                             Console.ForegroundColor = ConsoleColor.Red;
  262.                             Console.Write("!cycle requested by ");
  263.                             Console.ResetColor();
  264.                             Console.ForegroundColor = ConsoleColor.Blue;
  265.                             Console.Write(e.PrivateMessage.User.Nick + Environment.NewLine);
  266.  
  267.                         }
  268.                     }
  269.                     else if (e.PrivateMessage.Message.StartsWith("!kick "))
  270.                     {
  271.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  272.                         {
  273.  
  274.  
  275.                             channel.Kick(e.PrivateMessage.Message.Substring(6));
  276.                             client.SendMessage("You got kicked from " + splitvalue[1] ,e.PrivateMessage.Message.Substring(6));
  277.                             Console.ForegroundColor = ConsoleColor.DarkYellow;
  278.                             Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  279.                             Console.ResetColor();
  280.                             Console.ForegroundColor = ConsoleColor.Red;
  281.                             Console.Write(e.PrivateMessage.Message.Substring(6) + " is kicked from " +  splitvalue[1] +  " by " );
  282.                             Console.ResetColor();
  283.                             Console.ForegroundColor = ConsoleColor.Blue;
  284.                             Console.Write(e.PrivateMessage.User.Nick + Environment.NewLine);
  285.                         }
  286.  
  287.  
  288.                     }
  289.                     else if (e.PrivateMessage.Message == "!commands")
  290.                     {
  291.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  292.                         {
  293.                            
  294.                             channel.SendMessage(e.PrivateMessage.User.Nick +", Commands: !ban, !unban, !kick, !join, !warn, !warn_offtopic, !op, !deop" );
  295.                             Console.ForegroundColor = ConsoleColor.DarkYellow;
  296.                             Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  297.                             Console.ResetColor();
  298.                             Console.ForegroundColor = ConsoleColor.Red;
  299.                             Console.Write("!commands requested by " );
  300.                             Console.ResetColor();
  301.                             Console.ForegroundColor = ConsoleColor.Blue;
  302.                             Console.Write(e.PrivateMessage.User.Nick + Environment.NewLine);
  303.                         }
  304.  
  305.  
  306.  
  307.  
  308.                     }
  309.                     else if (e.PrivateMessage.Message.StartsWith("!say "))
  310.                     {
  311.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine,"TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  312.                         {
  313.                             string[] splitvalue2 = e.PrivateMessage.Message.Split(' ');
  314.  
  315.                             client.SendMessage(splitvalue2[1], splitvalue[1] );
  316.                             Console.ForegroundColor = ConsoleColor.DarkYellow;
  317.                             Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  318.                             Console.ResetColor();
  319.                             Console.ForegroundColor = ConsoleColor.Red;
  320.                             Console.Write("!say requested by " );
  321.                             Console.ResetColor();
  322.                             Console.ForegroundColor = ConsoleColor.Blue;
  323.                             Console.Write(e.PrivateMessage.User.Nick + Environment.NewLine);
  324.                         }
  325.  
  326.  
  327.                     }
  328.  
  329.                     else if (e.PrivateMessage.Message.StartsWith("!join "))
  330.                     {
  331.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  332.                         {
  333.                             client.JoinChannel(e.PrivateMessage.Message.Substring(5));
  334.                             Console.ForegroundColor = ConsoleColor.DarkYellow;
  335.                             Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  336.                             Console.ResetColor();
  337.                             Console.ForegroundColor = ConsoleColor.Red;
  338.                             Console.Write("Bot joined" + e.PrivateMessage.Message.Substring(5) + " by " );
  339.                             Console.ResetColor();
  340.                             Console.ForegroundColor = ConsoleColor.Blue;
  341.                             Console.Write(e.PrivateMessage.User.Nick + Environment.NewLine);
  342.                         }
  343.  
  344.  
  345.                     }
  346.                     else if (e.PrivateMessage.Message.StartsWith("!warn_offtopic "))
  347.                     {
  348.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  349.                         {
  350.                             if (System.IO.Directory.Exists((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/offtopic/")) + e.PrivateMessage.Message.Substring(15)))
  351.                             {
  352.                                 if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/offtopic/")) + e.PrivateMessage.Message.Substring(15) + "/" + "4"))
  353.                                 {
  354.                                     var target = e.PrivateMessage.Message.Substring(15);
  355.                                     client.WhoIs(target, whois => channel.ChangeMode("+b *!*@" + whois.User.Hostname));
  356.  
  357.                                     Console.WriteLine(e.PrivateMessage.Message.Substring(15) + " " + "is banned");
  358.                                     client.SendMessage("You got banned from " + splitvalue[1] + " because you keep going off topic", e.PrivateMessage.Message.Substring(15));
  359.                                     channel.Kick(e.PrivateMessage.Message.Substring(15));
  360.                                 }
  361.                                 else
  362.                                 {
  363.                                     if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/offtopic/")) + e.PrivateMessage.Message.Substring(15) + "/" + "3"))
  364.                                     {
  365.                                         System.IO.File.WriteAllText((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/offtopic/")) + e.PrivateMessage.Message.Substring(15) + "/" + "4", "Warning number 4");
  366.                                         channel.Kick(e.PrivateMessage.Message.Substring(15));
  367.                                         Console.WriteLine(e.PrivateMessage.Message.Substring(15) + " " + "is kicked");
  368.                                         client.SendMessage("You got kicked from " + splitvalue[1] + " because you keep going off topic", e.PrivateMessage.Message.Substring(6));
  369.  
  370.                                     }
  371.                                     else
  372.                                     {
  373.                                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/offtopic/")) + e.PrivateMessage.Message.Substring(15) + "/" + "2"))
  374.                                         {
  375.                                             System.IO.File.WriteAllText((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/offtopic/")) + e.PrivateMessage.Message.Substring(15) + "/" + "3", "Warning number 3");
  376.                                             client.SendMessage("This is your last warning, please stop being off topic, you will be kicked if you go on in " + splitvalue[1], e.PrivateMessage.Message.Substring(15));
  377.                                         }
  378.                                         else
  379.                                         {
  380.                                             System.IO.File.WriteAllText((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/offtopic/")) + e.PrivateMessage.Message.Substring(15) + "/" + "2", "Warning number 2");
  381.                                             client.SendMessage("Please remember, this is a chat for chat with related topics in " + splitvalue[1], e.PrivateMessage.Message.Substring(15));
  382.                                         }
  383.                                     }
  384.                                 }
  385.                             }
  386.                             else
  387.                             {
  388.                                 System.IO.Directory.CreateDirectory((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/offtopic/")) + e.PrivateMessage.Message.Substring(15));
  389.                                 client.SendMessage("Please try and stay on topic in " + splitvalue[1], e.PrivateMessage.Message.Substring(15));
  390.                             }
  391.  
  392.                         }
  393.  
  394.                         else
  395.  
  396.                         {
  397.  
  398.                         }
  399.  
  400.  
  401.  
  402.                     }
  403.                     else if (e.PrivateMessage.Message.StartsWith("!warn "))
  404.                     {
  405.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  406.                         {
  407.                             if (System.IO.Directory.Exists((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/warning/")) + e.PrivateMessage.Message.Substring(6)))
  408.                             {
  409.                                 if (System.IO.File.Exists((System.IO.Path.Combine(combine,"TimsBot/data/systems/warnsystem/warning/")) + e.PrivateMessage.Message.Substring(6) + "/" + "4"))
  410.                                 {
  411.                                     var target = e.PrivateMessage.Message.Substring(6);
  412.                                     client.WhoIs(target, whois => channel.ChangeMode("+b *!*@" + whois.User.Hostname));
  413.  
  414.                                     Console.WriteLine(e.PrivateMessage.Message.Substring(6) + " " + "is banned");
  415.                                     client.SendMessage("You got banned from " + splitvalue[1] + " because you have 5 warnings", e.PrivateMessage.Message.Substring(6));
  416.                                     channel.Kick(e.PrivateMessage.Message.Substring(6));
  417.                                 }
  418.                                 else
  419.                                 {
  420.                                     if (System.IO.File.Exists((System.IO.Path.Combine(combine,"TimsBot/data/systems/warnsystem/warning/")) + e.PrivateMessage.Message.Substring(6) + "/" + "3"))
  421.                                     {
  422.                                         System.IO.File.WriteAllText((System.IO.Path.Combine(combine,"TimsBot/data/systems/warnsystem/warning/")) + e.PrivateMessage.Message.Substring(6) + "/" + "4", "Warning number 4");
  423.                                         channel.Kick(e.PrivateMessage.Message.Substring(6));
  424.                                         Console.WriteLine(e.PrivateMessage.Message.Substring(6) + " " + "is kicked");
  425.                                         client.SendMessage("You got kicked from " + splitvalue[1] + " because you have 4 warnings, if you get one more warning you will get banned.", e.PrivateMessage.Message.Substring(6));
  426.  
  427.                                     }
  428.                                     else
  429.                                     {
  430.                                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/warning/")) + e.PrivateMessage.Message.Substring(6) + "/" + "2"))
  431.                                         {
  432.                                             System.IO.File.WriteAllText((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/warning/")) + e.PrivateMessage.Message.Substring(6) + "/" + "3", "Warning number 3");
  433.                                             client.SendMessage("Please remember, this is your 3th warning in in " + splitvalue[1], e.PrivateMessage.Message.Substring(6));
  434.                                         }
  435.                                         else
  436.                                         {
  437.                                             System.IO.File.WriteAllText((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/warning/")) + e.PrivateMessage.Message.Substring(6) + "/" + "2", "Warning number 2");
  438.                                             client.SendMessage("Please remember, this is your second warning in " + splitvalue[1], e.PrivateMessage.Message.Substring(6));
  439.                                         }
  440.                                     }
  441.                                 }
  442.                             }
  443.                             else
  444.                             {
  445.                                 System.IO.Directory.CreateDirectory((System.IO.Path.Combine(combine, "TimsBot/data/systems/warnsystem/warning/")) + e.PrivateMessage.Message.Substring(6));
  446.                                 client.SendMessage("Please remember, this is your first warning in " + splitvalue[1], e.PrivateMessage.Message.Substring(6));
  447.                             }
  448.  
  449.                         }
  450.                     }
  451.  
  452.  
  453.  
  454.  
  455.                     else if (e.PrivateMessage.Message == "!op")
  456.                     {
  457.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  458.                         {
  459.                             var target = e.PrivateMessage.User.Nick;
  460.                             client.WhoIs(target, whois => channel.ChangeMode("+o  "+ e.PrivateMessage.User.Nick));
  461.                                 Console.ForegroundColor = ConsoleColor.DarkYellow;
  462.                                 Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  463.                                 Console.ResetColor();
  464.                                 Console.ForegroundColor = ConsoleColor.Red;
  465.                                 Console.Write("!op requested by " );
  466.                                 Console.ResetColor();
  467.                                 Console.ForegroundColor = ConsoleColor.Blue;
  468.                                 Console.Write(e.PrivateMessage.User.Nick + Environment.NewLine);
  469.                         }
  470.                     }
  471.                     else if (e.PrivateMessage.Message == "!deop")
  472.                     {
  473.                         if (System.IO.File.Exists((System.IO.Path.Combine(combine, "TimsBot/data/access/commands/users/")) + e.PrivateMessage.User.Nick))
  474.                         {
  475.                             var target = e.PrivateMessage.User.Nick;
  476.                             client.WhoIs(target, whois => channel.ChangeMode("-o " + e.PrivateMessage.User.Nick));
  477.                                 Console.ForegroundColor = ConsoleColor.DarkYellow;
  478.                                 Console.Write("[" + DateTime.Now.ToString("HH:mm:ss") + "]");
  479.                                 Console.ResetColor();
  480.                                 Console.ForegroundColor = ConsoleColor.Red;
  481.                                 Console.Write("!deop requested by " );
  482.                                 Console.ResetColor();
  483.                                 Console.ForegroundColor = ConsoleColor.Blue;
  484.                                 Console.Write(e.PrivateMessage.User.Nick + Environment.NewLine);
  485.                         }
  486.                     }
  487.  
  488.  
  489.  
  490.  
  491.                 };
  492.  
  493.                 client.ConnectAsync();
  494.  
  495.  
  496.                 while (true) ;
  497.  
  498.             }
  499.                 catch (Exception e)
  500.                 {
  501.                     Console.ForegroundColor = ConsoleColor.Red;
  502.                     Console.WriteLine("[" + DateTime.Now.ToString("HH:mm:ss") + "] Error: '{0}'", e);
  503.                     Console.ReadLine ();
  504.        
  505.                 }
  506.         }
  507.         }
  508.  
  509.  
  510.     }
  511.  
  512.  
  513. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement