dev: Removed discrim from the database

add: .translateflags command
add: captcha to timely, configurable in .conf gambling
change: change bonuses for patreon rewards
fix: nunchi message color fix
This commit is contained in:
Kwoth
2024-11-02 16:23:58 +00:00
parent 12f4ce7f2a
commit 4b12e4e923
29 changed files with 7782 additions and 333 deletions

View File

@@ -2,6 +2,35 @@
Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
## [5.1.18] - 02.11.2024
### Added
- Added `.translateflags` / `.trfl` command.
- Enable on a per-channel basis.
- Reacting on any message in that channel with a flag emoji will post the translation of that message in the
language of that country
- 5 second cooldown per user
- The message can only be translated once per language (counter resets every 24h)
- `.timely` now has a captcha. Togglable via `.conf gambling`
## Changed
- [public bot] Patreon reward bonus for flowers reduced. Timely bonuses stay the same
- discriminators removed from the databases. All users who had ???? as discriminator have been renamed to ??username.
- all new unknown users will have ??Unknown as their name
## Fixed
- nunchi join game message is now ok color instead of error color
## [5.1.17] - 29.10.2024
### Fixed
- fix: Bot will now not accept .aar Role if that Role is higher than or equal to bot's role. Previously bot would just
fail silently, now there is a proper error message.
## [5.1.16] - 28.10.2024
## Added
@@ -70,7 +99,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Added
- Added `%user.displayname%` placeholder. It will show users nickname, if there is one, otherwise it will show the username.
- Added `%user.displayname%` placeholder. It will show users nickname, if there is one, otherwise it will show the
username.
- Nickname won't be shown in bye messages.
- Added initial version of grpc api. Beta
@@ -103,17 +133,20 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- Fixed `.greettest`, and other `.*test` commands if you didn't have them enabled.
- Fixed `.greetdmtest` sending messages twice.
- Fixed a serious bug which caused greet messages to be jumbled up, and wrong ones to be sent for the wrong events.
- There is no database issue, all greet messages are safe, the cache was caching any setting every 3 seconds with no regard for the type of the event
- There is no database issue, all greet messages are safe, the cache was caching any setting every 3 seconds with no
regard for the type of the event
- This also caused `.greetdm` messages to not be sent if `.greet` is enabled
- This bug was introduced in 5.1.8. PLEASE UPDATE if you are on 5.1.8
- Selfhosters only: Fixed medusa dependency loading
- Note: Make sure to not publish any other DLLs besides the ones you are sure you will need, as there can be version conflicts which didn't happen before.
- Note: Make sure to not publish any other DLLs besides the ones you are sure you will need, as there can be version
conflicts which didn't happen before.
## [5.1.8] - 19.09.2024
### Added
- Added `.leaveunkeptservers` which will make the bot leave all servers on all shards whose owners didn't run `.keep` command.
- Added `.leaveunkeptservers` which will make the bot leave all servers on all shards whose owners didn't run `.keep`
command.
- This is a dangerous and irreversible command, don't use it. Meant for use on the public bot.
- `.adpl` now supports custom statuses (you no longer need to specify Playing, Watching, etc...)
@@ -125,7 +158,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- `.quotesearch` / `.qse` is now paginated for easier searching
- `.whosplaying` is now paginated
- `.img` is now paginated
- `.setgame` renamed to`.setactivity` and now supports custom text activity. You don't have to specify playing, listening etc before the activity
- `.setgame` renamed to`.setactivity` and now supports custom text activity. You don't have to specify playing,
listening etc before the activity
- Clarified and added some embed / placeholder links to command help where needed
- dev: A lot of code cleanup and internal improvements
@@ -166,6 +200,7 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- Possible fix for `.remind` timestamp
### Removed
- Removed old bloat / semi broken / dumb commands
- `.memelist` / `.memegen` (too inconvenient to use)
- `.activity` (useless owner-only command)
@@ -192,7 +227,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- Updated some bet descriptions to include 'all' 'half' usage instructions
- Updated some command strings
- dev: Vastly simplified medusa creation using dotnet templates, docs updated
- Slight refactor of .wiki, time, .catfact, .wikia, .define, .bible and .quran commands, no significant change in functionality
- Slight refactor of .wiki, time, .catfact, .wikia, .define, .bible and .quran commands, no significant change in
functionality
### Fixed
@@ -200,6 +236,7 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- You can once again disable cleverbot responses using fake 'cleverbot:response' module name in permission commands
### Removed
- Removed .rip command
## [5.1.4] - 13.07.2024
@@ -208,8 +245,10 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- Added `.coins` command which lists top 10 cryptos ordered by marketcap
- Added Clubs rank in the leaderboard to `.clubinfo`
- Bot owners can now check other people's bank balance (Not server owners, only bot owner, the person who is hosting the bot)
- You can now send multiple waifu gifts at once to waifus. For example `.waifugift 3xRose @user` will give that user 3 roses
- Bot owners can now check other people's bank balance (Not server owners, only bot owner, the person who is hosting the
bot)
- You can now send multiple waifu gifts at once to waifus. For example `.waifugift 3xRose @user` will give that user 3
roses
- The format is `<NUMBER>x<ITEM>`, no spaces
- Added `.boosttest` command
- Added support for any openai compatible api for the chatterbot feature change:
@@ -235,7 +274,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Changed
- Replying to the bot's message in the channel where chatterbot is enabled will also trigger the ai response, as if you pinged the bot. This only works for chatterbot, but not for nadeko ai command prompts
- Replying to the bot's message in the channel where chatterbot is enabled will also trigger the ai response, as if you
pinged the bot. This only works for chatterbot, but not for nadeko ai command prompts
### Fixed
@@ -268,28 +308,33 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Added
- Added `.prompt` command, Nadeko Ai Assistant
- You can send natural language questions, queries or execute commands. For example "@Nadeko how's the weather in paris" and it will return `.we Paris` and run it for you.
- In case the bot can't execute a command using your query, It will fall back to your chatter bot, in case you have it enabled in data/games.yml. (Cleverbot or chatgpt)
- You can send natural language questions, queries or execute commands. For example "@Nadeko how's the weather in
paris" and it will return `.we Paris` and run it for you.
- In case the bot can't execute a command using your query, It will fall back to your chatter bot, in case you have
it enabled in data/games.yml. (Cleverbot or chatgpt)
- (It's far from perfect so please don't ask the bot to do dangerous things like banning or pruning)
- Requires Patreon subscription, after which you'll be able to run it on global @Nadeko bot.
- Selfhosters: If you're selfhosting, you also will need to acquire the api key from <https://dashy.nadeko.bot/me> after pledging on patreon and put it in nadekoAiToken in creds.yml
- Selfhosters: If you're selfhosting, you also will need to acquire the api key
from <https://dashy.nadeko.bot/me> after pledging on patreon and put it in nadekoAiToken in creds.yml
- Added support for `gpt-4o` in `data/games.yml`
### Changed
- Remind will now show a timestamp tag for durations
- Only `Gpt35Turbo` and `Gpt4o` are valid inputs in games.yml now
- `data/patron.yml` changed. It now has limits. The entire feature limit system has been reworked. Your previous settings will be reset
- `data/patron.yml` changed. It now has limits. The entire feature limit system has been reworked. Your previous
settings will be reset
- A lot of updates to bot strings (thanks Ene)
- Improved cleanup command to delete a lot more data once cleanup is ran, not only guild configs (please don't use this command unless you have your database bakced up and you know 100% what you're doing)
- Improved cleanup command to delete a lot more data once cleanup is ran, not only guild configs (please don't use this
command unless you have your database bakced up and you know 100% what you're doing)
### Fixed
- Fixed xp bg buy button not working, and possibly some other buttons too
- Fixed shopbuy %user% placeholders and updated help text
- All .feed overloads should now work"
- `.xpexclude` should will now work with forums too. If you exclude a forum you won't be able to gain xp in any of the threads.
- `.xpexclude` should will now work with forums too. If you exclude a forum you won't be able to gain xp in any of the
threads.
- Fixed remind not showing correct time (thx cata)
### Removed
@@ -303,8 +348,10 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- Added `.setserverbanner` and `.setservericon` commands (thx cata)
- Added overloads section to `.h command` which will show you all versions of command usage with param names
- You can now check commands for submodules, for example `.cmds SelfAssignedRoles` will show brief help for each of the commands in that submodule
- Added dropdown menus for .mdls and .cmds (both module and group versions) which will give you the option to see more detailed help for each specific module, group or command respectively
- You can now check commands for submodules, for example `.cmds SelfAssignedRoles` will show brief help for each of the
commands in that submodule
- Added dropdown menus for .mdls and .cmds (both module and group versions) which will give you the option to see more
detailed help for each specific module, group or command respectively
- Self-Hosters only:
- Added a dangerous cleanup command that you don't have to know about
@@ -323,7 +370,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Fixed
- `.streammessage` will once again be able to mention anyone (as long as the user setting the message has the permission to mention everyone)
- `.streammessage` will once again be able to mention anyone (as long as the user setting the message has the permission
to mention everyone)
- `.streammsgall` fixed
- `.xplb` and `.xpglb` pagination fixed
- Fixed page number when the total number of elements is unknown
@@ -352,15 +400,19 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Added
- Added `.shopadd command` You can now sell commands in the shop. The command will execute as if you were the one running it when someone buys it
- Added `.shopadd command` You can now sell commands in the shop. The command will execute as if you were the one
running it when someone buys it
- type `.h .shopadd` for more info
- Added `.stickyroles` Users leaving the server will have their roles saved to the database and reapplied if they rejoin within 30 days.
- Added `.stickyroles` Users leaving the server will have their roles saved to the database and reapplied if they rejoin
within 30 days.
- Giveaway commands
- `.ga start <duration> <text>` starts the giveway with the specified duration and message (prize). You may have up to 5 giveaways on the server at once
- `.ga start <duration> <text>` starts the giveway with the specified duration and message (prize). You may have up
to 5 giveaways on the server at once
- `.ga end <id>` prematurely ends the giveaway and selects a winner
- `.ga cancel <id>` cancels the giveaway and doesn't select a winner
- `.ga list` lists active giveaways on the current server
- `.ga reroll <id>` rerolls the winner on the completed giveaway. This only works for 24 hours after the giveaway has ended, or until the bot restarts.
- `.ga reroll <id>` rerolls the winner on the completed giveaway. This only works for 24 hours after the giveaway
has ended, or until the bot restarts.
- Users can join the giveaway by adding a :tada: reaction
- Added Todo Commands
- `.todo add <name>` - adds a new todo
@@ -370,7 +422,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- `.todo edit <id> <new message>` - edits a todo item message
- `.todo show <id>` - Shows the text of the specified todo item
- In addition to that, there are also Todo archive commands
- `.todo archive add <name>` - adds all current todos (completed and not completed) to the archived list, your current todo list will become cleared
- `.todo archive add <name>` - adds all current todos (completed and not completed) to the archived list, your
current todo list will become cleared
- `.todo archive list` - lists all your archived todo lists
- `.todo archive show <id>` - shows the todo items from one of your archived lists
- `.todo archive delete <id>` - deletes and archived todo list
@@ -389,8 +442,10 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Changed
- Users who have manage messages perm in the channel will now be excluded from link and invite filtering (`.sfi` and `.sfl`)
- `.send` command should work consistently and correctly now. You can have targets from other shards too. The usage has been changed. refer to `.h .send` for more info
- Users who have manage messages perm in the channel will now be excluded from link and invite filtering (`.sfi`
and `.sfl`)
- `.send` command should work consistently and correctly now. You can have targets from other shards too. The usage has
been changed. refer to `.h .send` for more info
- `.serverinfo` no longer takes a server name. It only takes an id or no arguments
- You can now target a different channel with .repeat
- `.cmds <module name>`, `.cmds <group name` and `.mdls` looks better
@@ -402,7 +457,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Fixed
- `.feed` should now correctly accept (and show) the message which can be passed as the third parameter
- `.say` will now correctly report errors if the user or the bot don't have sufficent perms to send a message in the targeted channel
- `.say` will now correctly report errors if the user or the bot don't have sufficent perms to send a message in the
targeted channel
- Fixed `.invitelist` not paginating correctly
- `.serverinfo` will now correctly work for other shards
- `.send` will now correctly work for other shards
@@ -420,15 +476,17 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
## [4.3.22] - 23.04.2024
### Added
- Added `.setbanner` command (thx cata)
### Fixed
- Fixed pagination error due to a missing emoji
- Fixed pagination error due to a missing emoji
## [4.3.21] - 19.04.2024
### Fixed
- Possible fix for a duplicate in `.h bank`
- Fixed `.stock` command
- Fixed `.clubapply` and `.clubaccept`
@@ -437,14 +495,17 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
## [4.3.20] - 20.01.2024
### Fixed
- Fixed `.config searches followedStreams.maxCount` not working
## [4.3.19] - 20.01.2024
### Added
- Added `followedStreams.maxCount` to `searches.yml` which lets bot owners change the default of 10 per server
### Changed
- Improvements to GPT ChatterBot (thx alexandra)
- Add a personality prompt to tweak the way chatgpt bot behaves
- Added Chat history support to chatgpt ChatterBot
@@ -467,7 +528,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- Fixed `icon_url` when using `.showembed`
- Fixed `.quoteshow` not showing sometimes (thx Cata)
- Notifications will no longer be sent if dms are off when using `.give`
- Users should no longer be able to apply to clubs while in a club already (especially not to the same club they're already in)
- Users should no longer be able to apply to clubs while in a club already (especially not to the same club they're
already in)
### Removed
@@ -566,10 +628,12 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Changed
- .meload and .meunload are now case sensitive. Previously loaded medusae may need to be reloaded or data/medusae/medusa.yml may need to be edited manually
- .meload and .meunload are now case sensitive. Previously loaded medusae may need to be reloaded or
data/medusae/medusa.yml may need to be edited manually
- Several club related command have their error messages improved
- Updated help text for .antispam and .antiraid
- You can now specify time and date (time is optional) in `.remind` command instead of relative time, in the format `HH:mm dd.MM.YYYY`
- You can now specify time and date (time is optional) in `.remind` command instead of relative time, in the
format `HH:mm dd.MM.YYYY`
- OwnerId will be automatically added to `creds.yml` at bot startup if it's missing
### Fixed
@@ -629,13 +693,15 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Added
- Added `.exprdelserv` (.exds) to completement .exas. Deletes an expression on the current server and is susceptible to .dpo, unlike .exd
- Added `.exprdelserv` (.exds) to completement .exas. Deletes an expression on the current server and is susceptible to
.dpo, unlike .exd
- Added `.shopreq` which lets you set role requirement for specific shop items
- Added `.shopbuy` alias to `.buy`
### Fixed
- Fixed `.convertlist` showing currencies twice (this may not apply to existing users and it may require you to manually remove all currencies from units.json)
- Fixed `.convertlist` showing currencies twice (this may not apply to existing users and it may require you to manually
remove all currencies from units.json)
### Removed
@@ -645,9 +711,12 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Added
- Added `.expraddserver` (.exas) which will server as a server-only alternative to '.exa' in case users want to override default Admin permissions with .dpo
- Added .banprune command which sets how many days worth of messages will be pruned when bot (soft)bans a person either through a command or another punishment feature.
- Added .qdelauth - Delete all quotes by the specified author on this server. If you target yourself - no permission required
- Added `.expraddserver` (.exas) which will server as a server-only alternative to '.exa' in case users want to override
default Admin permissions with .dpo
- Added .banprune command which sets how many days worth of messages will be pruned when bot (soft)bans a person either
through a command or another punishment feature.
- Added .qdelauth - Delete all quotes by the specified author on this server. If you target yourself - no permission
required
- Added `.timeout` command
- Added an option to award currency based on received xp
@@ -705,7 +774,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- Possibly fixed .trivia not stopping bug
- Fixed very low payout rate on `.betroll`
- Fixed an issue with youtube song resolver which caused invalid data to be cached
- Added client id to the cache key as a potential fix for VoiceXp 'bug'. The solution may be to use different redis instances for each bot, or to switch from botCache: from 'redis' to 'memory' in creds.yml
- Added client id to the cache key as a potential fix for VoiceXp 'bug'. The solution may be to use different redis
instances for each bot, or to switch from botCache: from 'redis' to 'memory' in creds.yml
- Bot owner should now be able to buy items from the xpshop when patron requirement is set
- Fixed youtube-dl caching invalid data. Please use yt-dlp instead
@@ -737,10 +807,12 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- multipliers < 1 are considered losses, > 1 considered wins
- Added `.betdraw` command which lets you guess red/black and/or high/low for a random card
- They payouts are very good, but seven always loses
- Added `.lula` command. Plays the same as `.wof` but looks much nicer, and is easily customizable from gambling.yml without any changes to the sourcecode needed.
- Added `.lula` command. Plays the same as `.wof` but looks much nicer, and is easily customizable from gambling.yml
without any changes to the sourcecode needed.
- Added `.repeatskip` command which makes the next repeat trigger not post anything
- Added `.linkonly` which will make the bot only allow link posts in the channel. Exclusive with `.imageonly`
- Added release notifications. Bot owners will now receive new release notifications in dms if they have `checkForUpdates` set to `true` in data/bot.yml
- Added release notifications. Bot owners will now receive new release notifications in dms if they
have `checkForUpdates` set to `true` in data/bot.yml
- You can also configure it via `.conf bot checkfor
- updates <true/false>`
- Added `.xpshop` which lets bot owners add xp backgrounds and xp frames for sale by configuring `data/xp.yml`
@@ -808,7 +880,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Fixed
- Fixed elipsis character issue with aliases/quotes. You should now be able to set an elipsis to be an alias of `.quoteprint`
- Fixed elipsis character issue with aliases/quotes. You should now be able to set an elipsis to be an alias
of `.quoteprint`
## [4.2.13] - 30.06.2022
@@ -874,7 +947,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
### Fixed
- Fixed `.crypto`, you will still need coinmarketcapApiKey in `creds.yml` in order to make it run consistently as the key is shared
- Fixed `.crypto`, you will still need coinmarketcapApiKey in `creds.yml` in order to make it run consistently as the
key is shared
## [4.2.3] - 17.06.2022
@@ -927,7 +1001,8 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
invidiousInstances: []
```
- Added new properties to `creds.yml`. google -> searchId and google -> searchImageId.
- These properties are used as `cx` (google api query parameter) in case you've setup your `data/searches.yml` to use the official google api.
- These properties are used as `cx` (google api query parameter) in case you've setup your `data/searches.yml` to use
the official google api.
`searchId` is used for web search
`searchimageId` is used for image search
```yml
@@ -938,12 +1013,15 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- Check `creds_example.yml` for comments explaining how to obtain them.
#### Patronage system added
- Added `data/patron.yml` for configuration
- Implemented only for patreon so far
- Patreon subscription code completely rewritten
- Users who pledge on patreon get benefits based on the amount they pledged
- Public nadeko only. But selfhosters can adapt it to their own patreon pages by configuring their patreon credentials in `creds.yml` and enabling the system in `data/patron.yml` file.
- Most of the patronage system strings are hardcoded atm, so if you wish to use this system on selfhosts, you will have to modify the source
- Public nadeko only. But selfhosters can adapt it to their own patreon pages by configuring their patreon credentials
in `creds.yml` and enabling the system in `data/patron.yml` file.
- Most of the patronage system strings are hardcoded atm, so if you wish to use this system on selfhosts, you will
have to modify the source
- Pledge amounts are split into tiers. This is not configurable atm.
- Tier I - 1$ - 4.99$ a month
- Tier V - 5$ - 9.99$ a month
@@ -953,12 +1031,14 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
- Tier C - 100$+ a month
- Rewards and command quotas for each of the tiers are configurable
- Limitations to certain features are also configurable. ex:
```yml
quotas:
features:
"rero:max_count":
x: 50
```
- ^ this setting would set the maximum number of reaction roles to be 50 for a user who is in Patron Tier X
- Read the comments in the .yml file for (much) more info
- Quota system allows the owner to set up hourly, daily and monthly quota usage for each tier
@@ -969,10 +1049,12 @@ quotas:
- If you're enabling patron system for a selfhost, you will want to edit it
Added `.patron` and `.patronmessage` commands
- `.patron` checks your patronage status, and quotas. Requires patron system to be enabled.
- `.patronmessage` (owner only) sends message to all patrons with the specified tier or higher. Supports embeds
- Added a fake `.cmdcd` command `cleverbot:response` which can be used to limit how often users can talk to the cleverbot.
- Added a fake `.cmdcd` command `cleverbot:response` which can be used to limit how often users can talk to the
cleverbot.
### Changed
@@ -983,26 +1065,34 @@ Added `.patron` and `.patronmessage` commands
- Added interaction explaining selfhosting
- `.google` reimplemented. It now has 2 modes configurable in `data/searches.yml` under the `webSearchengine` property
- If set to `google`, official custom search api will be used. You will need to set googleapikey and google.searchId in `creds.yml`
- if set to `searx` one of the instances specified in the `searxInstances:` property will be randomly chosen for each request
- If set to `google`, official custom search api will be used. You will need to set googleapikey and google.searchId
in `creds.yml`
- if set to `searx` one of the instances specified in the `searxInstances:` property will be randomly chosen for
each request
- instances must have `format=json` allowed (public ones usually don't allow it)
- instances are specified as a fully qualified url, example: `https://my.cool.searx.instance.io`
- `.image` reimplemented. Same as `.google` - it uses either `google` official api (in which case it uses `google.searchImageId` from `creds.yml`) or `searx`
- `.image` reimplemented. Same as `.google` - it uses either `google` official api (in which case it
uses `google.searchImageId` from `creds.yml`) or `searx`
- `.youtube` reimplemented. It will use a `ytProvider:` property from `data/searches.yml` to determine how to retrieve results
- `ytdataapi` will use the official google api (requires `GoogleApiKey` specified in `creds.yml`) and YoutubeDataApi enabled in the dev console
- `ytdl` will use `youtube-dl` program from the host machine. It must be downloaded and it's location must be added to path env variable.
- `.youtube` reimplemented. It will use a `ytProvider:` property from `data/searches.yml` to determine how to retrieve
results
- `ytdataapi` will use the official google api (requires `GoogleApiKey` specified in `creds.yml`) and YoutubeDataApi
enabled in the dev console
- `ytdl` will use `youtube-dl` program from the host machine. It must be downloaded and it's location must be added
to path env variable.
- `ytdlp` will use `yt-dlp` program from the host machine. Same as `youtube-dl` - must be in path env variable.
- `invidious` will use one of invidious instances specified in the `invidiousInstances` property. Very good.
- `.google`, `.youtube` and `.image` moved to the new Search group
Note: Results of each `.youtube` query will be cached for 1 hour to improve perfomance
- Removed 30 second `.ping` ratelimit on public nadeko
- xp image generation changes
- In case you have default settings, your xp image will look slightly different
- If you've modified xp_template.json, your xp image might look broken. Your old template will be saved in xp_template.json.old
- If you've modified xp_template.json, your xp image might look broken. Your old template will be saved in
xp_template.json.old
- Xp number outline is now slightly thicker
- Xp number will now have Center vertical and horizontal alignment
- LastLevelUp no longer supported
@@ -1066,7 +1156,8 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- Embed arrays use color hex values instead of an integer
- Old embed format will still work
- There shouldn't be any breaking changes
- Added `.stondel` command which, when toggled, will make the bot delete online stream messages on the server when the stream goes offline
- Added `.stondel` command which, when toggled, will make the bot delete online stream messages on the server when the
stream goes offline
- Added a simple bank system.
- Users can deposit, withdraw and check the balance of their currency in the bank.
- Users can't check other user's bank balances.
@@ -1092,7 +1183,6 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- Bot will now support much higher XP values for global and server levels
- [dev] Small change and generation perf improvement for the localized response strings
### Fixed
- Fixed `.deletexp` command
@@ -1111,7 +1201,8 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- NadekoBot now supports mysql, postgresql and sqlite
- To change the db nadeko will use, simply change the `db type` in `creds.yml`
- There is no migration code right now, which means that if you want to switch to another system you'll either have to manually export/import your database or start fresh
- There is no migration code right now, which means that if you want to switch to another system you'll either have
to manually export/import your database or start fresh
- Medusa system
- A massive new feature which allows developers to create custom modules/plugins/cogs
- They can be load/unloaded/updated at runtime without restarting the bot
@@ -1121,9 +1212,11 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- Minor club rework
- Clubs names are now case sensitive (owo and OwO can be 2 different clubs)
- Removed discriminators
- Current discriminators which are greater than 1 are appended to clubnames to avoid duplicates, you can rename your club with `.clubrename` to remove it
- Current discriminators which are greater than 1 are appended to clubnames to avoid duplicates, you can rename
your club with `.clubrename` to remove it
- Most of the clubs with #1 discriminator no longer have it (For example MyClub#1 will now just be MyClub)
- [dev] A lot of refactoring and slight functionality changes within Nadeko's behavior system and command handler which were required in order to support the medusa system
- [dev] A lot of refactoring and slight functionality changes within Nadeko's behavior system and command handler which
were required in order to support the medusa system
### Removed
@@ -1173,6 +1266,7 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
## [4.0.0] - 02.03.2022
### Added
- Added `.deleteemptyservers` command
- Added `.curtr <id>` which lets you see full information about one of your own transactions with the specified id
- Added trovo.live support for stream notifications (`.stadd`)
@@ -1180,18 +1274,24 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- Added 3 new settings to `data/gambling.yml` to control it:
- waifu.decay.percent - How much % to subtract from unclaimed waifu
- waifu.decay.hourInterval - How often to decay the price
- waifu.decay.minPrice - Unclaimed waifus with price lower than the one specified here will not be affected by the decay
- Added `currency.transactionsLifetime` to `data/gambling.yml` Any transaction older than the number of days specified will be automatically deleted
- waifu.decay.minPrice - Unclaimed waifus with price lower than the one specified here will not be affected by
the decay
- Added `currency.transactionsLifetime` to `data/gambling.yml` Any transaction older than the number of days specified
will be automatically deleted
- Added `.stock` command to check stock prices and charts
- Re-added `.qap / .queueautoplay`
### Changed
- CustomReactions module (and customreactions db table) has been renamed to Expressions.
- This was done to remove confusion about how it relates to discord Reactions (it doesn't, it was created and named before discord reactions existed)
- This was done to remove confusion about how it relates to discord Reactions (it doesn't, it was created and named
before discord reactions existed)
- Expression command now start with ex/expr and end with the name of the action or setting.
- For example `.exd` (`.dcr`) is expression delete, `.exa` (`.acr`)
- Permissions (`.lp`) be automatically updated with "ACTUALEXPRESSIONS", "EXPRESSIONS" instead of "ACTUALCUSTOMREACTIONS" and "CUSTOMREACTIONS"
- Permissions for `.ecr` (now `.exe`), `.scr` (now `.exs`), `.dcr` (now `.exd`), `.acr` (now `.exa`), `.lcr` (now `.exl`) will be automatically updated
- Permissions (`.lp`) be automatically updated with "ACTUALEXPRESSIONS", "EXPRESSIONS" instead of "
ACTUALCUSTOMREACTIONS" and "CUSTOMREACTIONS"
- Permissions for `.ecr` (now `.exe`), `.scr` (now `.exs`), `.dcr` (now `.exd`), `.acr` (now `.exa`), `.lcr` (
now `.exl`) will be automatically updated
- If you have custom permissions for other CustomReaction commands
- Some of the old aliases like `.acr` `.dcr` `.lcr` and a few others have been kept
- Currency output format improvement (will use guild locale now for some commands)
@@ -1210,6 +1310,7 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- [dev] Moved FilterWordsChannelId to a separate table
### Fixed
- Fixed twitch stream notifications (rewrote it to use the new api)
- Fixed an extra whitespace in usage part of command help if the command has no arguments
- Possible small fix for `.prune` ratelimiting
@@ -1221,8 +1322,10 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- Fixed embed color when disabling `.antialt`
### Removed
- Removed `.bce` - use `.config` or `.config bot` specifically for bot config
- Removed obsolete placeholders: %users% %servers% %userfull% %username% %userdiscrim% %useravatar% %id% %uid% %chname% %cid% %sid% %members% %server_time% %shardid% %time% %mention%
- Removed obsolete placeholders: %users% %servers% %userfull% %username% %userdiscrim% %useravatar% %id% %uid% %chname%
%cid% %sid% %members% %server_time% %shardid% %time% %mention%
- Removed some obsolete commands and strings
- Removed code which migrated 2.x to v3 credentials, settings, etc...
@@ -1236,6 +1339,7 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
## [3.0.12] - 06.01.2022
### Fixed
- `.smch` Fixed
- `.trans` command will now work properly with capitilized language names
- Ban message color with plain text fixed
@@ -1247,12 +1351,15 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
## [3.0.11] - 17.12.2021
### Added
- `.remindl` and `.remindrm` commands now supports optional 'server' parameter for Administrators which allows them to delete any reminder created on the server
- `.remindl` and `.remindrm` commands now supports optional 'server' parameter for Administrators which allows them to
delete any reminder created on the server
- Added slots.currencyFontColor to gambling.yml
- Added `.qexport` and `.qimport` commands which allow you to export and import quotes just like `.crsexport`
- Added `.showembed <msgid>` and `.showembed #channel <msgid>` which will show you embed json from the specified message
### Changed
- `.at` and `.atl` commands reworked
- Persist restarts
- Will now only translate non-commands
@@ -1262,55 +1369,67 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- Looks much nicer
- Bot will now reply to user messages with a translation if `del` is disabled
- Bot will make an embed with original and translated text with user avatar and name if `del` is enabled
- If the bot is unable to delete messages while having `del` enabled, it will reset back to the no-del behavior for the current session
- If the bot is unable to delete messages while having `del` enabled, it will reset back to the no-del behavior for
the current session
### Fixed
- `.crypto` now supports top 5000 coins
## [3.0.10] - 01.12.2021
### Changed
- `.warn` now supports weighted warnings
- `.warnlog` will now show current amount and total amount of warnings
### Fixed
- `.xprewsreset` now has correct permissions
### Removed
- Removed slot.numbers from `images.yml` as they're no longer used
## [3.0.9] - 21.11.2021
### Changed
- `.ea` will now use an image attachments if you omit imageUrl
### Added
- Added `.emojiadd` with 3 overloads
- `.ea :customEmoji:` which copies another server's emoji
- `.ea newName :customEmoji:` which copies emoji under a different name
- `.ea emojiName <imagelink.png>` which creates a new emoji from the specified image
- Patreon Access and Refresh Tokens should now be automatically updated once a month as long as the user has provided the necessary credentials in creds.yml file:
- Patreon Access and Refresh Tokens should now be automatically updated once a month as long as the user has provided
the necessary credentials in creds.yml file:
- `Patreon.ClientId`
- `Patreon.RefreshToken` (will also get updated once a month but needs an initial value)
- `Patreon.ClientSecret`
- `Patreon.CampaignId`
### Fixed
- Fixed an error that would show up in the console when a club image couldn't be drawn in certain circumstances
## [3.0.8] - 03.11.2021
### Added
- Created VotesApi project nad re-worked vote rewards handling
- Updated votes entries in creds.yml with explanations on how to set up vote links
### Fixed
- Fixed adding currency to users who don't exist in the database
- Memory used by the bot is now correct (thanks to kotz)
- Ban/kick will no longer fail due to too long reasons
- Fixed some fields not preserving inline after string replacements
### Changed
- `images.json` moved to `images.yml`
- Links will use the new cdn url
- Heads and Tails images will be updated if you haven't changed them already
@@ -1320,15 +1439,18 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
## [3.0.7] - 05.10.2021
### Added
- `.streamsclear` re-added. It will remove all followed streams on the server.
- `.gifts` now have 3 new ✂️ Haircut 🧻 ToiletPaper and 🥀 WiltedRose which **reduce** waifu's value
- They are called negative gifts
- They show up at the end of the `.gifts` page and are marked with a broken heart
- They have a separate multiplier (`waifu.multi.negative_gift_effect` default 0.5, changeable via `.config gambling` or `data/gambling.yml`)
- They have a separate multiplier (`waifu.multi.negative_gift_effect` default 0.5, changeable via `.config gambling`
or `data/gambling.yml`)
- When gifted, the waifu's price will be reduced by the `price * multiplier`
- Negative gifts don't show up in `.waifuinfo` nor is the record of them kept in the database
### Fixed
- Fixed `%users%` and `%shard.usercount%` placeholders not showing correct values
## [3.0.6] - 27.09.2021
@@ -1397,7 +1519,8 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- `.rero` now optionally takes a message id to which to attach the reaction roles
- Fully translated to German 🎉
- Added `.boost`, `.boostmsg` and `.boostdel` commands which allow you to have customizable messages when someone boosts your server, with auto-deletion support
- Added `.boost`, `.boostmsg` and `.boostdel` commands which allow you to have customizable messages when someone boosts
your server, with auto-deletion support
### Changed
@@ -1430,10 +1553,12 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- Explanations on how to get the keys are added as the comments
- Code cleanup
- Command attributes cleaned up
- Removed dummy Remarks and Usages attributes as hey were unused for a few patches but stayed in the code to avoid big git diffsmigration code has ran and it can be safely removed
- Removed dummy Remarks and Usages attributes as hey were unused for a few patches but stayed in the code to
avoid big git diffsmigration code has ran and it can be safely removed
- There are 2 projects: NadekoBot and NadekoBot.Coordinator
- You can directly run NadekoBot as the regular bot with one shard
- Run NadekoBot.Coordinator if you want more control over your shards and a grpc api for coordinator with which you can start, restart, kill and see status of shards
- Run NadekoBot.Coordinator if you want more control over your shards and a grpc api for coordinator with which
you can start, restart, kill and see status of shards
- Small performance improvements
- Db Migrations squashed
- A lot of cleanup all around
@@ -1447,7 +1572,8 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
### Removed
- Removed All database migrations and data (json file) migrations
- As updating to the latest 2.x version before switching over to v3 is mandated (or fresh v3 install), that means all
- As updating to the latest 2.x version before switching over to v3 is mandated (or fresh v3 install), that means
all
## [2.46.2] - 14.07.2021
@@ -1477,9 +1603,11 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- Use `.aar` to list roles which will be added
- Roles which are deleted are automatically cleaned up from `.aar`
- `.inrole` now also shows user ids
- Blacklist commands (owner only) `.ubl` `.sbl` and `.cbl` will now list blacklisted items when no argument (or a page number) is provided
- Blacklist commands (owner only) `.ubl` `.sbl` and `.cbl` will now list blacklisted items when no argument (or a page
number) is provided
- `.cmdcd` now works with customreactions too
- `.xprr` usage changed. It now takes add/rm parameter to add/remove a role ex. You can only take or remove a single role, adding and removing a role at the same level doesn't work (yet?)
- `.xprr` usage changed. It now takes add/rm parameter to add/remove a role ex. You can only take or remove a single
role, adding and removing a role at the same level doesn't work (yet?)
- example: `.xprr 5 add Member` or `.xprr 1 rm Newbie`
## [2.45.2] - 14.06.2021
@@ -1500,16 +1628,19 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
### Added
- Added many new aliases to custom reaction commands in the format ex + "action" to prepare for the future rename from CustomReactions to Expressions
- Added many new aliases to custom reaction commands in the format ex + "action" to prepare for the future rename from
CustomReactions to Expressions
- You can now `.divorce` via username#discrim even if the user no longer exists
### Changed
- DmHelpText should now have %prefix% and %bot.prefix% placeholders available
- Added squares which show enabled features for each cr in `.lcr`
- Changed CustomReactions' IDs to show, and accept base 32 unambigous characters instead of the normal database IDs (this will result in much shorter cr IDs in case you have a lot of them)
- Changed CustomReactions' IDs to show, and accept base 32 unambigous characters instead of the normal database IDs (
this will result in much shorter cr IDs in case you have a lot of them)
- Improved `.lcr` helptext to explain what's shown in the output
- `.rolecolor <color> <role>` changed to take color, then the role, to make it easier to set color for roles with multiple words without mentioning the role
- `.rolecolor <color> <role>` changed to take color, then the role, to make it easier to set color for roles with
multiple words without mentioning the role
- `.acmdcds` alias chanaged to `.cmdcds`
- `.8ball` will now cache results for a day
- `.chatmute` and `.voicemute` now support timed mutes
@@ -1526,10 +1657,13 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- Allows for quick export/import of server or global custom reactions
- Requires admin permissions for server crs, and owner for global crs
- Explanation of the fields is in the comment at the top of the `.crsexport` .yml file
- Added `.mquality` / `.musicquality` - Set encoding quality. Has 4 presets - Low, Medium, High, Highest. Default is Highest
- Added `.mquality` / `.musicquality` - Set encoding quality. Has 4 presets - Low, Medium, High, Highest. Default is
Highest
- Added `.xprewsreset` which resets all currently set xp level up rewards
- Added `.purgeuser @User` which will remove the specified from the database completely. Removed settings include: Xp, clubs, waifu, currency, etc...
- Added `.config xp txt.per_image` and xpFromImage to xp.yml - Change this config to allow xp gain from posting images. Images must be 128x128 or greater in size
- Added `.purgeuser @User` which will remove the specified from the database completely. Removed settings include: Xp,
clubs, waifu, currency, etc...
- Added `.config xp txt.per_image` and xpFromImage to xp.yml - Change this config to allow xp gain from posting images.
Images must be 128x128 or greater in size
- Added `.take <amount> <role>` to complement `.award <amount> role`
- Added **Fans** list to `.waifuinfo` which shows how many people have their affinity set to you
- Added `.antialt` which will punish any user whose account is younger than specified threshold
@@ -1543,7 +1677,8 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- Re-created GuildRepeaters table and renamed to Repeaters
- confirmation prompts will now use pending color from bot config, instead of okcolor
- `.mute` can now have up to 49 days mute to match .warnp
- `.warnlog` now has proper pagination (with reactions) and checking your own warnings past page 1 works correctly now with `.warnlog 2`
- `.warnlog` now has proper pagination (with reactions) and checking your own warnings past page 1 works correctly now
with `.warnlog 2`
### Fixed
@@ -1607,7 +1742,8 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
- Higher quality audio (no stuttering too!)
- Local tracks will now have durations if you have ffprobe installed (comes with ffmpeg)
- Bot supports joining a different vc without skipping the song if you use `.j`
- ⚠️ **DO NOT DRAG THE BOT** to another vc, as it's not properly supported atm, and you will have to do `.play` after dragging it)
- ⚠️ **DO NOT DRAG THE BOT** to another vc, as it's not properly supported atm, and you will have to do `.play`
after dragging it)
- `.j` makes the bot join your voice channel
- `.p` is now alias of play, pause is `.pause`
- `.qs` should work without google api key now for most users as it is using a custom loader
@@ -1630,4 +1766,5 @@ Note: Results of each `.youtube` query will be cached for 1 hour to improve perf
### Removed
- Removed admin requirement on `.scrm` as it didn't make sense
- Some Music commands are removed because of the complexity they bring in with little value (if you *really* want them back, you can open an issue and specify your *good* reason)
- Some Music commands are removed because of the complexity they bring in with little value (if you *really* want them
back, you can open an issue and specify your *good* reason)

View File

@@ -25,7 +25,6 @@ public static class DiscordUserExtensions
{
UserId = userId,
Username = username,
Discriminator = discrim,
AvatarId = avatarId,
TotalXp = 0,
CurrencyAmount = 0
@@ -33,7 +32,6 @@ public static class DiscordUserExtensions
old => new()
{
Username = username,
Discriminator = discrim,
AvatarId = avatarId
},
() => new()
@@ -49,8 +47,7 @@ public static class DiscordUserExtensions
() => new()
{
UserId = userId,
Username = "Unknown",
Discriminator = "????",
Username = "??Unknown",
AvatarId = string.Empty,
TotalXp = 0,
CurrencyAmount = 0

View File

@@ -7,7 +7,7 @@ public class DiscordUser : DbEntity
{
public ulong UserId { get; set; }
public string Username { get; set; }
public string Discriminator { get; set; }
// public string Discriminator { get; set; }
public string AvatarId { get; set; }
public int? ClubId { get; set; }
@@ -27,9 +27,6 @@ public class DiscordUser : DbEntity
public override string ToString()
{
if (string.IsNullOrWhiteSpace(Discriminator) || Discriminator == "0000")
return Username;
return Username + "#" + Discriminator;
}
}

View File

@@ -0,0 +1,8 @@
#nullable disable
namespace NadekoBot.Db.Models;
public class FlagTranslateChannel : DbEntity
{
public ulong GuildId { get; set; }
public ulong ChannelId { get; set; }
}

View File

@@ -73,6 +73,14 @@ public abstract class NadekoContext : DbContext
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
#region Flag Translate
modelBuilder.Entity<FlagTranslateChannel>()
.HasIndex(x => new { x.GuildId, x.ChannelId })
.IsUnique();
#endregion
#region NCanvas
modelBuilder.Entity<NCPixel>()

View File

@@ -5,6 +5,11 @@ namespace NadekoBot.Migrations;
public static class MigrationQueries
{
public static void UpdateUsernames(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("UPDATE DiscordUser SET Username = '??' + Username WHERE Discriminator = '????';");
}
public static void MigrateRero(MigrationBuilder migrationBuilder)
{
if (migrationBuilder.IsSqlite())

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,56 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace NadekoBot.Migrations.PostgreSql
{
/// <inheritdoc />
public partial class nodiscrimandflagtranslate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
MigrationQueries.UpdateUsernames(migrationBuilder);
migrationBuilder.DropColumn(
name: "discriminator",
table: "discorduser");
migrationBuilder.CreateTable(
name: "flagtranslatechannel",
columns: table => new
{
id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
guildid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
channelid = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
dateadded = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_flagtranslatechannel", x => x.id);
});
migrationBuilder.CreateIndex(
name: "ix_flagtranslatechannel_guildid_channelid",
table: "flagtranslatechannel",
columns: new[] { "guildid", "channelid" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "flagtranslatechannel");
migrationBuilder.AddColumn<string>(
name: "discriminator",
table: "discorduser",
type: "text",
nullable: true);
}
}
}

View File

@@ -751,10 +751,6 @@ namespace NadekoBot.Migrations.PostgreSql
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<string>("Discriminator")
.HasColumnType("text")
.HasColumnName("discriminator");
b.Property<bool>("IsClubAdmin")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
@@ -998,6 +994,37 @@ namespace NadekoBot.Migrations.PostgreSql
b.ToTable("filteredword", (string)null);
});
modelBuilder.Entity("NadekoBot.Db.Models.FlagTranslateChannel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("ChannelId")
.HasColumnType("numeric(20,0)")
.HasColumnName("channelid");
b.Property<DateTime?>("DateAdded")
.HasColumnType("timestamp without time zone")
.HasColumnName("dateadded");
b.Property<decimal>("GuildId")
.HasColumnType("numeric(20,0)")
.HasColumnName("guildid");
b.HasKey("Id")
.HasName("pk_flagtranslatechannel");
b.HasIndex("GuildId", "ChannelId")
.IsUnique()
.HasDatabaseName("ix_flagtranslatechannel_guildid_channelid");
b.ToTable("flagtranslatechannel", (string)null);
});
modelBuilder.Entity("NadekoBot.Db.Models.FollowedStream", b =>
{
b.Property<int>("Id")

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NadekoBot.Migrations
{
/// <inheritdoc />
public partial class nodiscrimandflagtranslate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
MigrationQueries.UpdateUsernames(migrationBuilder);
migrationBuilder.DropColumn(
name: "Discriminator",
table: "DiscordUser");
migrationBuilder.CreateTable(
name: "FlagTranslateChannel",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
GuildId = table.Column<ulong>(type: "INTEGER", nullable: false),
ChannelId = table.Column<ulong>(type: "INTEGER", nullable: false),
DateAdded = table.Column<DateTime>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_FlagTranslateChannel", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_FlagTranslateChannel_GuildId_ChannelId",
table: "FlagTranslateChannel",
columns: new[] { "GuildId", "ChannelId" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "FlagTranslateChannel");
migrationBuilder.AddColumn<string>(
name: "Discriminator",
table: "DiscordUser",
type: "TEXT",
nullable: true);
}
}
}

View File

@@ -560,9 +560,6 @@ namespace NadekoBot.Migrations
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<string>("Discriminator")
.HasColumnType("TEXT");
b.Property<bool>("IsClubAdmin")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
@@ -743,6 +740,29 @@ namespace NadekoBot.Migrations
b.ToTable("FilteredWord");
});
modelBuilder.Entity("NadekoBot.Db.Models.FlagTranslateChannel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<ulong>("ChannelId")
.HasColumnType("INTEGER");
b.Property<DateTime?>("DateAdded")
.HasColumnType("TEXT");
b.Property<ulong>("GuildId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("GuildId", "ChannelId")
.IsUnique();
b.ToTable("FlagTranslateChannel");
});
modelBuilder.Entity("NadekoBot.Db.Models.FollowedStream", b =>
{
b.Property<int>("Id")

View File

@@ -453,7 +453,6 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
{
x.UserId,
x.Username,
x.Discriminator
})
.Where(x => users.Select(y => y.Id).Contains(x.UserId))
.ToArrayAsyncEF();
@@ -465,12 +464,11 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
UserId = x.Id,
AvatarId = x.AvatarId,
Username = x.Username,
Discriminator = x.Discriminator
});
var added = (await ctx.BulkCopyAsync(usersToAdd)).RowsCopied;
var toUpdateUserIds = presentDbUsers
.Where(x => x.Username == "Unknown" && x.Discriminator == "????")
.Where(x => x.Username.StartsWith("??"))
.Select(x => x.UserId)
.ToArray();
@@ -481,7 +479,6 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
.UpdateAsync(x => new DiscordUser()
{
Username = user.Username,
Discriminator = user.Discriminator,
// .award tends to set AvatarId and DateAdded to NULL, so account for that.
AvatarId = user.AvatarId,

View File

@@ -603,7 +603,7 @@ public class WaifuService : INService, IReadyExecutor
.Where(wi => wi.ClaimerId == waifuId)
.Select(wi => wi.WaifuId)
.Contains(x.Id))
.Select(x => $"{x.Username}#{x.Discriminator}")
.Select(x => x.Username)
.ToListAsyncEF();
}
@@ -615,7 +615,7 @@ public class WaifuService : INService, IReadyExecutor
.Where(wi => wi.AffinityId == waifuId)
.Select(wi => wi.WaifuId)
.Contains(x.Id))
.Select(x => $"{x.Username}#{x.Discriminator}")
.Select(x => x.Username)
.ToListAsyncEF();
}

View File

@@ -42,15 +42,12 @@ public static class WaifuExtensions
{
Affinity = x.Affinity == null
? null
: x.Affinity.Username
+ (x.Affinity.Discriminator != "0000" ? "#" + x.Affinity.Discriminator : ""),
: x.Affinity.Username,
ClaimerName =
x.Claimer == null
? null
: x.Claimer.Username
+ (x.Claimer.Discriminator != "0000" ? "#" + x.Claimer.Discriminator : ""),
WaifuName = x.Waifu.Username
+ (x.Waifu.Discriminator != "0000" ? "#" + x.Waifu.Discriminator : ""),
: x.Claimer.Username,
WaifuName = x.Waifu.Username,
Price = x.Price
})
.ToListAsyncEF();
@@ -62,7 +59,7 @@ public static class WaifuExtensions
public static ulong GetWaifuUserId(this DbSet<WaifuInfo> waifus, ulong ownerId, string name)
=> waifus.AsQueryable()
.AsNoTracking()
.Where(x => x.Claimer.UserId == ownerId && x.Waifu.Username + "#" + x.Waifu.Discriminator == name)
.Where(x => x.Claimer.UserId == ownerId && x.Waifu.Username == name)
.Select(x => x.Waifu.UserId)
.FirstOrDefault();
@@ -100,7 +97,7 @@ public static class WaifuExtensions
ctx.Set<DiscordUser>()
.AsQueryable()
.Where(u => u.UserId == userId)
.Select(u => u.Username + "#" + u.Discriminator)
.Select(u => u.Username)
.FirstOrDefault(),
AffinityCount =
ctx.Set<WaifuUpdate>()
@@ -112,14 +109,14 @@ public static class WaifuExtensions
ctx.Set<DiscordUser>()
.AsQueryable()
.Where(u => u.Id == w.AffinityId)
.Select(u => u.Username + "#" + u.Discriminator)
.Select(u => u.Username)
.FirstOrDefault(),
ClaimCount = ctx.Set<WaifuInfo>().AsQueryable().Count(x => x.ClaimerId == w.WaifuId),
ClaimerName =
ctx.Set<DiscordUser>()
.AsQueryable()
.Where(u => u.Id == w.ClaimerId)
.Select(u => u.Username + "#" + u.Discriminator)
.Select(u => u.Username)
.FirstOrDefault(),
DivorceCount =
ctx.Set<WaifuUpdate>()

View File

@@ -29,7 +29,7 @@ public partial class Games
if (!await nunchi.Join(ctx.User.Id, ctx.User.ToString()))
return;
await Response().Error(strs.nunchi_joined(nunchi.ParticipantCount)).SendAsync();
await Response().Confirm(strs.nunchi_joined(nunchi.ParticipantCount)).SendAsync();
return;
}

View File

@@ -122,11 +122,11 @@ public sealed class CurrencyRewardService : INService, IReadyExecutor
var dollarValue = pledgeCents / 100;
percentBonus = dollarValue switch
{
>= 100 => 100,
>= 50 => 50,
>= 20 => 20,
>= 10 => 10,
>= 5 => 5,
>= 100 => 20,
>= 50 => 10,
>= 20 => 5,
>= 10 => 3,
>= 5 => 1,
_ => 0
};
return (long)(modifiedAmount * (1 + (percentBonus / 100.0f)));

View File

@@ -0,0 +1,191 @@
#nullable disable
using LinqToDB;
using LinqToDB.EntityFrameworkCore;
using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Db.Models;
using System.Collections.Frozen;
namespace NadekoBot.Modules.Searches;
public sealed partial class FlagTranslateService : IReadyExecutor, INService
{
private readonly IBotCreds _creds;
private readonly DiscordSocketClient _client;
private readonly TranslateService _ts;
private readonly IMessageSenderService _sender;
private IReadOnlyDictionary<string, string> _supportedFlags;
private readonly DbService _db;
private ConcurrentHashSet<ulong> _enabledChannels;
private readonly IBotCache _cache;
// disallow same message being translated multiple times to the same language
private readonly ConcurrentHashSet<(ulong, string)> _msgLangs = new();
public FlagTranslateService(
IBotCreds creds,
DiscordSocketClient client,
TranslateService ts,
IMessageSenderService sender,
DbService db,
IBotCache cache)
{
_creds = creds;
_client = client;
_ts = ts;
_sender = sender;
_db = db;
_cache = cache;
}
public async Task OnReadyAsync()
{
_supportedFlags = COUNTRIES
.Split('\n')
.Select(x => x.Split(' '))
.ToDictionary(x => x[0], x => x[1].TrimEnd())
.ToFrozenDictionary();
await using (var uow = _db.GetDbContext())
{
_enabledChannels = (await uow.GetTable<FlagTranslateChannel>()
.Where(x => Linq2DbExpressions.GuildOnShard(x.GuildId,
_creds.TotalShards,
_client.ShardId))
.Select(x => new
{
x.ChannelId,
x.GuildId
})
.ToListAsyncLinqToDB())
.Select(x => x.ChannelId)
.ToHashSet()
.ToConcurrentSet();
}
_client.ReactionAdded += OnReactionAdded;
var periodicCleanup = new PeriodicTimer(TimeSpan.FromHours(24));
while (await periodicCleanup.WaitForNextTickAsync())
{
_msgLangs.Clear();
}
}
private const int FLAG_START = 127462;
private static TypedKey<bool> CdKey(ulong userId)
=> new($"flagtranslate:{userId}");
private Task OnReactionAdded(
Cacheable<IUserMessage, ulong> arg1,
Cacheable<IMessageChannel, ulong> arg2,
SocketReaction reaction)
{
if (!_enabledChannels.Contains(reaction.Channel.Id))
return Task.CompletedTask;
var runes = reaction.Emote.Name.EnumerateRunes();
if (!runes.MoveNext()
|| runes.Current is not { Value: >= 127462 and <= 127487 } l1
|| !runes.MoveNext()
|| runes.Current is not { Value: >= 127462 and <= 127487 } l2)
{
return Task.CompletedTask;
}
_ = Task.Run(async () =>
{
if (reaction.Channel is not SocketTextChannel tc)
return;
var user = await ((IGuild)tc.Guild).GetUserAsync(reaction.UserId);
if (user is null)
return;
if (!user.GetPermissions(tc).SendMessages)
return;
if (!tc.Guild.CurrentUser.GetPermissions(tc).SendMessages
|| !tc.Guild.CurrentUser.GetPermissions(tc).EmbedLinks)
{
await Disable(tc.Guild.Id, tc.Id);
return;
}
var c1 = (char)(l1.Value - FLAG_START + 65);
var c2 = (char)(l2.Value - FLAG_START + 65);
var code = $"{c1}{c2}".ToUpper();
if (!_supportedFlags.TryGetValue(code, out var lang))
return;
if (!_msgLangs.Add((reaction.MessageId, lang)))
return;
var result = await _cache.GetAsync(CdKey(reaction.UserId));
if (result.TryPickT0(out _, out _))
return;
await _cache.AddAsync(CdKey(reaction.UserId), true, TimeSpan.FromSeconds(5));
var msg = await arg1.GetOrDownloadAsync();
var response = await _ts.Translate("", lang, msg.Content).ConfigureAwait(false);
await msg.ReplyAsync(embed: _sender.CreateEmbed()
.WithOkColor()
.WithFooter(user.ToString() ?? reaction.UserId.ToString(),
user.RealAvatarUrl().ToString())
.WithDescription(response)
.WithAuthor(reaction.Emote.ToString())
.Build(),
allowedMentions: AllowedMentions.None
);
});
return Task.CompletedTask;
}
public async Task Disable(ulong guildId, ulong tcId)
{
if (!_enabledChannels.TryRemove(tcId))
return;
await using var uow = _db.GetDbContext();
await uow.GetTable<FlagTranslateChannel>()
.Where(x => x.GuildId == guildId
&& x.ChannelId == tcId)
.DeleteAsync();
}
public async Task<bool> Toggle(ulong guildId, ulong tcId)
{
if (_enabledChannels.Contains(tcId))
{
await Disable(guildId, tcId);
return false;
}
await Enable(guildId, tcId);
return true;
}
public async Task Enable(ulong guildId, ulong tcId)
{
if (!_enabledChannels.Add(tcId))
return;
await using var uow = _db.GetDbContext();
await uow.GetTable<FlagTranslateChannel>()
.InsertAsync(() => new FlagTranslateChannel
{
GuildId = guildId,
ChannelId = tcId
});
}
}

View File

@@ -0,0 +1,73 @@
namespace NadekoBot.Modules.Searches;
public partial class FlagTranslateService
{
private const string COUNTRIES = """
CN zh
IN hi
US en
ID id
PK ur
BR pt
NG ha
BD bn
RU ru
JP ja
MX es
PH tl
VN vi
EG ar
ET am
DE de
IR fa
TR tr
TH th
FR fr
CD fr
MM my
UG en
MZ pt
ZA zu
CO es
BG bg
HR hr
MY ms
NL nl
RO ro
CZ cs
GR el
SK sk
PT pt
KR ko
IT it
ES es
RS sr
TN ar
PL pl
SD ar
CM fr
SN fr
ML fr
NE ha
BI fr
AO pt
AF ps
MA ar
DZ ar
GB en
AR es
ZW ny
KE sw
GH en
SA ar
IL he
IQ ar
UA ua
LY ar
KW ar
OM ar
YE ar
AL sq
AE ar
""";
}

View File

@@ -44,12 +44,10 @@ public sealed class TranslateService : ITranslateService, IExecNoCommand, IReady
foreach (var c in cs)
{
_atcs[c.ChannelId] = c.AutoDelete;
_users[c.ChannelId] =
new(c.Users.ToDictionary(x => x.UserId, x => (x.Source.ToLower(), x.Target.ToLower())));
_users[c.ChannelId] = new(c.Users.ToDictionary(x => x.UserId, x => (x.Source.ToLower(), x.Target.ToLower())));
}
}
public async Task ExecOnNoCommandAsync(IGuild guild, IUserMessage msg)
{
if (string.IsNullOrWhiteSpace(msg.Content))
@@ -95,7 +93,7 @@ public sealed class TranslateService : ITranslateService, IExecNoCommand, IReady
}
}
public async Task<string> Translate(string source, string target, string text = null)
public async Task<string> Translate(string source, string target, string text)
{
if (string.IsNullOrWhiteSpace(text))
throw new ArgumentException("Text is empty or null", nameof(text));

View File

@@ -6,6 +6,14 @@ public partial class Searches
[Group]
public partial class TranslateCommands : NadekoModule<ITranslateService>
{
private readonly FlagTranslateService _flagSvc;
public TranslateCommands(FlagTranslateService flagSvc)
{
_flagSvc = flagSvc;
}
public enum AutoDeleteAutoTranslate
{
Del,
@@ -91,5 +99,18 @@ public partial class Searches
await Response().Embed(eb).SendAsync();
}
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(ChannelPermission.ManageChannels)]
[BotPerm(ChannelPermission.SendMessages | ChannelPermission.EmbedLinks)]
public async Task TranslateFlags()
{
var enabled = await _flagSvc.Toggle(ctx.Guild.Id, ctx.Channel.Id);
if (enabled)
await Response().Confirm(strs.trfl_enabled).SendAsync();
else
await Response().Confirm(strs.trfl_disabled).SendAsync();
}
}
}

View File

@@ -28,6 +28,8 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, INService
GetXpSettingsRequest request,
ServerCallContext context)
{
await Task.Yield();
var guild = _client.GetGuild(request.GuildId);
if (guild is null)
@@ -54,6 +56,26 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, INService
Name = guild.GetRole(x)?.Name ?? "????"
})));
var curRews = _xp.GetCurrencyRewards(request.GuildId);
var roleRews = _xp.GetRoleRewards(request.GuildId);
var rews = curRews.Select(x => new RewItemReply()
{
Level = x.Level,
Type = "Currency",
Value = x.Amount.ToString()
});
rews = rews.Concat(roleRews.Select(x => new RewItemReply()
{
Level = x.Level,
Type = "Role",
Value = guild.GetRole(x.RoleId)?.ToString() ?? x.RoleId.ToString()
}))
.OrderBy(x => x.Level);
reply.Rewards.AddRange(rews);
reply.ServerExcluded = isServerExcluded;
return reply;

View File

@@ -201,9 +201,12 @@ public sealed partial class GoogleApiService : IGoogleApiService, INService
{
string text;
if (!Languages.ContainsKey(sourceLanguage) || !Languages.ContainsKey(targetLanguage))
if (!Languages.ContainsKey(targetLanguage))
throw new ArgumentException(nameof(sourceLanguage) + "/" + nameof(targetLanguage));
if (string.IsNullOrWhiteSpace(sourceLanguage) || !Languages.ContainsKey(sourceLanguage))
sourceLanguage = "auto";
var url = new Uri(string.Format(
"https://translate.googleapis.com/translate_a/single?client=gtx&sl={0}&tl={1}&dt=t&q={2}",
@@ -223,7 +226,7 @@ public sealed partial class GoogleApiService : IGoogleApiService, INService
private string ConvertToLanguageCode(string language)
{
Languages.TryGetValue(language, out var mode);
return mode;
return string.IsNullOrWhiteSpace(mode) ? language : mode;
}
}

View File

@@ -154,7 +154,6 @@ public sealed partial class GoogleApiService
}
Languages = langs;
}
}

View File

@@ -77,8 +77,7 @@ public class DefaultWallet : IWallet
.InsertOrUpdateAsync(() => new()
{
UserId = userId,
Username = "Unknown",
Discriminator = "????",
Username = "??Unknown",
CurrencyAmount = amount,
},
(old) => new()

View File

@@ -193,7 +193,7 @@ public sealed class StatsService : IStatsService, IReadyExecutor, INService
Id = g.Id,
IconUrl = g.IconUrl,
Name = g.Name,
Owner = (await ig.GetUserAsync(g.OwnerId))?.Username ?? "Unknown",
Owner = (await ig.GetUserAsync(g.OwnerId))?.Username ?? "??Unknown",
OwnerId = g.OwnerId,
CreatedAt = g.CreatedAt.UtcDateTime,
VoiceChannels = g.VoiceChannels.Count,

View File

@@ -1445,3 +1445,8 @@ ncpixel:
- ncgp
ncreset:
- ncreset
translateflags:
- translateflags
- trfl
- fltr
- transflags

View File

@@ -4634,3 +4634,11 @@ ncreset:
- ''
params:
- { }
translateflags:
desc: |-
Toggles translate flags on the current channel.
Reacting with a country flag will translate the message to that country's language.
ex:
- ''
params:
- { }

View File

@@ -1111,5 +1111,7 @@
"nc_hint": "Use `{0}nczoom x y` command to zoom in. Image is {1}x{2} pixels.",
"nc_insuff_payment": "Invalid payment.",
"invalid_img_size": "Image must to be {0}x{1} pixels.",
"no_attach_found": "No attachment found. Please send the image along with this command."
"no_attach_found": "No attachment found. Please send the image along with this command." ,
"trfl_enabled": "Flag translation enabled on this channel. Reacting to a message with a flag will translate it to that language.",
"trfl_disabled": "Flag translation disabled."
}