moved extensions to a separate module, added lmgtfy

This commit is contained in:
Master Kwoth 2016-01-21 03:17:01 +01:00
parent eac933e4ec
commit 40227a175a
14 changed files with 33 additions and 21 deletions

View File

@ -6,8 +6,9 @@ using System.Security.Cryptography;
using Discord.Commands;
using Discord;
using Discord.Legacy;
using NadekoBot.Modules;
namespace NadekoBot
namespace NadekoBot.Extensions
{
public static class Extensions
{
@ -113,6 +114,16 @@ namespace NadekoBot
}
}
/// <summary>
/// Shortens a string URL
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="source"></param>
/// <param name="action"></param>
public static string ShortenUrl(this string str) {
return Searches.ShortenUrl(str);
}
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action) {
foreach (T element in source) {
action(element);

View File

@ -8,7 +8,7 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Timers;
using Discord.Legacy;
using NadekoBot.Extensions;
namespace NadekoBot
{

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Discord.Commands;
using Discord.Legacy;
using NadekoBot.Extensions;
namespace NadekoBot
{

View File

@ -5,7 +5,7 @@ using System.Threading.Tasks;
using Discord.Commands;
using System.Drawing;
using System.Drawing.Imaging;
using Discord.Legacy;
using NadekoBot.Extensions;
namespace NadekoBot
{

View File

@ -5,6 +5,7 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.Collections.Generic;
using Discord.Legacy;
using NadekoBot.Extensions;
namespace NadekoBot
{

View File

@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
using Discord.Commands;
using Discord.Legacy;
using NadekoBot.Extensions;
using System.IO;
namespace NadekoBot

View File

@ -6,6 +6,7 @@ using System.Diagnostics;
using System.Linq;
using System.Timers;
using Discord.Commands.Permissions.Visibility;
using NadekoBot.Extensions;
namespace NadekoBot.Modules
{

View File

@ -11,7 +11,7 @@ using System.Drawing;
using System.IO;
using System.Text;
using System.Drawing.Imaging;
using Discord.Legacy;
using NadekoBot.Extensions;
namespace NadekoBot.Modules
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Discord.Modules;
using Discord.Legacy;
using NadekoBot.Extensions;
namespace NadekoBot.Modules
{

View File

@ -3,18 +3,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Discord.Modules;
using Discord.Commands;
using System.IO;
using Discord;
using Discord.Audio;
using System.Collections.Concurrent;
using YoutubeExtractor;
using System.Threading;
using System.Diagnostics;
using Discord.Legacy;
using NadekoBot.Extensions;
using System.Net;
using System.Globalization;
@ -196,7 +194,7 @@ namespace NadekoBot.Modules {
.OrderByDescending(v => v.AudioBitrate).FirstOrDefault();
if (video == null)
throw new Exception("Could not load any video elements"); // First one
throw new Exception("Could not load any video elements");
StreamUrl = video.DownloadUrl;
Title = video.Title;

View File

@ -1,19 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Discord.Modules;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Text.RegularExpressions;
using System.Reflection;
using System.Xml;
using Newtonsoft.Json;
using System.Net.Http;
using Discord.Legacy;
using Discord.Commands;
using NadekoBot.Extensions;
namespace NadekoBot.Modules
{
@ -109,6 +103,13 @@ namespace NadekoBot.Modules
await e.Send("This feature is being reconstructed.");
});
cgb.CreateCommand("lmgtfy")
.Description("Google something for an idiot.")
.Parameter("ffs", ParameterType.Unparsed)
.Do(async e => {
if (e.GetArg("ffs") == null || e.GetArg("ffs").Length < 1) return;
await e.Send($"http://lmgtfy.com/?q={ Uri.EscapeUriString(e.GetArg("ffs").ToString()) }".ShortenUrl());
});
});
}

View File

@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Discord.Modules;
using Manatee.Trello.ManateeJson;
using Manatee.Trello;
using System.Timers;
using NadekoBot.Extensions;
namespace NadekoBot.Modules {
class Trello : DiscordModule {

View File

@ -7,7 +7,7 @@ using Discord.Commands;
using NadekoBot.Modules;
using Discord.Modules;
using Discord.Audio;
using System.Threading.Tasks;
using NadekoBot.Extensions;
using System.Timers;
using System.Linq;

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Timers;
using Discord.Legacy;
using NadekoBot.Extensions;
namespace NadekoBot
{