Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Fruffi.Bot.Events
- {
- abstract class AbstractEvent
- {
- #region private vars
- private Connect connect;
- #endregion
- #region props
- protected Connect Connect
- {
- get { return this.connect; }
- set { this.connect = value; }
- }
- #endregion
- #region constructor
- public AbstractEvent(Connect connect) { this.Connect = connect; }
- #endregion
- }
- abstract class AbstractEventsOwnerUser : AbstractEvent
- {
- #region constructor
- public AbstractEventsOwnerUser(Connect connect) : base(connect) { }
- #endregion
- abstract public void Join(string channel, string user);
- abstract public void Part(string channel, string user);
- abstract public void Mode(string channel, string user, string mode);
- abstract public void Kick(string channel, string by, string user, string message);
- abstract public void Nick(string user, string newnick);
- abstract public void Quit(string user, string message);
- abstract public void Query(string user, string message);
- abstract public void Inv(string channel, string user);
- }
- abstract class AbstractEventsChannel : AbstractEvent
- {
- #region constructor
- public AbstractEventsChannel(Connect connect) : base(connect) { }
- #endregion
- abstract public void Topic(string channel, string topic);
- abstract public void TopicOwner(string channel, string user, string date);
- abstract public void Nameslist(string channel, string names);
- abstract public void Priv(string channel, string user, string message, bool is_owner);
- }
- }
- ----------------------------
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Fruffi.Bot.Commands;
- namespace Fruffi.Bot.Events
- {
- class EventsUser : AbstractEventsOwnerUser
- {
- #region constructor
- public EventsUser(Connect connect) : base(connect) { }
- #endregion
- public override void Join(string channel, string user)
- {
- this.Connect.write(this.Connect.Cmd.action(channel, "begrüßt " + user));
- }
- public override void Part(string channel, string user) { Console.WriteLine(channel + ": " + user + " left"); }
- public override void Mode(string channel, string user, string mode) { Console.WriteLine(channel + ": " + user + " mode " + mode); }
- public override void Kick(string channel, string by, string user, string message) { Console.WriteLine(channel + ": " + user + " kicked by " + by + ": " + message); }
- public override void Nick(string user, string newnick) { }
- public override void Quit(string user, string message) { }
- public override void Query(string user, string message)
- {
- if (this.Connect.Helpers.find(user, "spamscanner"))
- return;
- if (this.Connect.Helpers.find(user, "global"))
- return;
- if (this.Connect.Helpers.find(user, "chanserv"))
- return;
- if (this.Connect.Helpers.find(user, "nickserv"))
- return;
- UserCommand u = new UserCommand(this.Connect, message);
- if (u.query(user))
- this.Connect.write(u.Response);
- }
- public override void Inv(string channel, string user) { Console.WriteLine("INVITE: " + channel + " from " + user); }
- }
- }
- ----------------------------
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Fruffi.Bot.Events;
- using Fruffi.Bot.Chan;
- namespace Fruffi.Bot.Irc
- {
- class Parser
- {
- #region private vars
- private EventsUser uevents;
- private EventsChannel cevents;
- private EventsOwner oevents;
- private EventsFruffi fevents;
- private Connect connect;
- #endregion
- #region props
- public Connect Connect
- {
- get { return this.connect; }
- set { this.connect = value; }
- }
- public EventsUser UserEvents
- {
- get { return this.uevents; }
- set { this.uevents = value; }
- }
- public EventsChannel ChannelEvents
- {
- get { return this.cevents; }
- set { this.cevents = value; }
- }
- public EventsOwner OwnerEvents
- {
- get { return this.oevents; }
- set { this.oevents = value; }
- }
- public EventsFruffi FruffiEvents
- {
- get { return this.fevents; }
- set { this.fevents = value; }
- }
- #endregion
- #region constructor
- public Parser(Connect connect)
- {
- this.Connect = connect;
- this.UserEvents = new EventsUser(this.Connect);
- this.ChannelEvents = new EventsChannel(this.Connect);
- this.OwnerEvents = new EventsOwner(this.Connect);
- this.FruffiEvents = new EventsFruffi(this.Connect);
- }
- #endregion
- #region channel
- public void Topic(string[] c)
- {
- this.ChannelEvents.Topic(this.Connect.Helpers.RemoveColon(c[3]), this.Connect.Helpers.ArrayToString(c, 4));
- }
- public void TopicOwner(string[] c)
- {
- this.ChannelEvents.TopicOwner(c[3], this.Connect.Helpers.Nick(c[4]), c[5]);
- }
- public void Nameslist(string[] c)
- {
- string b = this.Connect.Helpers.RemoveColon(c[4]);
- string d = this.Connect.Helpers.ArrayToString(c, 5);
- this.ChannelEvents.Nameslist(b, d);
- Channel t = this.Connect.Channels.get(b);
- string[] a = d.Split(' ');
- for (int i = 0; i < a.Length; i++)
- t.add(a[i]);
- }
- #endregion
- #region user
- public void Join(string[] c)
- {
- string n = this.Connect.Helpers.Nick(c[0]);
- string t = this.Connect.Helpers.RemoveColon(c[2]);
- Channel b = this.Connect.Channels.get(t);
- b.add(n);
- if (n == this.Connect.Owner.Nick)
- {
- this.OwnerEvents.Join(t, n);
- return;
- }
- else if (n == this.Connect.Config.Nick)
- {
- if(this.Connect.Channels == null)
- this.Connect.Channels = new ChannelList();
- this.Connect.Channels.get(t);
- this.FruffiEvents.Join(t, n);
- return;
- }
- if (!this.Connect.Storage.Ignore.Exists(n))
- this.UserEvents.Join(t, n);
- }
- public void Part(string[] c)
- {
- string n = this.Connect.Helpers.Nick(c[0]);
- string t = this.Connect.Helpers.RemoveColon(c[2]);
- Channel b = this.Connect.Channels.get(t);
- b.del(n);
- if (n == this.Connect.Owner.Nick)
- {
- this.OwnerEvents.Part(t, n);
- return;
- }
- if (n == this.Connect.Config.Nick)
- {
- this.Connect.Channels.del(t);
- }
- if (!this.Connect.Storage.Ignore.Exists(n))
- this.UserEvents.Part(t, n);
- }
- public void Mode(string[] c)
- {
- string n = this.Connect.Helpers.Nick(c[0]);
- string t = this.Connect.Helpers.RemoveColon(c[2]);
- string m = this.Connect.Helpers.RemoveColon(this.Connect.Helpers.ArrayToString(c, 3));
- if (n == this.Connect.Owner.Nick)
- {
- this.OwnerEvents.Mode(t, n, m);
- return;
- }
- else if (n == this.Connect.Config.Nick)
- {
- this.FruffiEvents.Mode(t, n, m);
- return;
- }
- if (!this.Connect.Storage.Ignore.Exists(n))
- this.UserEvents.Mode(t, n, m);
- }
- public void Kick(string[] c)
- {
- string n = this.Connect.Helpers.Nick(c[0]);
- string t = this.Connect.Helpers.RemoveColon(c[2]);
- string m = this.Connect.Helpers.RemoveColon(this.Connect.Helpers.ArrayToString(c, 4));
- Channel b = this.Connect.Channels.get(t);
- b.del(n);
- if (n == this.Connect.Owner.Nick)
- {
- this.OwnerEvents.Kick(t, n, c[3], m);
- return;
- }
- if (!this.Connect.Storage.Ignore.Exists(n))
- this.UserEvents.Kick(t, n, c[3], m);
- }
- public void Nick(string[] c)
- {
- string n = this.Connect.Helpers.Nick(c[0]);
- string k = this.Connect.Helpers.RemoveColon(c[2]);
- this.Connect.Channels.nick(n, k);
- if (n == this.Connect.Owner.Nick)
- {
- Console.WriteLine("OWNER changed nick to " + k);
- this.Connect.Owner.Nick = k;
- this.OwnerEvents.Nick(n, k);
- return;
- }
- else if (n == this.Connect.Config.Nick)
- {
- Console.WriteLine("YOU changed nick to " + k);
- this.Connect.Config.Nick = k;
- this.FruffiEvents.Nick(n, k);
- return;
- }
- if (!this.Connect.Storage.Ignore.Exists(n))
- this.UserEvents.Nick(n, k);
- }
- public void Quit(string[] c)
- {
- string n = this.Connect.Helpers.Nick(c[0]);
- string m = this.Connect.Helpers.RemoveColon(this.Connect.Helpers.ArrayToString(c, 2));
- this.Connect.Channels.kill(n);
- if (n == this.Connect.Owner.Nick)
- {
- this.OwnerEvents.Quit(n, m);
- return;
- }
- if (!this.Connect.Storage.Ignore.Exists(n))
- this.UserEvents.Quit(n, m);
- }
- public void Priv(string[] c)
- {
- string n = this.Connect.Helpers.Nick(c[0]);
- string t = this.Connect.Helpers.RemoveColon(c[2]);
- string m = this.Connect.Helpers.RemoveColon(this.Connect.Helpers.ArrayToString(c, 3));
- if (t.Substring(0, 1) != "#")
- {
- if (n == this.Connect.Owner.Nick)
- this.OwnerEvents.Query(n, m);
- else
- this.UserEvents.Query(n, m);
- return;
- }
- if (!this.Connect.Storage.Ignore.Exists(n))
- this.ChannelEvents.Priv(t, n, m, (n == this.Connect.Owner.Nick));
- //this.Idler();
- }
- public void Inv(string[] c)
- {
- string n = this.Connect.Helpers.Nick(c[0]);
- string t = this.Connect.Helpers.RemoveColon(c[3]);
- if (n == this.Connect.Owner.Nick)
- {
- this.OwnerEvents.Inv(t, n);
- return;
- }
- if (!this.Connect.Storage.Ignore.Exists(n))
- this.UserEvents.Inv(t, n);
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement