Compare commits

...

58 Commits

Author SHA1 Message Date
Kwoth
ab0fd44b46 Updated changelog 2022-01-14 20:50:19 +01:00
Kwoth
b61f499f91 Merge branch 'hokutochen-v3-patch-35474' into 'v3'
Updated Linux guide to list the following supported versions.

See merge request Kwoth/nadekobot!221
2022-01-11 10:31:43 +00:00
Hokuto Chen
53d365db3a Updated Linux guide to list the following supported versions. 2022-01-11 10:31:43 +00:00
Kwoth
140c4f7fd6 Merge branch 'hokutochen-v3-patch-28697' into 'v3'
added warning to not follow release if following source

See merge request Kwoth/nadekobot!218
2022-01-07 18:12:58 +00:00
Kwoth
5627a3b172 Merge branch 'hokutochen-v3-patch-45634' into 'v3'
added warning to not follow manual release if following source

See merge request Kwoth/nadekobot!219
2022-01-07 18:12:43 +00:00
Kwoth
4795fa98a0 Merge branch 'hokutochen-v3-patch-32876' into 'v3'
added warning to not follow source guide if using windows updater

See merge request Kwoth/nadekobot!217
2022-01-07 18:11:49 +00:00
Hokuto Chen
93453ba522 added warning to not follow manual release if following source 2022-01-07 08:05:15 +00:00
Hokuto Chen
c6a9108474 added warning to not follow release if following source 2022-01-07 06:50:00 +00:00
Kwoth
c3ba805acf Possible fix for patreon auto-creds update 2022-01-07 06:28:58 +01:00
Kwoth
c0ce22a6b7 .greetdm staggering to avoid ratelimits during raids 2022-01-06 22:53:59 +01:00
Kwoth
22183501fe Fixed .gelbooru 2022-01-06 21:07:32 +01:00
Hokuto Chen
2fbdab3235 added warning to not follow source guide if using windows updater 2022-01-06 20:00:48 +00:00
Kwoth
804d3f79fd Updated changelog 2022-01-06 05:26:45 +01:00
Kwoth
fb119cca4c Merge branch 'v3' of https://gitlab.com/kwoth/nadekobot into v3 2022-01-06 05:16:20 +01:00
Kwoth
31af5ea8c2 Upped version and changelog 2022-01-06 05:15:11 +01:00
Kwoth
e1776d6093 GreetDmMessage will now show a footer with the source server -.- 2022-01-06 05:09:01 +01:00
Kwoth
33dd4bbf0e Merge branch 'make-image-use-safesearch-for-google-images' into 'v3'
Add safesearch to .img when using google

See merge request Kwoth/nadekobot!216
2022-01-05 02:28:58 +00:00
ZeroNyan
af343ac1f0 Add safesearch to .img when using google 2022-01-05 02:28:58 +00:00
Kwoth
065807c180 Merge branch 'hokutochen-v3-patch-71695' into 'v3'
updated creds.yml example owner ID section

See merge request Kwoth/nadekobot!215
2022-01-05 02:28:18 +00:00
Kwoth
9cd24feccc Merge branch 'hokutochen-v3-patch-15423' into 'v3'
Transferred over VPS guide from 1.9

See merge request Kwoth/nadekobot!214
2022-01-05 02:27:47 +00:00
Hokuto Chen
a2d1506915 Transferred over VPS guide from 1.9 2022-01-05 02:27:46 +00:00
Kwoth
54a32a5770 Merge branch 'hokutochen-v3-patch-85263' into 'v3'
Omitted comma explanation for multi owner ID section to avoid confusion

See merge request Kwoth/nadekobot!213
2022-01-05 02:26:53 +00:00
Hokuto Chen
5b9abeb0b2 Omitted comma explanation for multi owner ID section to avoid confusion 2022-01-05 02:26:53 +00:00
Hokuto Chen
accfb2d1ac updated creds.yml example owner ID section 2022-01-04 17:58:47 +00:00
Kwoth
71d383c4db Merge branch 'hokutochen-v3-patch-31256' into 'v3'
fixed GoogleApiKey, formatting error, thanks to alaruba for catching the mistake

See merge request Kwoth/nadekobot!212
2022-01-04 06:03:05 +00:00
Hokuto Chen
197ee9f5ff fixed GoogleApiKey, formatting error, thanks to alaruba for catching the mistake 2022-01-04 00:19:28 +00:00
Kwoth
d51d159962 Merge branch 'hokutochen-v3-patch-51803' into 'v3'
added: Enable "custom search api" for GoogleAPIKey section.

See merge request Kwoth/nadekobot!211
2022-01-03 12:09:06 +00:00
Hokuto Chen
89b0eabd41 added: Enable "custom search api" for GoogleAPIKey section. 2022-01-03 12:09:06 +00:00
Kwoth
8d932d546a Merge branch 'hangman-patch' into 'v3'
small bugfix for hangman

See merge request Kwoth/nadekobot!210
2022-01-03 12:08:41 +00:00
Alan Beatty
9ea3460e3d small bugfix for hangman 2022-01-03 12:08:41 +00:00
Kwoth
7bd4db60a8 Wrong condition in downloadtracker 2022-01-01 16:31:23 +01:00
Kwoth
42e1f35df2 Removed useless #if 2022-01-01 16:28:16 +01:00
Kwoth
179784da3e Possible fix for slowdown with inrole and xplb clean commands 2022-01-01 16:27:30 +01:00
Kwoth
9ed0c870d1 Merge branch 'v3' of https://gitlab.com/kwoth/nadekobot into v3 2021-12-28 10:59:11 +01:00
Kwoth
77e288ee54 Possible fix for .smch 2021-12-28 10:59:02 +01:00
Kwoth
58adaa9110 Merge branch 'hokutochen-v3-patch-89665' into 'v3'
fixed "from source guide" links and "manual prereq" link

See merge request Kwoth/nadekobot!209
2021-12-27 19:10:05 +00:00
Hokuto Chen
d3a73945e7 fixed "from source guide" links and "manual prereq" link 2021-12-27 19:10:05 +00:00
Kwoth
caca407abd Merge branch 'hokutochen-v3-patch-31383' into 'v3'
fixed error in Source guide (accidentally used quotes)

See merge request Kwoth/nadekobot!208
2021-12-24 22:02:51 +00:00
Hokuto Chen
4fd7b2d8cd fixed error in Source guide (accidentally used quotes) 2021-12-24 21:46:24 +00:00
Kwoth
eaea6e3c54 Merge branch 'hokutochen-v3-patch-44970' into 'v3'
Update step 4 of "linux from source" to be more specific.

See merge request Kwoth/nadekobot!206
2021-12-21 20:18:15 +00:00
Hokuto Chen
0bb68c7723 Update step 4 of "linux from source" to be more specific. 2021-12-21 08:48:22 +00:00
Kwoth
52b2c0910c Merge branch 'trans-patch' into 'v3'
ToLower for `.trans` language parameters

See merge request Kwoth/nadekobot!205
2021-12-21 01:20:52 +00:00
Alan Beatty
9a4bb7bff9 ToLower for .trans language parameters 2021-12-21 01:20:52 +00:00
Kwoth
ab5450a125 Merge branch 'hokutochen-v3-patch-59240' into 'v3'
updated "GoogleAPIKey" section

See merge request Kwoth/nadekobot!203
2021-12-21 00:46:13 +00:00
Kwoth
bcce32423c Merge branch 'banmsgpatch' into 'v3'
Fix color for ban DMs with plain text ban message.

Closes #324

See merge request Kwoth/nadekobot!204
2021-12-21 00:00:45 +00:00
Alan Beatty
c42d529016 Fix color for ban DMs with plain text ban message. 2021-12-21 00:00:45 +00:00
Hokuto Chen
cbea5077be updated "GoogleAPIKey" section 2021-12-20 04:40:53 +00:00
Kwoth
cdc2cc1439 Merge branch 'hokutochen-v3-patch-62793' into 'v3'
fixed broken "Enter your bot's token" link in "linux release" portion

See merge request Kwoth/nadekobot!202
2021-12-19 01:12:47 +00:00
Kwoth
87819f21bf Merge branch 'v3' of https://gitlab.com/kwoth/nadekobot into v3 2021-12-19 01:56:42 +01:00
Kwoth
d1be56fbc1 Another attempt at fixing a weird coordinator bug 2021-12-19 01:56:30 +01:00
Hokuto Chen
14016a761d fixed broken "Enter your bot's token" link in "linux release" portion 2021-12-19 00:24:55 +00:00
Kwoth
12a64c4c4d Merge branch 'xpstrspatch' into 'v3'
Update xpex channel to use the right string

See merge request Kwoth/nadekobot!201
2021-12-18 21:11:06 +00:00
Kwoth
d922120f58 Merge branch 'transpatch' into 'v3'
Small `.trans` fixes

See merge request Kwoth/nadekobot!200
2021-12-18 21:10:06 +00:00
Alan Beatty
8e8e349e65 Small .trans fixes 2021-12-18 21:10:06 +00:00
Kwoth
ccdf0fc077 Merge branch 'hokutochen-v3-patch-43568' into 'v3'
separated "cd output && cp creds_example.yml creds.yml"

See merge request Kwoth/nadekobot!199
2021-12-18 21:09:16 +00:00
Hokuto Chen
8c66bcb1e1 separated "cd output && cp creds_example.yml creds.yml" 2021-12-18 21:09:16 +00:00
Kwoth
77fb47183f Possible fix for #322 2021-12-18 22:07:03 +01:00
Alan Beatty
d275dc36b2 Update xpex channel to use the right string 2021-12-18 11:13:02 +00:00
22 changed files with 235 additions and 86 deletions

View File

@@ -2,9 +2,23 @@
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
## Unreleased
## [3.0.13] - 14.04.2021
-
### Fixed
- Fixed `.greetdm` causing ratelimits during raids
- Fixed `.gelbooru`
## [3.0.12] - 06.01.2021
### Fixed
- `.smch` Fixed
- `.trans` command will now work properly with capitilized language names
- Ban message color with plain text fixed
- Fixed some grpc coordinator bugs
- Fixed a string in `.xpex`
- Google version of .img will now have safe search enabled
- Fixed a small bug in `.hangman`
## [3.0.11] - 17.12.2021

View File

@@ -13,8 +13,13 @@ This document aims to guide you through the process of creating a Discord accoun
- Click on the `Add a Bot` button and confirm that you do want to add a bot to this app.
- **Optional:** Add bot's avatar and description.
- Copy your Token to `creds.yml` as shown above.
- Scroll down to the `Privileged Gateway Intents` section and enable both intents.
These are required for a number of features to function properly, and should both be on.
- Scroll down to the `Privileged Gateway Intents` section
- Enabled the following:
- PRESENCE INTENT
- SERVER MEMBERS INTENT
- MESSAGE CONTENT INTENT
These are required for a number of features to function properly, and all should be on.
##### Getting Owner ID*(s)*:
@@ -32,7 +37,7 @@ For a single owner, it should look like this:
- 105635576866156544
```
For multiple owners, it should look like this (pay attention to the commas, the last ID should **never** have a comma next to it):
For multiple owners, it should look like this:
```yml
OwnerIds:
@@ -56,4 +61,4 @@ For multiple owners, it should look like this (pay attention to the commas, the
That's it! You may now go back to the installation guide you were following before 🎉
[DiscordApp]: https://discordapp.com/developers/applications/me
[DiscordApp]: https://discordapp.com/developers/applications/me

View File

@@ -4,6 +4,19 @@
#### [Linux migration instructions](../migration-guide/#linux)
#### Operating System Compatibility
It is recommended that you use **Ubuntu 20.04**, as there have been nearly no problems with it. Also, **32-bit systems are incompatible**.
##### Compatible operating systems:
- Ubuntu: 16.04, 18.04, 20.04, 21.04, 21.10
- Mint: 19, 20
- Debian: 9, 10
- CentOS: 7
- openSUSE
- Fedora: 33, 34, 35
## Linux From Source
Open Terminal (if you're on an installation with a window manager) and navigate to the location where you want to install the bot (for example `cd ~`)
@@ -13,11 +26,11 @@ Open Terminal (if you're on an installation with a window manager) and navigate
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/master/linuxAIO.sh && bash linuxAIO.sh`
2. Install prerequisites (type `1` and press enter)
3. Download the bot (type `2` and press enter)
4. Exit the installer in order to set up your `creds.yml`
4. Exit the installer (type `5` and press enter)
5. Copy the creds.yml template `cp nadekobot/output/creds_example.yml nadekobot/output/creds.yml`
6. Open `nadekobot/output/creds.yml` with your favorite text editor. We will use nano here
- `nano nadekobot/output/creds.yml`
7. [Enter your bot's token](../../creds-guide)
7. [Click here to follow creds guide](../../creds-guide)
- After you're done, you can close nano (and save the file) by inputting, in order
- `CTRL` + `X`
- `Y`
@@ -34,6 +47,8 @@ Open Terminal (if you're on an installation with a window manager) and navigate
## Linux Release
⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠
##### Installation Instructions
1. Download the latest release from <https://gitlab.com/Kwoth/nadekobot/-/releases>
@@ -49,7 +64,7 @@ Open Terminal (if you're on an installation with a window manager) and navigate
- `cp creds_example.yml creds.yml`
6. Open `creds.yml` with your favorite text editor. We will use nano here
- `nano nadekobot/output/creds.yml`
8. [Enter your bot's token](#creds-guide)
8. [Click here to follow creds guide](../../creds-guide)
- After you're done, you can close nano (and save the file) by inputting, in order
- `CTRL` + `X`
- `Y`
@@ -244,3 +259,34 @@ This method is similar to the one above, but requires one extra step, with the a
5. Start Nadeko:
- `sudo systemctl start nadeko.service && sudo systemctl enable nadeko.service`
### Setting up Nadeko on a Linux VPS (Digital Ocean Droplet)
If you want Nadeko to play music for you 24/7 without having to hosting it on your PC and want to keep it cheap, reliable and convenient as possible, you can try Nadeko on Linux Digital Ocean Droplet using the link [DigitalOcean](http://m.do.co/c/46b4d3d44795/) (by using this link, you will get **$10 credit** and also support Nadeko)
**Setting up NadekoBot**
Assuming you have followed the link above to setup an account and a Droplet with a 64-bit operational system on Digital Ocean and got the `IP address and root password (in your e-mail)` to login, it's time to get started.
**This section is only relevant to those who want to host Nadeko on DigitalOcean. Go through this whole section before setting the bot up.**
#### Prerequisites
- Download [PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)
- Download [WinSCP](https://winscp.net/eng/download.php) *(optional)*
- [Create and invite the bot](../../creds-guide).
#### Starting up
- **Open PuTTY** and paste or enter your `IP address` and then click **Open**.
If you entered your Droplets IP address correctly, it should show **login as:** in a newly opened window.
- Now for **login as:**, type `root` and press enter.
- It should then ask for a password. Type the `root password` you have received in your e-mail address, then press Enter.
If you are running your droplet for the first time, it will most likely ask you to change your root password. To do that, copy the **password you've received by e-mail** and paste it on PuTTY.
- To paste, just right-click the window (it won't show any changes on the screen), then press Enter.
- Type a **new password** somewhere, copy and paste it on PuTTY. Press Enter then paste it again.
**Save the new password somewhere safe.**
After that, your droplet should be ready for use. [Follow the guide from the beginning](#linux-from-source) to set Nadeko up on your newly created VPS.

View File

@@ -56,6 +56,8 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
## MacOS Manual Release installation instructions
⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠
##### Installation Instructions
1. Download the latest release from <https://gitlab.com/Kwoth/nadekobot/-/releases>
@@ -120,4 +122,4 @@ rm -r nadekobot-old/data/strings && \
cp -RT nadekobot-old/data/ nadekobot/data/ && \
cp nadekobot-old/creds.yml nadekobot/ && \
cd nadekobot && chmod +x NadekoBot
```
```

View File

@@ -12,11 +12,11 @@
| [Setup](#setup) |
| [Starting the Bot](#starting-the-bot) |
| [Updating Nadeko](#updating-nadeko) |
| [Manually Installing the Prerequisites from the Updater](#if-the-updater-fails-to-install-the-prerequisites-for-any-reason) |
| [Manually Installing the Prerequisites from the Updater](#music-prerequisites) |
*Note: If you want to make changes to Nadeko's source code, please follow the [From Source][SourceGuide] guide instead.*
*Note: If you want to make changes to Nadeko's source code, please follow the [From Source](#windows-from-source) guide instead.*
*If you have Windows 7 or a 32-bit system, please refer to the [From Source][SourceGuide] guide.*
*If you have Windows 7 or a 32-bit system, please refer to the [From Source](#windows-from-source)) guide.*
#### Prerequisites
@@ -38,7 +38,7 @@
- Click on **`DOWNLOAD`** at the lower right
![Bot Setup](https://i.imgur.com/HqAl36p.png "Bot Setup")
- Click on **`Install`** next to **`Redis`**.
- **Note: If Redis fails to install, install Redis manually here: [Redis Installer](https://github.com/MicrosoftArchive/redis/releases/tag/win-3.0.504) Download and run the **`.msi`** file.
- Note: If Redis fails to install, install Redis manually here: [Redis Installer](https://github.com/MicrosoftArchive/redis/releases/tag/win-3.0.504) Download and run the **`.msi`** file.
- If you will use the music module, click on **`Install`** next to **`FFMPEG`** and **`Youtube-DL`**.
- If any dependencies fail to install, you can temporarily disable your Windows Defender/AV until you install them. If you don't want to, then read [the last section of this guide](#Manual-Prerequisite-Installation).
- When installation is finished, click on **`CREDS`** to the left of **`RUN`** at the lower right.
@@ -69,6 +69,8 @@ You can still install them manually:
### Windows From Source
⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠
##### Prerequisites
**Install these before proceeding or your bot will not work!**
@@ -83,11 +85,12 @@ Open PowerShell (press windows button on your keyboard and type powershell, it s
1. `git clone https://gitlab.com/kwoth/nadekobot -b v3 --depth 1`
2. `cd nadekobot`
3. `dotnet publish -c Release -o output/ src/NadekoBot/`
4. `cd output && cp creds_example.yml creds.yml`
5. Open `creds.yml` with your favorite text editor (Please don't use Notepad or WordPad. You can use Notepad++, VSCode, Atom, Sublime, or something similar)
6. [Enter your bot's token](#creds-guide)
7. Run the bot `dotnet NadekoBot.dll`
8. 🎉
4. `cd output`
5. `cp creds_example.yml creds.yml`
6. Open `creds.yml` with your favorite text editor (Please don't use Notepad or WordPad. You can use Notepad++, VSCode, Atom, Sublime, or something similar)
7. [Enter your bot's token](#creds-guide)
8. Run the bot `dotnet NadekoBot.dll`
9. 🎉
##### Update Instructions
@@ -129,8 +132,6 @@ In order to use music commands, you need ffmpeg and youtube-dl installed.
[Redis]: https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi
[Visual C++ 2010 (x86)]: https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe
[Visual C++ 2017 (x64)]: https://aka.ms/vs/15/release/vc_redist.x64.exe
[SourceGuide]: ../from-source
[ffmpeg-32bit]: https://cdn.nadeko.bot/dl/ffmpeg-32.zip
[ffmpeg-64bit]: https://cdn.nadeko.bot/dl/ffmpeg-64.zip
[youtube-dl]: https://yt-dl.org/downloads/latest/youtube-dl.exe

View File

@@ -8,8 +8,14 @@ This part is completely optional, **however it's necessary for music and a few o
- Go to [Google Console][Google Console] and log in.
- Create a new project (name does not matter).
- Once the project is created, go into `Library`
- Under the `YouTube APIs` section, enable `YouTube Data API`
- On the left tab, access `Credentials`,
- Under the `YouTube APIs` section
- Select `YouTube Data API v3`,
- Click enable.
- Search for `Custom Search API`
- Select `Custom Search API`,
- Click enable.
- Open up the `Navigation menu` on the top right with the three lines.
- select `APIs & Services`, then select `Credentials`,
- Click `Create Credentials` button,
- Click on `API Key`
- A new window will appear with your `Google API key`
@@ -18,7 +24,7 @@ This part is completely optional, **however it's necessary for music and a few o
- Open up `creds.yml` and look for `GoogleAPIKey`, paste your API key after the `:`.
- It should look like this:
```yml
GoogleApiKey: "AIzaSyDSci1sdlWQOWNVj1vlXxxxxxbk0oWMEzM"
GoogleApiKey: AIzaSyDSci1sdlWQOWNVj1vlXxxxxxbk0oWMEzM
```
- **MashapeKey**
- Required for Hearthstone cards.
@@ -92,11 +98,10 @@ version: 1
token: 'MTE5Nzc3MDIxMzE5NTc3NjEw.VlhNCw.BuqJFyzdIUAK1PRf1eK1Cu89Jew'
# List of Ids of the users who have bot owner permissions
# **DO NOT ADD PEOPLE YOU DON'T TRUST**
ownerIds: [
105635123466156544,
145521851676884992,
341420590009417729
]
ownerIds:
- 105635123466156544
- 145521851676884992
- 341420590009417729
# The number of shards that the bot will running on.
# Leave at 1 if you don't know what you're doing.
totalShards: 1

View File

@@ -160,18 +160,24 @@ namespace NadekoBot.Coordinator
private void StartShard(int shardId)
{
var status = _shardStatuses[shardId];
if (status.Process is {HasExited: false} p)
try
{
try
if (status.Process is { HasExited: false } p)
{
p.Kill(true);
try
{
p.Kill(true);
}
catch
{
}
}
catch
{
}
}
try { status.Process?.Dispose(); } catch { }
status.Process?.Dispose();
}
catch
{
}
var proc = StartShardProcess(shardId);
_shardStatuses[shardId] = status with

View File

@@ -19,6 +19,9 @@ namespace NadekoBot.Common
/// <returns>Task representing download state</returns>
public async Task EnsureUsersDownloadedAsync(IGuild guild)
{
#if GLOBAL_NADEKO
return;
#endif
await downloadUsersSemaphore.WaitAsync();
try
{

View File

@@ -258,8 +258,7 @@ namespace NadekoBot.Modules.Administration
{
user = user ?? (IGuildUser) ctx.User;
var channel = await user.GetOrCreateDMChannelAsync();
var success = await _service.GreetDmTest(channel, user);
var success = await _service.GreetDmTest(user);
if (success)
await ctx.OkAsync();
else

View File

@@ -499,7 +499,9 @@ WHERE GuildId={guildId}
{
template = JsonConvert.SerializeObject(new
{
color = _bcs.Data.Color.Error,
//To get the decimal version of the color that's expected, take the packed value of the Rgba32
//and bitshift it to the right by 8 bits, thereby dropping the "a" and getting a reprensentation of the RGB value
color = _bcs.Data.Color.Error.PackedValue >> 8,
description = defaultMessage
});
}
@@ -514,7 +516,9 @@ WHERE GuildId={guildId}
{
template = JsonConvert.SerializeObject(new
{
color = _bcs.Data.Color.Error,
//To get the decimal version of the color that's expected, take the packed value of the Rgba32
//and bitshift it to the right by 8 bits, thereby dropping the "a" and getting a reprensentation of the RGB value
color = _bcs.Data.Color.Error.PackedValue >> 8,
description = template
});
}

View File

@@ -104,7 +104,8 @@ namespace NadekoBot.Modules.Games.Hangman
CurrentPhase = Phase.Ended;
return GetState(GuessResult.Win);
}
_correct.Add(charGuess);
return GetState(GuessResult.Guess);
}

View File

@@ -195,7 +195,7 @@ namespace NadekoBot.Modules.Music.Services
public Task<IUserMessage?> SendToOutputAsync(ulong guildId, IEmbedBuilder embed)
{
if (_outputChannels.TryGetValue(guildId, out var chan))
return (chan.Default ?? chan.Override).EmbedAsync(embed);
return (chan.Override ?? chan.Default).EmbedAsync(embed);
return Task.FromResult<IUserMessage?>(null);
}

View File

@@ -2,6 +2,7 @@
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
@@ -13,10 +14,11 @@ namespace NadekoBot.Modules.Nsfw.Common
{
}
public override async Task<List<DapiImageObject>> DownloadImagesAsync(string[] tags, int page, bool isExplicit = false, CancellationToken cancel = default)
public override async Task<List<DapiImageObject>> DownloadImagesAsync(string[] tags, int page,
bool isExplicit = false, CancellationToken cancel = default)
{
var tagString = ImageDownloaderHelper.GetTagString(tags, isExplicit);
var uri = $"http://gelbooru.com/index.php?page=dapi&s=post&json=1&q=index&limit=100" +
var uri = $"https://gelbooru.com/index.php?page=dapi&s=post&json=1&q=index&limit=100" +
$"&tags={tagString}&pid={page}";
using var req = new HttpRequestMessage(HttpMethod.Get, uri);
using var res = await _http.SendAsync(req, cancel).ConfigureAwait(false);
@@ -24,12 +26,18 @@ namespace NadekoBot.Modules.Nsfw.Common
var resString = await res.Content.ReadAsStringAsync(cancel);
if (string.IsNullOrWhiteSpace(resString))
return new();
var images = JsonSerializer.Deserialize<List<DapiImageObject>>(resString, _serializerOptions);
if (images is null)
var images = JsonSerializer.Deserialize<GelbooruResponse>(resString, _serializerOptions);
if (images is null or { Post: null })
return new();
return images.Where(x => x.FileUrl is not null).ToList();
return images.Post.Where(x => x.FileUrl is not null).ToList();
}
}
public class GelbooruResponse
{
[JsonPropertyName("post")]
public List<DapiImageObject> Post { get; set; }
}
}

View File

@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using AngleSharp.Common;
using Discord;
using Discord.Net;
using LinqToDB;
@@ -13,7 +12,6 @@ using Microsoft.EntityFrameworkCore;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Extensions;
using NadekoBot.Services;
using NadekoBot.Services.Database;
namespace NadekoBot.Modules.Searches
{

View File

@@ -12,12 +12,12 @@ namespace NadekoBot.Modules.Searches
public class TranslateCommands : NadekoSubmodule<ITranslateService>
{
[NadekoCommand, Aliases]
public async Task Translate(string from, string to, [Leftover] string text = null)
public async Task Translate(string from, string to, [Leftover] string text)
{
try
{
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
var translation = await _service.Translate(from, to, text).ConfigureAwait(false);
var translation = await _service.Translate(from.ToLower(), to.ToLower(), text).ConfigureAwait(false);
var embed = _eb.Create(ctx)
.WithOkColor()

View File

@@ -4,7 +4,9 @@ using NadekoBot.Services.Database.Models;
using NadekoBot.Modules.Utility.Common.Patreon;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json.Serialization;
@@ -146,15 +148,22 @@ namespace NadekoBot.Modules.Utility.Services
if (DateTime.UtcNow.Day < 5)
return;
// if the user has the necessary patreon creds
// and the access token expired or doesn't exist
// -> update access token
if (!HasPatreonCreds(creds))
if (string.IsNullOrWhiteSpace(creds.Patreon.CampaignId))
return;
if (LastAccessTokenUpdate(creds).Month < DateTime.UtcNow.Month
var lastUpdate = LastAccessTokenUpdate(creds);
var now = DateTime.UtcNow;
if (lastUpdate.Year != now.Year
|| lastUpdate.Month != now.Month
|| string.IsNullOrWhiteSpace(creds.Patreon.AccessToken))
{
// if the user has the necessary patreon creds
// and the access token expired or doesn't exist
// -> update access token
if (!HasPatreonCreds(creds))
return;
var success = await UpdateAccessToken(creds);
if (!success)
return;
@@ -164,7 +173,7 @@ namespace NadekoBot.Modules.Utility.Services
await getPledgesLocker.WaitAsync().ConfigureAwait(false);
try
{
var members = new List<PatreonMember>();
var users = new List<PatreonUser>();
using (var http = _httpFactory.CreateClient())
@@ -185,7 +194,7 @@ namespace NadekoBot.Modules.Utility.Services
if (data is null)
break;
members.AddRange(data.Data);
users.AddRange(data.Included);
} while (!string.IsNullOrWhiteSpace(page = data?.Links?.Next));
@@ -209,12 +218,19 @@ namespace NadekoBot.Modules.Utility.Services
EntitledTo: > 0
})
.ToList();
foreach (var pledge in userData)
{
await ClaimReward(pledge.UserId, pledge.PatreonUserId, pledge.EntitledTo);
}
}
catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.Unauthorized)
{
Log.Warning("Patreon credentials invalid or expired. I will try to refresh them during the next run");
var db = _redis.GetDatabase();
await db.KeyDeleteAsync($"{creds.RedisKey()}_patreon_update");
}
catch (Exception ex)
{
Log.Warning(ex, "Error refreshing patreon pledges");
@@ -223,7 +239,6 @@ namespace NadekoBot.Modules.Utility.Services
{
getPledgesLocker.Release();
}
}
public async Task<int> ClaimReward(ulong userId, string patreonUserId, int cents)

View File

@@ -108,7 +108,9 @@ namespace NadekoBot.Modules.Utility
await ctx.Channel.TriggerTypingAsync().ConfigureAwait(false);
await _tracker.EnsureUsersDownloadedAsync(ctx.Guild).ConfigureAwait(false);
var users = await ctx.Guild.GetUsersAsync();
var users = await ctx.Guild.GetUsersAsync(
CacheMode.CacheOnly
);
var roleUsers = users
.Where(u => role is null ? u.RoleIds.Count == 1 : u.RoleIds.Contains(role.Id))
.Select(u => $"`{u.Id, 18}` {u}")

View File

@@ -1,4 +1,4 @@
using Discord;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using NadekoBot.Common.Attributes;
@@ -278,7 +278,7 @@ namespace NadekoBot.Modules.Xp
}
else
{
await ReplyConfirmLocalizedAsync(strs.excluded(Format.Bold(channel.ToString())));
await ReplyConfirmLocalizedAsync(strs.not_excluded(Format.Bold(channel.ToString())));
}
}

View File

@@ -8,14 +8,16 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Channels;
using System.Threading.Tasks;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Db;
using NadekoBot.Modules.Administration;
using Serilog;
namespace NadekoBot.Services
{
public class GreetSettingsService : INService
public class GreetSettingsService : INService, IReadyExecutor
{
private readonly DbService _db;
@@ -51,6 +53,17 @@ namespace NadekoBot.Services
_client.GuildMemberUpdated += ClientOnGuildMemberUpdated;
}
public async Task OnReadyAsync()
{
while (true)
{
var (conf, user, compl) = await _greetDmQueue.Reader.ReadAsync();
var res = await GreetDmUserInternal(conf, user);
compl.TrySetResult(res);
await Task.Delay(2000);
}
}
private Task ClientOnGuildMemberUpdated(SocketGuildUser oldUser, SocketGuildUser newUser)
{
@@ -240,17 +253,48 @@ namespace NadekoBot.Services
}
}
private async Task<bool> GreetDmUser(GreetSettings conf, IDMChannel channel, IGuildUser user)
private readonly Channel<(GreetSettings, IGuildUser, TaskCompletionSource<bool>)> _greetDmQueue =
Channel.CreateBounded<(GreetSettings, IGuildUser, TaskCompletionSource<bool>)>(new BoundedChannelOptions(60)
{
// The limit of 60 users should be only hit when there's a raid. In that case
// probably the best thing to do is to drop newest (raiding) users
FullMode = BoundedChannelFullMode.DropNewest
});
private async Task<bool> GreetDmUser(GreetSettings conf, IGuildUser user)
{
var completionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
await _greetDmQueue.Writer.WriteAsync((conf, user, completionSource));
return await completionSource.Task;
}
private async Task<bool> GreetDmUserInternal(GreetSettings conf, IGuildUser user)
{
var rep = new ReplacementBuilder()
.WithDefault(user, channel, (SocketGuild)user.Guild, _client)
.Build();
var text = SmartText.CreateFrom(conf.DmGreetMessageText);
rep.Replace(text);
try
{
await channel.SendAsync(text).ConfigureAwait(false);
var rep = new ReplacementBuilder()
.WithUser(user)
.WithServer(_client, (SocketGuild)user.Guild)
.Build();
var text = SmartText.CreateFrom(conf.DmGreetMessageText);
text = rep.Replace(text);
if (text is SmartPlainText pt)
{
text = new SmartEmbedText() { PlainText = pt.Text };
}
((SmartEmbedText)text).Footer = new()
{
Text = $"This message was sent from {user.Guild} server.", IconUrl = user.Guild.IconUrl
};
var ch = await user.GetOrCreateDMChannelAsync();
if (ch is null)
return false;
await ch.SendAsync(text);
}
catch
{
@@ -301,12 +345,7 @@ namespace NadekoBot.Services
if (conf.SendDmGreetMessage)
{
var channel = await user.GetOrCreateDMChannelAsync().ConfigureAwait(false);
if (channel != null)
{
await GreetDmUser(conf, channel, user);
}
await GreetDmUser(conf, user);
}
}
catch
@@ -477,10 +516,10 @@ namespace NadekoBot.Services
return GreetUsers(conf, channel, user);
}
public Task<bool> GreetDmTest(IDMChannel channel, IGuildUser user)
public Task<bool> GreetDmTest(IGuildUser user)
{
var conf = GetOrAddSettingsForGuild(user.GuildId);
return GreetDmUser(conf, channel, user);
return GreetDmUser(conf, user);
}
#endregion

View File

@@ -1,4 +1,4 @@
using Google;
using Google;
using Google.Apis.Customsearch.v1;
using Google.Apis.Services;
using Google.Apis.Urlshortener.v1;
@@ -220,6 +220,7 @@ namespace NadekoBot.Services
req.Fields = "items(image(contextLink,thumbnailLink),link)";
req.SearchType = CseResource.ListRequest.SearchTypeEnum.Image;
req.Start = new NadekoRandom().Next(0, 20);
req.Safe = CseResource.ListRequest.SafeEnum.Active;
var search = await req.ExecuteAsync().ConfigureAwait(false);
@@ -388,4 +389,4 @@ namespace NadekoBot.Services
return mode;
}
}
}
}

View File

@@ -20,7 +20,7 @@ namespace NadekoBot.Services
private readonly IBotCredentials _creds;
private readonly DateTime _started;
public const string BotVersion = "3.0.11";
public const string BotVersion = "3.0.12";
public string Author => "Kwoth#2452";
public string Library => "Discord.Net";
public double MessagesPerSecond => MessageCounter / GetUptime().TotalSeconds;

View File

@@ -1143,9 +1143,9 @@ butts:
args:
- ""
translate:
desc: "Translates from>to text. From the given language to the destination language."
desc: "Translates text from the given language to the destination language."
args:
- "en>fr Hello"
- "en fr Hello"
translangs:
desc: "Lists the valid languages for translation."
args: