-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (49 loc) · 1.91 KB
/
Program.cs
File metadata and controls
57 lines (49 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Meebey.SmartIrc4net;
using SteamKit2;
using System.Threading;
using System.Configuration;
namespace IRCbot
{
class Program
{
public static IrcClient irc = new IrcClient();
static void Main(string[] args)
{
irc.Encoding = System.Text.Encoding.UTF8;
irc.SendDelay = 500;
irc.AutoRetry = true;
irc.ActiveChannelSyncing = true;
irc.OnChannelMessage += new IrcEventHandler(IRCHandler.OnChannelMessage);
irc.AutoRejoin = true;
irc.AutoRelogin = true;
irc.AutoReconnect = true;
irc.AutoRetry = true;
irc.AutoRejoinOnKick = true;
string[] serverlist = {ConfigurationManager.AppSettings["irc-server"]};
string channel = ConfigurationManager.AppSettings["announce_channel"];
int port = int.Parse(ConfigurationManager.AppSettings["irc-port"]);
int debug = int.Parse(ConfigurationManager.AppSettings["debug"]);
try {
irc.Connect(serverlist, port);
} catch (ConnectionException e) {
System.Console.WriteLine("couldn't connect! Reason: "+e.Message);
}
try {
irc.Login("SteamDB", "SteamDB bot", 0, "SteamDB");
irc.RfcJoin(channel);
if (debug == 1) { irc.SendMessage(SendType.Message, channel, "Hello friends! Your favorite bot is back!"); }
new Thread(new ThreadStart(Steam.Loop)).Start();
irc.Listen();
irc.Disconnect();
} catch (ConnectionException) {
} catch (Exception e) {
System.Console.WriteLine("Error occurred! Message: "+e.Message);
System.Console.WriteLine("Exception: "+e.StackTrace);
}
}
}
}