small fixes, not adding youtube gaming because api sux, closes #25

This commit is contained in:
Master Kwoth 2016-03-13 11:59:57 +01:00
parent 400df43875
commit c32b32e056
2 changed files with 20 additions and 11 deletions

View File

@ -10,8 +10,8 @@ using NadekoBot.Modules;
namespace NadekoBot.Commands {
class CrossServerTextChannel : DiscordCommand {
public CrossServerTextChannel(DiscordModule module) : base(module) {
try {
NadekoBot.Client.MessageReceived += async (s, e) => {
try {
if (e.Message.User.Id == NadekoBot.Creds.BotId) return;
foreach (var subscriber in Subscribers) {
var set = subscriber.Value;
@ -21,9 +21,11 @@ namespace NadekoBot.Commands {
await chan.SendMessage(GetText(e.Server, e.Channel, e.User, e.Message));
}
}
} catch { }
};
NadekoBot.Client.MessageUpdated += async (s, e) => {
if (e.After.User.Id == NadekoBot.Creds.BotId) return;
try {
if (e.After?.User?.Id == null || e.After.User.Id == NadekoBot.Creds.BotId) return;
foreach (var subscriber in Subscribers) {
var set = subscriber.Value;
if (!set.Contains(e.Channel))
@ -36,9 +38,9 @@ namespace NadekoBot.Commands {
await msg.Edit(GetText(e.Server, e.Channel, e.User, e.After));
}
}
};
} catch { }
};
}
private string GetText(Server server, Channel channel, User user, Message message) =>

View File

@ -8,6 +8,7 @@ using System.Timers;
using Discord.Commands;
using NadekoBot.Classes;
using NadekoBot.Classes.JSONModels;
using NadekoBot.Classes.Permissions;
using NadekoBot.Modules;
using Newtonsoft.Json.Linq;
@ -85,12 +86,14 @@ namespace NadekoBot.Commands {
.Description("Notifies this channel when a certain user starts streaming." +
"\n**Usage**: ~hitbox SomeStreamer")
.Parameter("username", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.ManageServer())
.Do(TrackStream(StreamNotificationConfig.StreamType.Hitbox));
cgb.CreateCommand(Module.Prefix + "twitch")
.Alias(Module.Prefix + "tw")
.Description("Notifies this channel when a certain user starts streaming." +
"\n**Usage**: ~twitch SomeStreamer")
.AddCheck(SimpleCheckers.ManageServer())
.Parameter("username", ParameterType.Unparsed)
.Do(TrackStream(StreamNotificationConfig.StreamType.Twitch));
@ -98,6 +101,7 @@ namespace NadekoBot.Commands {
.Alias(Module.Prefix + "rms")
.Description("Removes notifications of a certain streamer on this channel." +
"\n**Usage**: ~srm SomeGuy")
.AddCheck(SimpleCheckers.ManageServer())
.Parameter("username", ParameterType.Unparsed)
.Do(async e => {
var username = e.GetArg("username")?.ToLower().Trim();
@ -155,7 +159,8 @@ namespace NadekoBot.Commands {
Username = username,
Type = type,
};
if (NadekoBot.Config.ObservingStreams.Contains(stream)) {
var exists = NadekoBot.Config.ObservingStreams.Contains(stream);
if (exists) {
await e.Channel.SendMessage(":anger: I am already notifying that stream on this channel.");
}
Tuple<bool, string> data;
@ -174,7 +179,9 @@ namespace NadekoBot.Commands {
else if (type == StreamNotificationConfig.StreamType.YoutubeGaming)
msg += $"\n`Here is the Link:` not implemented yet - {stream.Username}";
stream.LastStatus = data.Item1;
await e.Channel.SendMessage($":ok: I will notify this channel when status changes.\n{msg}");
if (!exists)
msg = $":ok: I will notify this channel when status changes.\n{msg}";
await e.Channel.SendMessage(msg);
NadekoBot.Config.ObservingStreams.Add(stream);
ConfigHandler.SaveConfig();
};