-
Notifications
You must be signed in to change notification settings - Fork 2
/
IrcConnection.cs
62 lines (60 loc) · 2.27 KB
/
IrcConnection.cs
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
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Squishy.Irc;
using WCell.Util;
using WCellUtilityBot.ChannelManagment;
namespace WCellUtilityBot
{
class IrcConnection : IrcClient
{
public static readonly IrcConnection Irc = new IrcConnection
{
UserName = Properties.Settings.Default.IrcUser,
Nicks = new[] { Properties.Settings.Default.IrcNick },
ServerPassword = Properties.Settings.Default.IrcPassword,
};
public bool ConsoleMode;
protected override void OnConnecting()
{
base.OnConnecting();
if (ConsoleMode)
protHandler.PacketReceived += Console.WriteLine;
}
protected override void Perform()
{
base.Perform();
var qUser = Properties.Settings.Default.QUser;
var qPass = Properties.Settings.Default.QPass;
if(!string.IsNullOrWhiteSpace(qUser) && !string.IsNullOrWhiteSpace(qPass))
{
if(ConsoleMode)
Console.WriteLine("Authing with Q.." + qUser);
CommandHandler.Msg("[email protected]","auth " + qUser + " " + qPass);
}
}
protected override void OnBeforeSend(string text)
{
base.OnBeforeSend(text);
if (ConsoleMode)
Console.WriteLine(text);
}
protected override void OnCommandFail(WCell.Util.Commands.CmdTrigger<Squishy.Irc.Commands.IrcCmdArgs> trigger, Exception ex)
{
CommandHandler.Msg(Properties.Settings.Default.ErrorChannel, "Exception Occured: " + ex.InnerException.Message);
foreach (string text in ex.GetAllMessages())
CommandHandler.Msg(Properties.Settings.Default.ErrorChannel, text);
}
public override bool MayTriggerCommand(WCell.Util.Commands.CmdTrigger<Squishy.Irc.Commands.IrcCmdArgs> trigger, Squishy.Irc.Commands.IrcCommand cmd)
{
return trigger.Args.User.UserLevel >= cmd.RequiredAccountLevel;
}
protected override void OnJoin(IrcUser user, IrcChannel chan)
{
base.OnJoin(user, chan);
new AutoVoiceUser(user, chan);
}
}
}