Tag Archive
arctic arctic monkeys bot clever cure def f# f-sharp framework fsharp functions guitar guitar tabs infection install intelligent irc irc bot ircbot Linux lyrics malware monkeys network notes oop pcquad php Python quotes sheets simple social social network socialnetwork song source code string tabs too much to ask tutorial ubuntu variables without tools zend
F# Irc bot
Heyho in the past i created a little irc bot,
its my first F# application and i pretty like it:
'its a simple IRC Bot written in F#.
#light
open System.Net.Sockets
open System.IO
open System
open System.Text.RegularExpressions
//Opens any needed namespaces
let tcp = new TcpClient();
tcp.Connect("irc.afterworkchat.net",6667)
//Connects and creates streams for the connection.
let reader = new StreamReader(tcp.GetStream())
let writer = new StreamWriter(tcp.GetStream())
writer.WriteLine("USER FSharpBot FSharpBot FSharpBot FSharpBot")
writer.AutoFlush < - true
writer.WriteLine("NICK FSharpBot")
//Log in and create a loop that will keep the bot open.
while(reader.EndOfStream = false) do
let line = reader.ReadLine()
Console.WriteLine(line)
//msg is what someone said without the raw irc code.
let msg = line.Substring(line.Substring(1).IndexOf(":") + 2)
//Console.WriteLine(msg))
if (line.Contains("PING")) then
writer.WriteLine("PONG :irc.afterworkchat.net")
thats it