Merge remote-tracking branch 'refs/remotes/Kwoth/1.4' into 1.4

This commit is contained in:
samvaio 2017-06-17 16:46:42 +05:30
commit fc13b2aa23
42 changed files with 1784 additions and 144 deletions

View File

@ -181,7 +181,7 @@ Commands and aliases | Description | Usage
`.claimwaifu` `.claim` | Claim a waifu for yourself by spending currency. You must spend at least 10% more than her current value unless she set `.affinity` towards you. | `.claim 50 @Himesama`
`.divorce` | Releases your claim on a specific waifu. You will get some of the money you've spent back unless that waifu has an affinity towards you. 6 hours cooldown. | `.divorce @CheatingSloot`
`.affinity` | Sets your affinity towards someone you want to be claimed by. Setting affinity will reduce their `.claim` on you by 20%. You can leave second argument empty to clear your affinity. 30 minutes cooldown. | `.affinity @MyHusband` or `.affinity`
`.waifus` `.waifulb` | Shows top 9 waifus. | `.waifus`
`.waifus` `.waifulb` | Shows top 9 waifus. You can specify another page to show other waifus. | `.waifus` or `.waifulb 3`
`.waifuinfo` `.waifustats` | Shows waifu stats for a target person. Defaults to you if no user is provided. | `.waifuinfo @MyCrush` or `.waifuinfo`
###### [Back to ToC](#table-of-contents)
@ -239,6 +239,7 @@ Commands and aliases | Description | Usage
`.pause` `.p` | Pauses or Unpauses the song. | `.p`
`.fairplay` `.fp` | Toggles fairplay. While enabled, the bot will prioritize songs from users who didn't have their song recently played instead of the song's position in the queue. | `.fp`
`.queue` `.q` `.yq` | Queue a song using keywords or a link. Bot will join your voice channel. **You must be in a voice channel**. | `.q Dream Of Venice`
`.queuesearch` `.qs` `.yqs` | Search for top 5 youtube song result using keywords, and type the index of the song to play that song. Bot will join your voice channel. **You must be in a voice channel**. | `.qs Dream Of Venice`
`.soundcloudqueue` `.sq` | Queue a soundcloud song using keywords. Bot will join your voice channel. **You must be in a voice channel**. | `.sq Dream Of Venice`
`.listqueue` `.lq` | Lists 15 currently queued songs per page. Default page is 1. | `.lq` or `.lq 2`
`.nowplaying` `.np` | Shows the song that the bot is currently playing. | `.np`
@ -317,6 +318,8 @@ Commands and aliases | Description | Usage
`.listglobalperms` `.lgp` | Lists global permissions set by the bot owner. **Bot owner only** | `.lgp`
`.globalmodule` `.gmod` | Toggles whether a module can be used on any server. **Bot owner only** | `.gmod nsfw`
`.globalcommand` `.gcmd` | Toggles whether a command can be used on any server. **Bot owner only** | `.gcmd .stats`
`.resetperms` | Resets the bot's permissions module on this server to the default value. **Requires Administrator server permission.** | `.resetperms`
`.resetglobalperms` | Resets global permissions set by bot owner. **Bot owner only** | `.resetglobalperms`
###### [Back to ToC](#table-of-contents)
@ -432,7 +435,7 @@ Commands and aliases | Description | Usage
`.qsearch` | Shows a random quote for a keyword that contains any text specified in the search. | `.qsearch keyword text`
`.quoteid` `.qid` | Displays the quote with the specified ID number. Quote ID numbers can be found by typing `.liqu [num]` where `[num]` is a number of a page which contains 15 quotes. | `.qid 123456`
`..` | Adds a new quote with the specified name and message. | `.. sayhi Hi`
`.deletequote_cmd` | deletequote_desc | deletequote_usage
`.quotedel` `.qdel` | Deletes a quote with the specified ID. You have to be either server Administrator or the creator of the quote to delete it. | `.qdel 123456`
`.delallq` `.daq` | Deletes all quotes on a specified keyword. **Requires Administrator server permission.** | `.delallq kek`
`.remind` | Sends a message to you or a channel after certain amount of time. First argument is `me`/`here`/'channelname'. Second argument is time in a descending order (mo>w>d>h>m) example: 1w5d3h10m. Third argument is a (multiword) message. | `.remind me 1d5h Do something` or `.remind #general 1m Start now!`
`.remindtemplate` | Sets message for when the remind is triggered. Available placeholders are `%user%` - user who ran the command, `%message%` - Message specified in the remind, `%target%` - target channel of the remind. **Bot owner only** | `.remindtemplate %user%, do %message%!`

View File

@ -79,7 +79,6 @@ You will need the following for the next step:
- **LoL Api Key** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/#setting-up-your-api-keys)
- **Mashape Key** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/#setting-up-your-api-keys)
- **Osu Api Key** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/#setting-up-your-api-keys)
- **Sound Cloud Client Id** [(optional)](http://nadekobot.readthedocs.io/en/latest/JSON%20Explanations/#setting-up-your-api-keys)
Once you have acquired them, press `5` to **Set up credentials.json**

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
namespace NadekoBot.Migrations
{
public partial class crstartswith : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "CustomReactionsStartWith",
table: "BotConfig",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CustomReactionsStartWith",
table: "BotConfig");
}
}
}

View File

@ -149,6 +149,8 @@ namespace NadekoBot.Migrations
b.Property<string>("CurrencySign");
b.Property<bool>("CustomReactionsStartWith");
b.Property<string>("DMHelpString");
b.Property<DateTime?>("DateAdded");

View File

@ -70,7 +70,7 @@ namespace NadekoBot.Modules.Administration
catch (Exception ex)
{
await ReplyErrorLocalized("setrole_err").ConfigureAwait(false);
Console.WriteLine(ex.ToString());
_log.Info(ex);
}
}

View File

@ -1,6 +1,7 @@
using Discord;
using Discord.Commands;
using NadekoBot.Attributes;
using NadekoBot.DataStructures;
using NadekoBot.Extensions;
using NadekoBot.Modules.Permissions;
using NadekoBot.Services;
@ -16,6 +17,7 @@ namespace NadekoBot.Modules.Administration
public partial class Administration
{
[Group]
[NoPublicBot]
public class LogCommands : NadekoSubmodule
{
private readonly LogCommandService _lc;

View File

@ -216,7 +216,7 @@ namespace NadekoBot.Modules.Administration
catch (Exception ex)
{
await ReplyErrorLocalized("self_assign_perms").ConfigureAwait(false);
Console.WriteLine(ex);
_log.Info(ex);
return;
}
var msg = await ReplyConfirmLocalized("self_assign_success",Format.Bold(role.Name)).ConfigureAwait(false);

View File

@ -249,6 +249,8 @@ namespace NadekoBot.Modules.Gambling
}
private Task Client_MessageReceived(SocketMessage imsg)
{
var _ = Task.Run(() =>
{
var msg = imsg as SocketUserMessage;
if (msg == null)
@ -257,6 +259,8 @@ namespace NadekoBot.Modules.Gambling
return Task.CompletedTask;
Interlocked.Increment(ref _messagesSinceGameStarted);
return Task.CompletedTask;
});
return Task.CompletedTask;
}
private async Task CheckForFullGameAsync(CancellationToken cancelToken)

View File

@ -122,7 +122,7 @@ namespace NadekoBot.Modules.Gambling
});
}
return Task.Delay(0);
return Task.CompletedTask;
}
public async Task FlowerReactionEvent(ICommandContext context, int amount)

View File

@ -43,13 +43,16 @@ namespace NadekoBot.Modules.Gambling
var members = role.Members().Where(u => u.Status != UserStatus.Offline);
var membersArray = members as IUser[] ?? members.ToArray();
if (membersArray.Length == 0)
{
}
var usr = membersArray[new NadekoRandom().Next(0, membersArray.Length)];
await Context.Channel.SendConfirmAsync("🎟 "+ GetText("raffled_user"), $"**{usr.Username}#{usr.Discriminator}**", footer: $"ID: {usr.Id}").ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[Priority(0)]
[RequireContext(ContextType.Guild)]
public async Task Cash([Remainder] IUser user = null)
{
if(user == null)

View File

@ -184,9 +184,8 @@ $@"--
await End().ConfigureAwait(false);
}
private async Task PotentialAcro(SocketMessage arg)
private Task PotentialAcro(SocketMessage arg)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -285,6 +284,7 @@ $@"--
_log.Warn(ex);
}
});
return Task.CompletedTask;
}
public async Task End()

View File

@ -23,9 +23,9 @@ namespace NadekoBot.Modules.Games.Hangman
{
data = JsonConvert.DeserializeObject<Dictionary<string, HangmanObject[]>>(File.ReadAllText(termsPath));
}
catch (Exception ex)
catch (Exception)
{
Console.WriteLine(ex);
//ignored
}
}
@ -117,9 +117,8 @@ namespace NadekoBot.Modules.Games.Hangman
await GameChannel.EmbedAsync(embed.WithOkColor()).ConfigureAwait(false);
}
private async Task PotentialGuess(SocketMessage msg)
private Task PotentialGuess(SocketMessage msg)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -194,6 +193,7 @@ namespace NadekoBot.Modules.Games.Hangman
}
catch (Exception ex) { _log.Warn(ex); }
});
return Task.CompletedTask;
}
public string GetHangman() => $@". ┌─────┐

View File

@ -107,9 +107,8 @@ namespace NadekoBot.Modules.Games.Models
_client.MessageReceived += AnswerReceived;
}
private async Task AnswerReceived(SocketMessage imsg)
private Task AnswerReceived(SocketMessage imsg)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -145,6 +144,7 @@ namespace NadekoBot.Modules.Games.Models
}
catch (Exception ex) { _log.Warn(ex); }
});
return Task.CompletedTask;
}
private bool Judge(int errors, int textLength) => errors <= textLength / 25;

View File

@ -178,9 +178,8 @@ namespace NadekoBot.Modules.Games.Trivia
try { await Channel.SendConfirmAsync(GetText("trivia_game"), GetText("trivia_stopping")).ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
}
private async Task PotentialGuess(SocketMessage imsg)
private Task PotentialGuess(SocketMessage imsg)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -242,6 +241,7 @@ namespace NadekoBot.Modules.Games.Trivia
}
catch (Exception ex) { _log.Warn(ex); }
});
return Task.CompletedTask;
}
public string GetLeaderboard()

View File

@ -431,7 +431,7 @@ namespace NadekoBot.Modules.Music
using (var http = new HttpClient())
{
var scvids = JObject.Parse(await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={pl}&client_id={_creds.SoundCloudClientId}").ConfigureAwait(false))["tracks"].ToObject<SoundCloudVideo[]>();
var scvids = JObject.Parse(await http.GetStringAsync($"https://scapi.nadekobot.me/resolve?url={pl}").ConfigureAwait(false))["tracks"].ToObject<SoundCloudVideo[]>();
await _music.QueueSong(((IGuildUser)Context.User), (ITextChannel)Context.Channel, ((IGuildUser)Context.User).VoiceChannel, scvids[0].TrackLink).ConfigureAwait(false);
MusicPlayer musicPlayer;
@ -446,7 +446,7 @@ namespace NadekoBot.Modules.Music
{
Title = svideo.FullName,
Provider = "SoundCloud",
Uri = svideo.GetStreamLink(_creds),
Uri = await svideo.StreamLink(),
ProviderType = MusicType.Normal,
Query = svideo.TrackLink,
}), ((IGuildUser)Context.User).Username);

View File

@ -110,6 +110,8 @@ namespace NadekoBot.Modules
}
Task MessageReceived(SocketMessage arg)
{
var _ = Task.Run(() =>
{
if (!(arg is SocketUserMessage userMsg) ||
!(userMsg.Channel is ITextChannel chan) ||
@ -122,6 +124,8 @@ namespace NadekoBot.Modules
userInputTask.SetResult(arg.Content);
userMsg.DeleteAfter(1);
return Task.CompletedTask;
});
return Task.CompletedTask;
}
}
}

View File

@ -1,11 +1,13 @@
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Attributes;
using NadekoBot.Extensions;
using NadekoBot.Services;
using NadekoBot.Services.Permissions;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Permissions
@ -181,14 +183,25 @@ namespace NadekoBot.Modules.Permissions
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task LstFilterWords()
public async Task LstFilterWords(int page = 1)
{
page--;
if (page < 0)
return;
var channel = (ITextChannel)Context.Channel;
_service.ServerFilteredWords.TryGetValue(channel.Guild.Id, out ConcurrentHashSet<string> filteredWords);
_service.ServerFilteredWords.TryGetValue(channel.Guild.Id, out var fwHash);
await channel.SendConfirmAsync(GetText("filter_word_list"), string.Join("\n", filteredWords))
.ConfigureAwait(false);
var fws = fwHash.ToArray();
await channel.SendPaginatedConfirmAsync((DiscordShardedClient)Context.Client,
page,
(curPage) =>
new EmbedBuilder()
.WithTitle(GetText("filter_word_list"))
.WithDescription(string.Join("\n", fws.Skip(curPage * 10).Take(10)))
, fws.Length / 10).ConfigureAwait(false);
}
}
}

View File

@ -6,7 +6,7 @@ using NadekoBot.Services.Database.Models;
using NadekoBot.Services.Permissions;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Permissions.Commands
namespace NadekoBot.Modules.Permissions
{
public partial class Permissions
{

View File

@ -173,7 +173,7 @@ namespace NadekoBot.Modules.Searches
// .FirstOrDefault(jt => jt["role"].ToString() == role)?["general"];
// if (general == null)
// {
// Console.WriteLine("General is null.");
// //Console.WriteLine("General is null.");
// return;
// }
// //get build data for this role
@ -309,7 +309,7 @@ namespace NadekoBot.Modules.Searches
// }
// catch (Exception ex)
// {
// Console.WriteLine(ex);
// //Console.WriteLine(ex);
// await channel.SendMessageAsync("💢 Failed retreiving data for that champion.").ConfigureAwait(false);
// }
// });

View File

@ -86,7 +86,6 @@ namespace NadekoBot.Modules.Searches
{
http.AddFakeHeaders();
var url = $"https://owapi.nadekobot.me/api/v3/u/{battletag}/stats";
System.Console.WriteLine(url);
var res = await http.GetStringAsync($"https://owapi.nadekobot.me/api/v3/u/{battletag}/stats");
var model = JsonConvert.DeserializeObject<OverwatchApiModel.OverwatchResponse>(res);
switch (region)

View File

@ -637,9 +637,21 @@ namespace NadekoBot.Modules.Searches
color = color?.Trim().Replace("#", "");
if (string.IsNullOrWhiteSpace(color))
return;
ImageSharp.Color clr;
try
{
clr = ImageSharp.Color.FromHex(color);
}
catch
{
await ReplyErrorLocalized("hex_invalid").ConfigureAwait(false);
return;
}
var img = new ImageSharp.Image(50, 50);
img.BackgroundColor(ImageSharp.Color.FromHex(color));
img.BackgroundColor(clr);
await Context.Channel.SendFileAsync(img.ToStream(), $"{color}.png").ConfigureAwait(false);
}

View File

@ -170,7 +170,7 @@ namespace NadekoBot.Modules.Utility
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task DeleteQuote(int id)
public async Task QuoteDelete(int id)
{
var isAdmin = ((IGuildUser) Context.Message.Author).GuildPermissions.Administrator;

View File

@ -27,6 +27,8 @@ using NadekoBot.Services.Utility;
using NadekoBot.Services.Help;
using System.IO;
using NadekoBot.Services.Pokemon;
using NadekoBot.DataStructures;
using NadekoBot.Extensions;
namespace NadekoBot
{
@ -143,7 +145,7 @@ namespace NadekoBot
var clashService = new ClashOfClansService(Client, Db, Localization, Strings);
var musicService = new MusicService(GoogleApi, Strings, Localization, Db, soundcloudApiService, Credentials, AllGuildConfigs);
var crService = new CustomReactionsService(permissionsService, Db, Client, CommandHandler);
var crService = new CustomReactionsService(permissionsService, Db, Client, CommandHandler, BotConfig);
#region Games
var gamesService = new GamesService(Client, BotConfig, AllGuildConfigs, Strings, Images, CommandHandler);
@ -194,6 +196,7 @@ namespace NadekoBot
.Add(repeaterService)
.Add(converterService)
.Add(verboseErrorsService)
.Add(patreonRewardsService)
.Add<SearchesService>(searchesService)
.Add(streamNotificationService)
.Add(animeSearchService)
@ -286,8 +289,8 @@ namespace NadekoBot
// .Where(x => x.Count() > 1)
// .Select(x => x.Key + $"({x.Count()})")));
#if GLOBAL_NADEKO
//unload modules which are not available on the public bot
#if GLOBAL_NADEKO
CommandService
.Modules
.ToArray()
@ -329,8 +332,6 @@ namespace NadekoBot
}
private static void SetupLogger()
{
try
{
var logConfig = new LoggingConfiguration();
var consoleTarget = new ColoredConsoleTarget()
@ -343,10 +344,5 @@ namespace NadekoBot
LogManager.Configuration = logConfig;
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}

View File

@ -94,9 +94,8 @@ namespace NadekoBot.Services.Administration
private string GetText(IGuild guild, string key, params object[] replacements) =>
_strings.GetText(key, guild.Id, "Administration".ToLowerInvariant(), replacements);
private async Task _client_UserUpdated(SocketUser before, SocketUser uAfter)
private Task _client_UserUpdated(SocketUser before, SocketUser uAfter)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -164,11 +163,11 @@ namespace NadekoBot.Services.Administration
// ignored
}
});
return Task.CompletedTask;
}
private async Task _client_UserVoiceStateUpdated_TTS(SocketUser iusr, SocketVoiceState before, SocketVoiceState after)
private Task _client_UserVoiceStateUpdated_TTS(SocketUser iusr, SocketVoiceState before, SocketVoiceState after)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -212,11 +211,11 @@ namespace NadekoBot.Services.Administration
// ignored
}
});
return Task.CompletedTask;
}
private async void MuteCommands_UserMuted(IGuildUser usr, MuteType muteType)
private void MuteCommands_UserMuted(IGuildUser usr, MuteType muteType)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -257,9 +256,8 @@ namespace NadekoBot.Services.Administration
});
}
private async void MuteCommands_UserUnmuted(IGuildUser usr, MuteType muteType)
private void MuteCommands_UserUnmuted(IGuildUser usr, MuteType muteType)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -301,9 +299,8 @@ namespace NadekoBot.Services.Administration
});
}
public async Task TriggeredAntiProtection(PunishmentAction action, ProtectionType protection, params IGuildUser[] users)
public Task TriggeredAntiProtection(PunishmentAction action, ProtectionType protection, params IGuildUser[] users)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -348,11 +345,11 @@ namespace NadekoBot.Services.Administration
// ignored
}
});
return Task.CompletedTask;
}
private async Task _client_GuildUserUpdated(SocketGuildUser before, SocketGuildUser after)
private Task _client_GuildUserUpdated(SocketGuildUser before, SocketGuildUser after)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -397,11 +394,11 @@ namespace NadekoBot.Services.Administration
// ignored
}
});
return Task.CompletedTask;
}
private async Task _client_ChannelUpdated(IChannel cbefore, IChannel cafter)
private Task _client_ChannelUpdated(IChannel cbefore, IChannel cafter)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -448,11 +445,11 @@ namespace NadekoBot.Services.Administration
// ignored
}
});
return Task.CompletedTask;
}
private async Task _client_ChannelDestroyed(IChannel ich)
private Task _client_ChannelDestroyed(IChannel ich)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -487,11 +484,11 @@ namespace NadekoBot.Services.Administration
// ignored
}
});
return Task.CompletedTask;
}
private async Task _client_ChannelCreated(IChannel ich)
private Task _client_ChannelCreated(IChannel ich)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -522,11 +519,11 @@ namespace NadekoBot.Services.Administration
}
catch (Exception ex) { _log.Warn(ex); }
});
return Task.CompletedTask;
}
private async Task _client_UserVoiceStateUpdated(SocketUser iusr, SocketVoiceState before, SocketVoiceState after)
private Task _client_UserVoiceStateUpdated(SocketUser iusr, SocketVoiceState before, SocketVoiceState after)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -576,11 +573,11 @@ namespace NadekoBot.Services.Administration
// ignored
}
});
return Task.CompletedTask;
}
private async Task _client_UserPresenceUpdated(Optional<SocketGuild> optGuild, SocketUser usr, SocketPresence before, SocketPresence after)
private Task _client_UserPresenceUpdated(Optional<SocketGuild> optGuild, SocketUser usr, SocketPresence before, SocketPresence after)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -619,11 +616,11 @@ namespace NadekoBot.Services.Administration
// ignored
}
});
return Task.CompletedTask;
}
private async Task _client_UserLeft(IGuildUser usr)
private Task _client_UserLeft(IGuildUser usr)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -649,6 +646,7 @@ namespace NadekoBot.Services.Administration
// ignored
}
});
return Task.CompletedTask;
}
private Task _client_UserJoined(IGuildUser usr)
@ -678,9 +676,8 @@ namespace NadekoBot.Services.Administration
return Task.CompletedTask;
}
private async Task _client_UserUnbanned(IUser usr, IGuild guild)
private Task _client_UserUnbanned(IUser usr, IGuild guild)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -703,11 +700,11 @@ namespace NadekoBot.Services.Administration
}
catch (Exception ex) { _log.Warn(ex); }
});
return Task.CompletedTask;
}
private async Task _client_UserBanned(IUser usr, IGuild guild)
private Task _client_UserBanned(IUser usr, IGuild guild)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -729,11 +726,11 @@ namespace NadekoBot.Services.Administration
}
catch (Exception ex) { _log.Warn(ex); }
});
return Task.CompletedTask;
}
private async Task _client_MessageDeleted(Cacheable<IMessage, ulong> optMsg, ISocketMessageChannel ch)
private Task _client_MessageDeleted(Cacheable<IMessage, ulong> optMsg, ISocketMessageChannel ch)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -772,11 +769,11 @@ namespace NadekoBot.Services.Administration
// ignored
}
});
return Task.CompletedTask;
}
private async Task _client_MessageUpdated(Cacheable<IMessage, ulong> optmsg, SocketMessage imsg2, ISocketMessageChannel ch)
private Task _client_MessageUpdated(Cacheable<IMessage, ulong> optmsg, SocketMessage imsg2, ISocketMessageChannel ch)
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -821,6 +818,7 @@ namespace NadekoBot.Services.Administration
// ignored
}
});
return Task.CompletedTask;
}
public enum LogType

View File

@ -93,16 +93,11 @@ namespace NadekoBot.Services.Administration
var beforeRoleName = GetRoleName(beforeVch);
var beforeRole = guild.Roles.FirstOrDefault(x => x.Name == beforeRoleName);
if (beforeRole != null)
try
{
_log.Info("Removing role " + beforeRoleName + " from user " + user.Username);
await user.RemoveRoleAsync(beforeRole).ConfigureAwait(false);
await Task.Delay(200).ConfigureAwait(false);
}
catch (Exception ex)
{
_log.Warn(ex);
}
}
var afterVch = after.VoiceChannel;
if (afterVch != null && guild.AFKChannel?.Id != afterVch.Id)
@ -130,7 +125,7 @@ namespace NadekoBot.Services.Administration
.ConfigureAwait(false);
await Task.Delay(50).ConfigureAwait(false);
}
_log.Warn("Adding role " + roleToAdd.Name + " to user " + user.Username);
_log.Info("Adding role " + roleToAdd.Name + " to user " + user.Username);
await user.AddRoleAsync(roleToAdd).ConfigureAwait(false);
}
}

View File

@ -128,7 +128,6 @@ namespace NadekoBot.Services.ClashOfClans
SequenceNumber = i,
});
}
Console.WriteLine(cw.Bases.Capacity);
uow.ClashOfClans.Add(cw);
await uow.CompleteAsync();
return cw;

View File

@ -187,7 +187,6 @@ namespace NadekoBot.Services
private async Task MessageReceivedHandler(SocketMessage msg)
{
await Task.Yield();
try
{
if (msg.Author.IsBot || !_bot.Ready) //no bots, wait until bot connected and initialized

View File

@ -25,15 +25,17 @@ namespace NadekoBot.Services.CustomReactions
private readonly DiscordShardedClient _client;
private readonly PermissionService _perms;
private readonly CommandHandler _cmd;
private readonly BotConfig _bc;
public CustomReactionsService(PermissionService perms, DbService db,
DiscordShardedClient client, CommandHandler cmd)
DiscordShardedClient client, CommandHandler cmd, BotConfig bc)
{
_log = LogManager.GetCurrentClassLogger();
_db = db;
_client = client;
_perms = perms;
_cmd = cmd;
_bc = bc;
var sw = Stopwatch.StartNew();
using (var uow = _db.UnitOfWork)
@ -66,7 +68,7 @@ namespace NadekoBot.Services.CustomReactions
var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%");
var trigger = cr.TriggerWithContext(umsg, _client).Trim().ToLowerInvariant();
return ((hasTarget && content.StartsWith(trigger + " ")) || content == trigger);
return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.CustomReactionsStartWith && content.StartsWith(trigger + " ")) || content == trigger);
}).ToArray();
if (rs.Length != 0)
@ -87,7 +89,7 @@ namespace NadekoBot.Services.CustomReactions
return false;
var hasTarget = cr.Response.ToLowerInvariant().Contains("%target%");
var trigger = cr.TriggerWithContext(umsg, _client).Trim().ToLowerInvariant();
return ((hasTarget && content.StartsWith(trigger + " ")) || content == trigger);
return ((hasTarget && content.StartsWith(trigger + " ")) || (_bc.CustomReactionsStartWith && content.StartsWith(trigger + " ")) || content == trigger);
}).ToArray();
if (grs.Length == 0)
return null;

View File

@ -67,6 +67,7 @@ Nadeko Support Server: https://discord.gg/nadekobot";
public HashSet<BlockedCmdOrMdl> BlockedModules { get; set; }
public int PermissionVersion { get; set; } = 1;
public string DefaultPrefix { get; set; } = ".";
public bool CustomReactionsStartWith { get; set; } = false;
}
public class BlockedCmdOrMdl : DbEntity

View File

@ -30,7 +30,6 @@ namespace NadekoBot.Services.Games
{
var res = await http.GetStringAsync(string.Format(apiEndpoint, message)).ConfigureAwait(false);
var cbr = JsonConvert.DeserializeObject<ChatterBotResponse>(res);
//Console.WriteLine(cbr.Convo_id);
return cbr.BotSay.Replace("<br/>", "\n");
}
}

View File

@ -97,19 +97,18 @@ namespace NadekoBot.Services.Games
private string GetText(ITextChannel ch, string key, params object[] rep)
=> _strings.GetText(key, ch.GuildId, "Games".ToLowerInvariant(), rep);
private async Task PotentialFlowerGeneration(SocketMessage imsg)
private Task PotentialFlowerGeneration(SocketMessage imsg)
{
await Task.Yield();
var msg = imsg as SocketUserMessage;
if (msg == null || msg.Author.IsBot)
return;
return Task.CompletedTask;
var channel = imsg.Channel as ITextChannel;
if (channel == null)
return;
return Task.CompletedTask;
if (!GenerationChannels.Contains(channel.Id))
return;
return Task.CompletedTask;
var _ = Task.Run(async () =>
{
@ -159,7 +158,7 @@ namespace NadekoBot.Services.Games
LogManager.GetCurrentClassLogger().Warn(ex);
}
});
return;
return Task.CompletedTask;
}
}
}

View File

@ -141,7 +141,7 @@ namespace NadekoBot.Services
if (channel != null)
{
CREmbed embedData;
if (CREmbed.TryParse(conf.ChannelGreetMessageText, out embedData))
if (CREmbed.TryParse(conf.DmGreetMessageText, out embedData))
{
embedData.PlainText = embedData.PlainText?.Replace("%user%", user.ToString()).Replace("%id%", user.Id.ToString()).Replace("%server%", user.Guild.Name);
embedData.Description = embedData.Description?.Replace("%user%", user.ToString()).Replace("%id%", user.Id.ToString()).Replace("%server%", user.Guild.Name);

View File

@ -81,7 +81,11 @@ namespace NadekoBot.Services.Impl
ulong.TryParse(data[nameof(ClientId)], out clId);
ClientId = clId;
SoundCloudClientId = data[nameof(SoundCloudClientId)];
var scId = data[nameof(SoundCloudClientId)];
SoundCloudClientId = scId;
//SoundCloudClientId = string.IsNullOrWhiteSpace(scId)
// ?
// : scId;
CarbonKey = data[nameof(CarbonKey)];
var dbSection = data.GetSection("db");
Db = new DBConfig(string.IsNullOrWhiteSpace(dbSection["Type"])

View File

@ -46,21 +46,27 @@ namespace NadekoBot.Services.Impl
cmdHandler.CommandExecuted += (_, e) => Task.FromResult(Interlocked.Increment(ref _commandsRan));
_client.ChannelCreated += (c) =>
{
var _ = Task.Run(() =>
{
if (c is ITextChannel)
Interlocked.Increment(ref _textChannels);
else if (c is IVoiceChannel)
Interlocked.Increment(ref _voiceChannels);
});
return Task.CompletedTask;
};
_client.ChannelDestroyed += (c) =>
{
var _ = Task.Run(() =>
{
if (c is ITextChannel)
Interlocked.Decrement(ref _textChannels);
else if (c is IVoiceChannel)
Interlocked.Decrement(ref _voiceChannels);
});
return Task.CompletedTask;
};

View File

@ -281,7 +281,7 @@ namespace NadekoBot.Services.Music
{
Title = svideo.FullName,
Provider = "SoundCloud",
Uri = svideo.GetStreamLink(_creds),
Uri = await svideo.StreamLink(),
ProviderType = musicType,
Query = svideo.TrackLink,
AlbumArt = svideo.artwork_url,
@ -296,7 +296,7 @@ namespace NadekoBot.Services.Music
{
Title = svideo.FullName,
Provider = "SoundCloud",
Uri = svideo.GetStreamLink(_creds),
Uri = await svideo.StreamLink(),
ProviderType = MusicType.Soundcloud,
Query = svideo.TrackLink,
AlbumArt = svideo.artwork_url,

View File

@ -26,8 +26,7 @@ namespace NadekoBot.Services.Music
using (var http = new HttpClient())
{
response = await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={url}&client_id={_creds.SoundCloudClientId}").ConfigureAwait(false);
response = await http.GetStringAsync($"https://scapi.nadekobot.me/resolve?url={url}").ConfigureAwait(false);
}
@ -51,7 +50,7 @@ namespace NadekoBot.Services.Music
var response = "";
using (var http = new HttpClient())
{
response = await http.GetStringAsync($"http://api.soundcloud.com/tracks?q={Uri.EscapeDataString(query)}&client_id={_creds.SoundCloudClientId}").ConfigureAwait(false);
response = await http.GetStringAsync($"https://scapi.nadekobot.me/tracks?q={Uri.EscapeDataString(query)}").ConfigureAwait(false);
}
var responseObj = JsonConvert.DeserializeObject<SoundCloudVideo[]>(response).Where(s => s.Streamable).FirstOrDefault();
@ -75,7 +74,13 @@ namespace NadekoBot.Services.Music
[JsonProperty("permalink_url")]
public string TrackLink { get; set; } = "";
public string artwork_url { get; set; } = "";
public string GetStreamLink(IBotCredentials creds) => $"https://api.soundcloud.com/tracks/{Id}/stream?client_id={creds.SoundCloudClientId}";
public async Task<string> StreamLink()
{
using (var http = new HttpClient())
{
return await http.GetStringAsync($"http://scapi.nadekobot.me/stream/{Id}");
}
}
}
public class SoundCloudUser
{

View File

@ -39,9 +39,8 @@ namespace NadekoBot.Services.Searches
_log = LogManager.GetCurrentClassLogger();
//translate commands
_client.MessageReceived += async (msg) =>
_client.MessageReceived += (msg) =>
{
await Task.Yield();
var _ = Task.Run(async () =>
{
try
@ -70,6 +69,7 @@ namespace NadekoBot.Services.Searches
}
catch { }
});
return Task.CompletedTask;
};
//pokemon commands

View File

@ -17,7 +17,6 @@ namespace NadekoBot.Services.Utility
public MessageRepeaterService(NadekoBot bot, DiscordShardedClient client, IEnumerable<GuildConfig> gcs)
{
System.Console.WriteLine(bot.Ready);
var _ = Task.Run(async () =>
{
while (!bot.Ready)

View File

@ -94,7 +94,10 @@ namespace NadekoBot.Extensions
}
}
}
catch (Exception ex) { Console.WriteLine(ex); }
catch (Exception)
{
//ignored
}
};
using (msg.OnReaction(client, changePage, changePage))

View File

@ -153,7 +153,7 @@
"administration_old_nick": "Old nickname",
"administration_old_topic": "Old topic",
"administration_perms": "Error. Most likely I don't have sufficient permissions.",
"administration_perms_reset": "Permissions for this server are reset.",
"permissions_perms_reset": "Permissions for this server are reset.",
"administration_prot_active": "Active protections",
"administration_prot_disable": "{0} has been **disabled** on this server.",
"administration_prot_enable": "{0} Enabled",
@ -534,6 +534,7 @@
"searches_hashtag_error": "Failed finding a definition for that tag.",
"searches_height_weight": "Height/Weight",
"searches_height_weight_val": "{0}m/{1}kg",
"searches_hex_invalid": "Invalid color specified.",
"searches_humidity": "Humidity",
"searches_image_search_for": "Image search for:",
"searches_imdb_fail": "Failed to find that movie.",
@ -764,7 +765,7 @@
"gambling_shop_role": "You will get {0} role.",
"gambling_type": "Type",
"utility_clpa_next_update": "Next update in {0}",
"administration_global_perms_reset": "Global permissions have been reset.",
"permissions_global_perms_reset": "Global permissions have been reset.",
"administration_gvc_disabled": "Game Voice Channel feature has been disabled on this server.",
"administration_gvc_enabled": "{0} is a Game Voice Channel now.",
"administration_not_in_voice": "You are not in a voice channel on this server.",