Blizzardo1 icon

20 minute C# Bot dIRC

Blizzardo1 | PRO | 10/27/13 02:36:48 AM UTC | 0 ⭐ | 760 👁️ | Never ⏰ | []
C# |

2.58 KB

|

None

|

0 👍

/

0 👎

/*
    dIRC - Dummy IRC Bot
    Copyright (c) 2007 - 2013, Blizzardo1 and Blizzeta S&W
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
 
namespace dIRC
{
    class Program
    {
        public static StreamWriter writer = null;
        public static StreamReader reader = null;
        public static TcpClient client = null;
 
        public static void Connect(string host, int port)
        {
            client = new TcpClient();
            client.Connect(host, port);
 
            writer = new StreamWriter(client.GetStream());
            reader = new StreamReader(client.GetStream());
            
            Nick("PowerSharp");
            Sleep(25);
            User("Blizzy", "Blizzy");
            Sleep(100);
            Join("#Blizzeta");
            Sleep(50);
            SendMessage("#Blizzeta", "Hi! Blizzy here from a Powershell script with C#! Allow me to idle!");
            
            Listen();
        }
 
        public static void Listen()
        {
            (new Thread(new ThreadStart(delegate
            {
                while (client.Connected)
                {
                    string m = string.Empty;
                    while ((m = reader.ReadLine()) != null)
                    {
                        Console.WriteLine(m);
                        Sleep(10);
                    }
                }
            }))).Start();
        }
 
        public static void Join(string Channel, string Pass = "")
        {
            if (string.IsNullOrEmpty(Pass))
                writer.WriteLine("JOIN {0}", Channel);
            else
                writer.WriteLine("JOIN {0} {1}", Channel, Pass);
            writer.Flush();
        }
 
        public static void SendMessage(string channel, string message)
        {
            writer.WriteLine("PRIVMSG {0} :{1}", channel, message);
            writer.Flush();
        }
 
        public static void User(string username, string realname, int usermode = 8)
        {
            writer.WriteLine("USER {0} {1} * :{2}", usermode, usermode, realname);
            writer.Flush();
        }
 
        public static void Sleep(int mil)
        {
            Thread.Sleep(mil);
        }
 
        public static void Nick(string NewNick)
        {
            writer.WriteLine("NICK {0}", NewNick);
            writer.Flush();
        }
 
        public static void Main(string[] args)
        {
            Connect("irc.geekshed.net", 6667);
        }
    }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎