1
0
Çatalla 0

Refactoring.

Bot: Split into multiple files.
Bot: Add roles system to replace BotCommandFlags.
BotClient: Split into separate directory.
master
Marrub 2016-10-28 02:48:58 -04:00
ebeveyn 8464c6ee6c
işleme a39a42ef40
16 değiştirilmiş dosya ile 340 ekleme ve 266 silme

Dosyayı Görüntüle

@ -6,7 +6,7 @@
//
//-----------------------------------------------------------------------------
//
// Main bot class.
// Data for the Bot class.
//
//-----------------------------------------------------------------------------
@ -14,7 +14,6 @@ using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using CommandFuncDict =
System.Collections.Generic.Dictionary<
@ -44,27 +43,31 @@ namespace ProjectGolan.Vrobot3
//
public partial class Bot
{
public List<IBotModule> modules = new List<IBotModule>();
public CommandFuncDict cmdfuncs = new CommandFuncDict();
private readonly Dictionary<ulong, String> lastLine;
private readonly IBotClient client;
public List<IBotModule> modules { get; private set; }
public CommandFuncDict cmdfuncs { get; private set; }
public readonly BotInfo info;
private Dictionary<ulong, String> lastLine = new Dictionary<ulong, String>();
private IBotClient client;
public bool isInAudioChannel => false;
public ServerInfo serverInfo => client.info;
public bool isInAudioChannel => client.isInAudioChannel();
public BotClientInfo clientInfo => client.info;
//
// Bot constructor
//
public Bot(BotInfo info)
{
this.info = info;
this.info = info;
this.lastLine = new Dictionary<ulong, String>();
this.modules = new List<IBotModule>();
this.cmdfuncs = new CommandFuncDict();
switch(info.serverType)
{
case ServerType.IRC: client = new BotClientIRC(this); break;
case ServerType.Discord: client = new BotClientDiscord(this); break;
case "IRC": this.client = new BotClientIRC(this); break;
case "Discord": this.client = new BotClientDiscord(this); break;
default: throw new BotConfigurationException("Invalid server type.");
}
var modClasses =
@ -82,10 +85,33 @@ namespace ProjectGolan.Vrobot3
}
//
// connect
// client
//
public void connect() => client.connect();
public void action(Channel channel, String msg) =>
client.sendAction(channel, msg);
public void action(ulong id, String msg) =>
client.sendAction(client.getChannel(id), msg);
public void message(Channel channel, String msg) =>
client.sendMessage(channel, msg);
public void message(ulong id, String msg) =>
client.sendMessage(client.getChannel(id), msg);
public void messageRaw(Channel channel, String msg) =>
client.sendMessageRaw(channel, msg);
public void messageRaw(ulong id, String msg) =>
client.sendMessageRaw(client.getChannel(id), msg);
public void reply(User usr, Channel channel, String msg) =>
message(channel, usr.name + ": " + msg);
public void reply(User usr, ulong id, String msg) =>
message(id, usr.name + ": " + msg);
public void partAudioChannel() => client.partAudioChannel();
public Task playAudioFile(String file) => client.playAudioFile(file);
//
// disconnect
//
@ -96,30 +122,6 @@ namespace ProjectGolan.Vrobot3
client.disconnect();
}
//
// reply
//
public void reply(User usr, Channel channel, String msg) =>
message(channel, usr.name + ": " + msg);
public void reply(User usr, ulong id, String msg) =>
message(id, usr.name + ": " + msg);
//
// message
//
public void message(Channel channel, String msg) =>
client.sendMessage(channel, msg);
public void message(ulong id, String msg) =>
client.sendMessage(client.getChannel(id), msg);
//
// action
//
public void action(Channel channel, String msg) =>
client.sendAction(channel, msg);
public void action(ulong id, String msg) =>
client.sendAction(client.getChannel(id), msg);
//
// joinAudioChannel
//
@ -135,16 +137,6 @@ namespace ProjectGolan.Vrobot3
return false;
}
//
// partAudioChannel
//
public void partAudioChannel() => client.partAudioChannel();
//
// playAudioFile
//
public Task playAudioFile(String file) => client.playAudioFile(file);
//
// checkModPermissions
//
@ -176,58 +168,6 @@ namespace ProjectGolan.Vrobot3
return false;
}
//
// runCommand
//
private void runCommand(User usr, Channel channel, BotCommand cmd,
String rest)
{
try
{
cmd(usr, channel, rest ?? String.Empty);
}
catch(CommandArgumentException exc)
{
if(exc.Message != null)
reply(usr, channel, exc.Message);
else
Console.WriteLine("{0}: Unknown CommandArgumentException",
info.serverName);
}
catch(Exception exc)
{
reply(usr, channel, "fug it borked");
Console.WriteLine("{0}: Unhandled exception in command: {1}",
info.serverName, exc?.Message ?? "unknown error");
File.WriteAllText(Program.Instance.dataDir + "/cmdexcdump.txt",
exc.ToString());
}
}
//
// moduleIsValid
//
private bool moduleIsValid(Type type)
{
if(!typeof(IBotModule).IsAssignableFrom(type) ||
!type.IsClass || type.IsAbstract)
return false;
foreach(var attribute in type.GetCustomAttributes(false))
{
if((attribute is BotModuleIRCAttribute &&
info.serverType != ServerType.IRC) ||
(attribute is BotModuleDiscordAttribute &&
info.serverType != ServerType.Discord) ||
(attribute is BotModuleRequiresAudioAttribute &&
!serverInfo.hasAudio) ||
attribute is BotModuleDisabledAttribute)
return false;
}
return true;
}
}
}

Dosyayı Görüntüle

@ -11,7 +11,6 @@
//-----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
namespace ProjectGolan.Vrobot3
@ -38,23 +37,25 @@ namespace ProjectGolan.Vrobot3
//
public void onMessage(User usr, Channel channel, String msg)
{
var validCmdPreceders = ".%".ToCharArray();
var validCmdPreceders = ".%$".ToCharArray();
String rest = null;
if(msg.Length >= 1 && validCmdPreceders.Contains(msg[0]))
{
Predicate<BotCommandStructure> pred;
if(msg[0] == '%')
pred = fn => fn.flags.HasFlag(BotCommandFlags.AdminOnly);
else
pred = fn => !fn.flags.HasFlag(BotCommandFlags.AdminOnly);
switch(msg[0])
{
case '%': pred = fn => fn.role == BotRole.Admin; break;
case '$': pred = fn => fn.role == BotRole.HalfAdmin; break;
default: pred = fn => fn.role == BotRole.User; break;
}
var dict = from fn in cmdfuncs where pred(fn.Value.Item2) select fn;
// Get the command name.
String[] splt = msg.Substring(1).Split(" ".ToCharArray(), 2);
String cmdname = splt[0].ToLower();
var splt = msg.Substring(1).Split(" ".ToCharArray(), 2);
var cmdname = splt[0].ToLower();
// Handle commands ending with "^".
// These take the last message as input.
@ -71,9 +72,8 @@ namespace ProjectGolan.Vrobot3
var tcmdr = tcmd.First();
// Check permissions.
if(usr.hostname != info.adminId &&
(tcmdr.Item2.flags.HasFlag(BotCommandFlags.AdminOnly) ||
!checkModPermissions(channel, tcmdr.Item1.GetType())))
if(!client.userPermitted(usr, tcmdr.Item2.role) ||
!checkModPermissions(channel, tcmdr.Item1.GetType()))
goto RaiseMessage;
// If we have input, grab that too.

Dosyayı Görüntüle

@ -16,24 +16,12 @@ using System.Collections.Generic;
namespace ProjectGolan.Vrobot3
{
//
// ServerType
// RoleInfo
//
public enum ServerType
public struct RoleInfo
{
IRC,
Discord
}
//
// ServerInfo
//
public struct ServerInfo
{
public bool hasAudio;
public bool hasColors;
public bool hasNewlines;
public int messageSafeMaxLen;
public bool shortMessages;
public String[] admin;
public String[] halfadmin;
}
//
@ -42,12 +30,12 @@ namespace ProjectGolan.Vrobot3
public struct BotInfo
{
public Dictionary<String, String[]> enables;
public ServerType serverType;
public String serverName;
public String serverPass;
public String serverAddr;
public String adminId;
public String[] channels;
public String serverType;
public String serverName;
public String serverPass;
public String serverAddr;
public String[] channels;
public RoleInfo roles;
}
//

Dosyayı Görüntüle

@ -54,15 +54,15 @@ namespace ProjectGolan.Vrobot3
}
//
// BotCommandFlags
// BotRole
//
// Flags for command registration.
// Used for command role-checking.
//
[Flags]
public enum BotCommandFlags
public enum BotRole
{
AdminOnly = 1 << 0,
Hidden = 1 << 1
User,
HalfAdmin,
Admin
}
//
@ -73,8 +73,9 @@ namespace ProjectGolan.Vrobot3
public struct BotCommandStructure
{
public BotCommand cmd;
public BotCommandFlags flags;
public String help;
public String help;
public bool hidden;
public BotRole role;
}
//
@ -93,30 +94,21 @@ namespace ProjectGolan.Vrobot3
public event Modules.EventType.OnMessage onMessage;
public event Modules.EventType.OnSeen onSeen;
public void raiseOnCmdMessage(User usr, Channel channel, String msg)
{
if(onCmdMessage != null)
onCmdMessage(usr, channel, msg);
}
public void raiseOnCmdMessage(User usr, Channel channel, String msg) =>
onCmdMessage?.Invoke(usr, channel, msg);
public void raiseOnMessage(User usr, Channel channel, String msg)
{
if(onMessage != null)
onMessage(usr, channel, msg);
}
public void raiseOnMessage(User usr, Channel channel, String msg) =>
onMessage?.Invoke(usr, channel, msg);
public void raiseOnSeen(User usr, Channel channel)
{
if(onSeen != null)
onSeen(usr, channel);
}
public void raiseOnSeen(User usr, Channel channel) =>
onSeen?.Invoke(usr, channel);
}
public IBotModule(Bot bot) { this.bot = bot; }
protected IBotModule(Bot bot) { this.bot = bot; }
public CommandDict commands = new CommandDict();
public Events events;
protected Bot bot;
public Events events;
protected Bot bot;
}
}

Dosyayı Görüntüle

@ -0,0 +1,79 @@
//-----------------------------------------------------------------------------
//
// Copyright © 2016 Project Golan
//
// See "LICENSE" for more information.
//
//-----------------------------------------------------------------------------
//
// Private functions for Bot.
//
//-----------------------------------------------------------------------------
using System;
using System.IO;
namespace ProjectGolan.Vrobot3
{
//
// Bot
//
public partial class Bot
{
//
// runCommand
//
private void runCommand(User usr, Channel channel, BotCommand cmd,
String rest)
{
try
{
cmd(usr, channel, rest ?? String.Empty);
}
catch(CommandArgumentException exc)
{
reply(usr, channel, exc.Message);
}
catch(Exception exc)
{
reply(usr, channel, "fug it borked");
Console.WriteLine("{0}: Unhandled exception in command: {1}",
info.serverName, exc.Message);
File.WriteAllText(Program.Instance.dataDir + "/cmdexcdump.txt",
exc.ToString());
}
}
//
// moduleIsValid
//
private bool moduleIsValid(Type type)
{
if(!typeof(IBotModule).IsAssignableFrom(type) ||
!type.IsClass || type.IsAbstract)
return false;
foreach(var attribute in type.GetCustomAttributes(false))
{
if(attribute is BotModuleDisabledAttribute)
return false;
if(attribute is BotModuleIRCAttribute &&
!(client is BotClientIRC))
return false;
if(attribute is BotModuleDiscordAttribute &&
!(client is BotClientDiscord))
return false;
if(attribute is BotModuleRequiresAudioAttribute &&
!clientInfo.hasAudio)
return false;
}
return true;
}
}
}
// EOF

Dosyayı Görüntüle

@ -15,31 +15,52 @@ using System.Threading.Tasks;
namespace ProjectGolan.Vrobot3
{
//
// BotClientInfo
//
public class BotClientInfo
{
public bool hasAudio;
public bool hasColors;
public bool hasNewlines;
public int messageSafeMaxLen;
public bool shortMessages;
}
//
// IBotClient
//
public abstract class IBotClient
{
protected Bot bot;
public ServerInfo info;
public BotClientInfo info { get; protected set; }
public IBotClient(Bot bot) { this.bot = bot; }
protected IBotClient(Bot bot)
{
this.info = new BotClientInfo();
this.bot = bot;
}
// Connect
// connect
public abstract void connect();
public abstract void disconnect();
// Send
// send
public abstract void sendAction(Channel channel, String msg);
public abstract void sendMessage(Channel channel, String msg);
public virtual void sendMessageRaw(Channel channel, String msg) =>
sendMessage(channel, msg);
// Channel
// channel
public abstract Channel getChannel(ulong id);
public virtual void joinChannel(Channel channel) {}
public virtual void partChannel(Channel channel) {}
// Audio
public virtual ChannelAudio getAudioChannel(User user) =>
// user
public abstract bool userPermitted(User usr, BotRole role);
// audio
public virtual ChannelAudio getAudioChannel(User usr) =>
new ChannelAudio();
public virtual async Task joinAudioChannel(ChannelAudio channel) =>
await Task.FromResult(0);

Dosyayı Görüntüle

@ -24,27 +24,9 @@ namespace ProjectGolan.Vrobot3
//
public class BotClientDiscord : IBotClient
{
//
// AudioBuffer
//
class AudioBuffer
{
// private static const int MaxSize = 20 * 1024 * 1024;
private readonly String name;
private ulong num = 0;
private ulong next = 1;
private ulong bufSize = 0;
public bool completed { get; private set; } = false;
public AudioBuffer()
{
name = System.IO.Path.GetRandomFileName() + ".";
}
}
private Discord.DiscordClient client = new Discord.DiscordClient();
private Discord.DiscordClient client;
private Discord.Audio.IAudioClient audioClient;
private Discord.Server server;
private Discord.Server server;
//
// BotClientDiscord constructor
@ -52,13 +34,15 @@ namespace ProjectGolan.Vrobot3
public BotClientDiscord(Bot bot) :
base(bot)
{
info.hasAudio = true;
info.hasColors = false;
info.hasNewlines = true;
info.messageSafeMaxLen = 1777;
info.shortMessages = false;
this.client = new Discord.DiscordClient();
client.MessageReceived += (sender, evt) =>
this.info.hasAudio = true;
this.info.hasColors = false;
this.info.hasNewlines = true;
this.info.messageSafeMaxLen = 1777;
this.info.shortMessages = false;
this.client.MessageReceived += (sender, evt) =>
{
if(!evt.Message.IsAuthor && !evt.User.IsBot &&
(bot.info.channels == null ||
@ -78,7 +62,7 @@ namespace ProjectGolan.Vrobot3
}
};
client.UsingAudio(x => x.Mode = AudioMode.Outgoing);
this.client.UsingAudio(x => x.Mode = AudioMode.Outgoing);
}
//
@ -91,6 +75,33 @@ namespace ProjectGolan.Vrobot3
return server.GetUser(ulong.Parse(usr.hostname));
}
//
// checkRole
//
private bool checkRole(User usr, String[] strings)
{
var duser = getUser(usr);
foreach(var str in strings)
{
if(str[0] == '#')
{
var sel =
from role in duser.Roles
let strn = str.Substring(1)
where role.Name == strn
select role;
if(sel.Any())
return true;
}
else if(usr.hostname == str)
return true;
}
return false;
}
//
// connect
//
@ -130,6 +141,13 @@ namespace ProjectGolan.Vrobot3
public override void sendMessage(Channel channel, String msg) =>
client.GetChannel(channel.id)?.SendMessage(Discord.Format.Escape(msg));
//
// sendMessageRaw
//
public override void sendMessageRaw(Channel channel, String msg) =>
sendMessage(channel,
"```" + Discord.Format.Escape(msg ?? String.Empty) + "```");
//
// getChannel
//
@ -142,6 +160,14 @@ namespace ProjectGolan.Vrobot3
return channel;
}
//
// userPermitted
//
public override bool userPermitted(User usr, BotRole role) =>
role == BotRole.User ||
(role == BotRole.HalfAdmin && checkRole(usr, bot.info.roles.halfadmin)) ||
(role == BotRole.Admin && checkRole(usr, bot.info.roles.admin));
//
// getAudioChannel
//
@ -209,12 +235,12 @@ namespace ProjectGolan.Vrobot3
var buf = new byte[3840 * 32];
var ostream = audioClient.OutputStream;
var istream = proc.StandardOutput.BaseStream;
var istream = proc?.StandardOutput.BaseStream;
int count;
try
{
while(!proc.HasExited &&
int count;
while(proc?.HasExited == false &&
(count = await istream.ReadAsync(buf, 0, buf.Length)) != 0)
{
Thread.Sleep(8);
@ -228,7 +254,7 @@ namespace ProjectGolan.Vrobot3
}
finally
{
istream.Dispose();
istream?.Dispose();
ostream.Dispose();
}
}

Dosyayı Görüntüle

@ -25,11 +25,11 @@ namespace ProjectGolan.Vrobot3
public BotClientIRC(Bot bot) :
base(bot)
{
info.hasAudio = false;
info.hasColors = true;
info.hasNewlines = false;
info.messageSafeMaxLen = 601;
info.shortMessages = true;
this.info.hasAudio = false;
this.info.hasColors = true;
this.info.hasNewlines = false;
this.info.messageSafeMaxLen = 601;
this.info.shortMessages = true;
}
public override void connect() {}
@ -39,6 +39,7 @@ namespace ProjectGolan.Vrobot3
public override void partChannel(Channel channel) {}
public override void sendAction(Channel channel, String msg) {}
public override void sendMessage(Channel channel, String msg) {}
public override bool userPermitted(User usr, BotRole role) => true;
}
}

Dosyayı Görüntüle

@ -26,6 +26,19 @@ namespace ProjectGolan.Vrobot3
{
}
}
//
// BotConfigurationException
//
public class BotConfigurationException : Exception
{
public BotConfigurationException() {}
public BotConfigurationException(String message) : base(message) {}
public BotConfigurationException(String message, Exception inner) :
base(message, inner)
{
}
}
}
// EOF

Dosyayı Görüntüle

@ -29,14 +29,14 @@ namespace ProjectGolan.Vrobot3.Modules
{
commands["kill"] = new BotCommandStructure{
cmd = cmdKill,
flags = BotCommandFlags.AdminOnly,
role = BotRole.Admin,
help = "Kills all bot instances.\n" +
"Syntax: %kill"
};
commands["msg"] = new BotCommandStructure{
cmd = cmdMsg,
flags = BotCommandFlags.AdminOnly,
role = BotRole.Admin,
help = "Sends a message.\n" +
"Syntax: %msg channel, msg\n" +
"Example: %msg #general, ur all dumb"
@ -44,7 +44,7 @@ namespace ProjectGolan.Vrobot3.Modules
commands["action"] = new BotCommandStructure{
cmd = cmdAction,
flags = BotCommandFlags.AdminOnly,
role = BotRole.Admin,
help = "Sends an action.\n" +
"Syntax: %action channel, msg\n" +
"Example: %action #general, explodes violently"

Dosyayı Görüntüle

@ -29,7 +29,7 @@ namespace ProjectGolan.Vrobot3.Modules
//
class QueueItem
{
Utils.URI uri;
private Utils.URI uri;
public QueueItem(Utils.URI uri)
{
@ -44,9 +44,9 @@ namespace ProjectGolan.Vrobot3.Modules
//
class Queue
{
TimeSpan curTime;
List<QueueItem> items;
int pos;
private TimeSpan curTime;
private List<QueueItem> items;
private int pos;
public Queue()
{
@ -63,9 +63,9 @@ namespace ProjectGolan.Vrobot3.Modules
}
}
String[] validMethods = { "http", "https", "ftp", "ftps" };
Random rnd = Utils.GetRND();
Queue queue = new Queue();
private readonly String[] validMethods =
{ "http", "https", "ftp", "ftps" };
private Queue queue = new Queue();
//
// Mod_Audio constructor
@ -95,12 +95,6 @@ namespace ProjectGolan.Vrobot3.Modules
"Syntax: .lsqueue"
};
commands["fugoff"] = new BotCommandStructure{
cmd = cmdFugOff,
help = "GET ME COGS OR FUG OFF",
flags = BotCommandFlags.AdminOnly
};
commands["summon"] = new BotCommandStructure{
cmd = cmdSummon,
help = "Makes the bot join your audio channel.\n" +
@ -111,14 +105,14 @@ namespace ProjectGolan.Vrobot3.Modules
cmd = cmdVanquish,
help = "Makes the bot leave their audio channel.\n" +
"Syntax: %vanquish",
flags = BotCommandFlags.AdminOnly
role = BotRole.HalfAdmin
};
}
//
// summon
//
async Task<bool> summon(User usr, Channel channel)
private async Task<bool> summon(User usr, Channel channel)
{
if(bot.isInAudioChannel)
return true;
@ -158,7 +152,7 @@ namespace ProjectGolan.Vrobot3.Modules
}
bot.reply(usr, channel,
$"Added {loadPass} item{loadPass == 1 ? "" : "s"} to the queue.");
$"Added {loadPass} item{loadPass != 1 ? "s" : ""} to the queue.");
}
//
@ -175,17 +169,6 @@ namespace ProjectGolan.Vrobot3.Modules
{
}
//
// cmdFugOff
//
public async void cmdFugOff(User usr, Channel channel, String msg)
{
if(!await summon(usr, channel))
return;
await bot.playAudioFile("\"/home/marrub/musix/MusixDL/Shadowfax - Shadowdance/01 New Electric India.mp3\"").ConfigureAwait(false);
}
//
// cmdSummon
//

Dosyayı Görüntüle

@ -12,6 +12,7 @@
//-----------------------------------------------------------------------------
using System;
using System.Linq;
namespace ProjectGolan.Vrobot3.Modules
{
@ -74,30 +75,60 @@ namespace ProjectGolan.Vrobot3.Modules
public Mod_Fun(Bot bot) :
base(bot)
{
commands["carmack"] = new BotCommandStructure{
commands["carmack"] = new BotCommandStructure {
cmd = new ShitpostingDevice("MM", "", 3, 20, bot).run,
flags = BotCommandFlags.Hidden
hidden = true
};
commands["revenant"] = new BotCommandStructure{
commands["revenant"] = new BotCommandStructure {
cmd = new ShitpostingDevice("AA", "", 3, 20, bot).run,
flags = BotCommandFlags.Hidden
hidden = true
};
commands["wan"] = new BotCommandStructure{
commands["wan"] = new BotCommandStructure {
cmd = new ShitpostingDevice("wan ", "- !", 2, 12, bot).run,
flags = BotCommandFlags.Hidden
hidden = true
};
commands["nyan"] = new BotCommandStructure{
commands["nyan"] = new BotCommandStructure {
cmd = new ShitpostingDevice("nyan ", "!~", 2, 12, bot).run,
flags = BotCommandFlags.Hidden
hidden = true
};
commands[":^)"] = new BotCommandStructure{
commands[":^)"] = new BotCommandStructure {
cmd = (usr, channel, msg) => bot.message(channel, ":^)"),
flags = BotCommandFlags.Hidden
hidden = true
};
// commands["box"] = new BotCommandStructure {
// cmd = cmdBox,
// hidden = true,
// role = BotRole.HalfAdmin
// };
events.onMessage += onMessage;
}
//
// cmdBox
//
// public void cmdBox(User usr, Channel channel, String msg)
// {
// var outp = msg + '\n';
//
// for(var i = 1; i < msg.Length; i++)
// {
// var ln = msg[i].ToString();
// ln = ln.PadRight(msg.Length);
// ln += msg[msg.Length - i];
// outp += ln + '\n';
// }
//
// outp += msg.Reverse();
//
// bot.messageRaw(channel, outp);
// }
//
// onMessage
//

Dosyayı Görüntüle

@ -63,24 +63,24 @@ namespace ProjectGolan.Vrobot3.Modules
throw new CommandArgumentException("invalid quote ID");
var quote = Utils.GetResponseString(APIURI + id.ToString(),
bot.serverInfo.messageSafeMaxLen);
bot.clientInfo.messageSafeMaxLen);
if(String.IsNullOrEmpty(quote))
throw new CommandArgumentException("QDB exploded try again later");
if(bot.serverInfo.shortMessages)
if(bot.clientInfo.shortMessages)
quote = Regex.Replace(quote, "\n+", "\n").Trim();
var lines = quote.Split('\n');
if(bot.serverInfo.shortMessages &&
if(bot.clientInfo.shortMessages &&
(lines.Length > 5 || quote.Length > 600))
{
bot.reply(usr, channel, "Quote is too long.");
return;
}
if(bot.serverInfo.hasNewlines)
if(bot.clientInfo.hasNewlines)
bot.message(channel, quote);
else
foreach(var ln_ in lines)

Dosyayı Görüntüle

@ -114,9 +114,8 @@ namespace ProjectGolan.Vrobot3.Modules
var outp = String.Empty;
var en =
from kvp in bot.cmdfuncs
let f = kvp.Value.Item2.flags
let fhidden = f.HasFlag(BotCommandFlags.Hidden)
let fadmin = f.HasFlag(BotCommandFlags.AdminOnly)
let fhidden = kvp.Value.Item2.hidden
let fadmin = kvp.Value.Item2.role != BotRole.User
where
bot.checkModPermissions(channel, this.GetType()) &&
(admin || !fadmin) && !fhidden

Dosyayı Görüntüle

@ -40,13 +40,6 @@ namespace ProjectGolan.Vrobot3
public BotInfo[] servers;
}
private readonly List<Bot> bots = new List<Bot>();
private readonly List<Thread> threads = new List<Thread>();
public String dataDir = "../data";
public ProgramInfo info;
public static Program Instance;
//
// Main
//
@ -95,6 +88,13 @@ namespace ProjectGolan.Vrobot3
bots.Clear();
threads.Clear();
}
private readonly List<Bot> bots = new List<Bot>();
private readonly List<Thread> threads = new List<Thread>();
public String dataDir = "../data";
public ProgramInfo info;
public static Program Instance;
}
}

Dosyayı Görüntüle

@ -70,17 +70,14 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties/AssemblyInfo.cs" />
<Compile Include="Source/Bot.cs" />
<Compile Include="Source/BotClient.cs" />
<Compile Include="Source/BotClientDiscord.cs" />
<Compile Include="Source/BotClientIRC.cs" />
<Compile Include="Source/BotEvents.cs" />
<Compile Include="Source/BotInfo.cs" />
<Compile Include="Source/BotModule.cs" />
<Compile Include="Source/Exceptions.cs" />
<Compile Include="Source/Links.cs" />
<Compile Include="Source/Program.cs" />
<Compile Include="Source/Utils.cs" />
<Compile Include="Source/Bot/Data.cs" />
<Compile Include="Source/Bot/Events.cs" />
<Compile Include="Source/Bot/Info.cs" />
<Compile Include="Source/Bot/Module.cs" />
<Compile Include="Source/Bot/PrivateFuncs.cs" />
<Compile Include="Source/Client/Client.cs" />
<Compile Include="Source/Client/Discord.cs" />
<Compile Include="Source/Client/IRC.cs" />
<Compile Include="Source/Modules/Mod_Admin.cs" />
<Compile Include="Source/Modules/Mod_Audio.cs" />
<Compile Include="Source/Modules/Mod_Fun.cs" />
@ -88,6 +85,10 @@
<Compile Include="Source/Modules/Mod_Idgames.cs" />
<Compile Include="Source/Modules/Mod_Quote.cs" />
<Compile Include="Source/Modules/Mod_Shittalk.cs" />
<Compile Include="Source/Exceptions.cs" />
<Compile Include="Source/Links.cs" />
<Compile Include="Source/Program.cs" />
<Compile Include="Source/Utils.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)/Microsoft.CSharp.targets" />
<ItemGroup>