Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Suche samples wie man einen IRC client in C# schreibt

Empfohlene Antworten

Hi!

Bin auf der suche nach einiegen beispielen wie man einen IRC

client in C# schreibt. Weiss einer wo ich solche beispiele finden

kann?

DANKE!!!

IrcBot.cs:

using System;

using System.Net;

using System.Net.Sockets;

using System.IO;

using System.Threading;

/*

* This program establishes a connection to irc server, joins a channel and greets every nickname that

* joins the channel.

*

* Coded by Pasi Havia 17.11.2001 http://koti.mbnet.fi/~curupted

*/

class IrcBot

{

// Irc server to connect

public static string SERVER = "irc.df.lth.se";

// Irc server's port (6667 is default port)

private static int PORT = 6667;

// User information defined in RFC 2812 (Internet Relay Chat: Client Protocol) is sent to irc server

private static string USER = "USER CSharpBot 8 * :I'm a C# irc bot";

// Bot's nickname

private static string NICK = "BotNick";

// Channel to join

private static string CHANNEL = "#my_channel";

// StreamWriter is declared here so that PingSender can access it

public static StreamWriter writer;

static void Main (string[] args)

{

NetworkStream stream;

TcpClient irc;

string inputLine;

StreamReader reader;

string nickname;

try

{

irc = new TcpClient (SERVER, PORT);

stream = irc.GetStream ();

reader = new StreamReader (stream);

writer = new StreamWriter (stream);

// Start PingSender thread

PingSender ping = new PingSender ();

ping.Start ();

writer.WriteLine (USER);

writer.Flush ();

writer.WriteLine ("NICK " + NICK);

writer.Flush ();

writer.WriteLine ("JOIN " + CHANNEL);

writer.Flush ();

while (true)

{

while ( (inputLine = reader.ReadLine () ) != null )

{

if (inputLine.EndsWith ("JOIN :" + CHANNEL) )

{

// Parse nickname of person who joined the channel

nickname = inputLine.Substring(1, inputLine.IndexOf ("!") - 1);

// Welcome the nickname to channel by sending a notice

writer.WriteLine ("NOTICE " + nickname + " :Hi " + nickname +

" and welcome to " + CHANNEL + " channel!");

writer.Flush ();

// Sleep to prevent excess flood

Thread.Sleep (2000);

}

}

// Close all streams

writer.Close ();

reader.Close ();

irc.Close ();

}

}

catch (Exception e)

{

// Show the exception, sleep for a while and try to establish a new connection to irc server

Console.WriteLine (e.ToString () );

Thread.Sleep (5000);

string[] argv = { };

Main (argv);

}

}

}

PingSender.cs:

using System;

using System.Threading;

/*

* Class that sends PING to irc server every 15 seconds

*/

class PingSender

{

static string PING = "PING :";

private Thread pingSender;

// Empty constructor makes instance of Thread

public PingSender ()

{

pingSender = new Thread (new ThreadStart (this.Run) );

}

// Starts the thread

public void Start ()

{

pingSender.Start ();

}

// Send PING to irc server every 15 seconds

public void Run ()

{

while (true)

{

IrcBot.writer.WriteLine (PING + IrcBot.SERVER);

IrcBot.writer.Flush ();

Thread.Sleep (15000);

}

}

}

cool danke!

ist zwar nicht 100% das was ich gesucht habe aber damit kann ich schon ne menge anfangen.

gicio

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.