2024-09-20 23:23:21 +12:00
#nullable disable
using EllieBot.Common.Yml ;
namespace EllieBot.Common ;
2024-10-05 11:44:44 +13:00
public sealed class Creds : IBotCreds
2024-09-20 23:23:21 +12:00
{
[Comment("""DO NOT CHANGE""")]
2025-03-29 21:05:43 +13:00
public int Version { get ; set ; } = 21 ;
2024-09-20 23:23:21 +12:00
[Comment("""Bot token. Do not share with anyone ever -> https://discordapp.com/developers/applications/""")]
public string Token { get ; set ; }
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
List of Ids of the users who have bot owner permissions
* * DO NOT ADD PEOPLE YOU DON ' T TRUST * *
"" ")]
2024-09-20 23:23:21 +12:00
public ICollection < ulong > OwnerIds { get ; set ; }
2024-10-03 17:24:13 +13:00
[ Comment (
"Keep this on 'true' unless you're sure your bot shouldn't use privileged intents or you're waiting to be accepted" ) ]
2024-09-20 23:23:21 +12:00
public bool UsePrivilegedIntents { get ; set ; }
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
The number of shards that the bot will be running on .
Leave at 1 if you don ' t know what you ' re doing .
note : If you are planning to have more than one shard , then you must change botCache to ' redis ' .
Also , in that case you should be using EllieBot.Coordinator to start the bot , and it will correctly override this value .
"" ")]
2024-09-20 23:23:21 +12:00
public int TotalShards { get ; set ; }
[ Comment ( "" "
Pledge 5 $ or more on https : //patreon.com/elliebot and connect your discord account to Patreon.
Go to https : //dashy.elliebot.net/me and login with your discord account
Go to the Keys page and click "Generate New Key" and copy it here
You and anyone else with the permission to run ` . prompt ` command will be able to use natural language to run bot ' s commands .
For example ' @Bot how ' s the weather in Paris ' will return the current weather in Paris as if you were to run ` . weather Paris ` command .
⚠ This does not currently work and is a work in progress .
"" ")]
public string EllieAiToken { get ; set ; }
2024-10-03 17:24:13 +13:00
[ Comment (
2024-09-20 23:23:21 +12:00
"" "
2024-10-03 17:24:13 +13:00
Login to https : //console.cloud.google.com, create a new project, go to APIs & Services -> Library -> YouTube Data API and enable it.
Then , go to APIs and Services - > Credentials and click Create credentials - > API key .
Used only for Youtube Data Api ( at the moment ) .
"" ")]
2024-09-20 23:23:21 +12:00
public string GoogleApiKey { get ; set ; }
2024-10-03 17:24:13 +13:00
[ Comment (
2024-09-20 23:23:21 +12:00
"" "
2024-10-03 17:24:13 +13:00
Create a new custom search here https : //programmablesearchengine.google.com/cse/create/new
Enable SafeSearch
Remove all Sites to Search
Enable Search the entire web
Copy the ' Search Engine ID ' to the SearchId field
Do all steps again but enable image search for the ImageSearchId
"" ")]
2024-09-20 23:23:21 +12:00
public GoogleApiConfig Google { get ; set ; }
[Comment("""Settings for voting system for discordbots. Meant for use on global Ellie.""")]
public VotesSettings Votes { get ; set ; }
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
Patreon auto reward system settings .
go to https : //www.patreon.com/portal -> my clients -> create client
"" ")]
2024-09-20 23:23:21 +12:00
public PatreonSettings Patreon { get ; set ; }
[Comment("""Api key for sending stats to DiscordBotList.""")]
public string BotListToken { get ; set ; }
[Comment("""Official cleverbot api key.""")]
public string CleverbotApiKey { get ; set ; }
[Comment(@"OpenAi api key.")]
public string Gpt3ApiKey { get ; set ; }
2024-10-03 17:24:13 +13:00
2024-09-20 23:23:21 +12:00
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
Which cache implementation should bot use .
' memory ' - Cache will be in memory of the bot ' s process itself . Only use this on bots with a single shard . When the bot is restarted the cache is reset .
' redis ' - Uses redis ( which needs to be separately downloaded and installed ) . The cache will persist through bot restarts . You can configure connection string in creds . yml
"" ")]
2024-09-20 23:23:21 +12:00
public BotCacheImplemenation BotCache { get ; set ; }
2024-10-03 17:24:13 +13:00
2024-09-20 23:23:21 +12:00
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
Redis connection string . Don ' t change if you don ' t know what you ' re doing .
Only used if botCache is set to ' redis '
"" ")]
2024-09-20 23:23:21 +12:00
public string RedisOptions { get ; set ; }
[Comment("""Database options. Don't change if you don't know what you're doing. Leave null for default values""")]
public DbOptions Db { get ; set ; }
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
Address and port of the coordinator endpoint . Leave empty for default .
Change only if you ' ve changed the coordinator address or port .
"" ")]
2024-09-20 23:23:21 +12:00
public string CoordinatorUrl { get ; set ; }
[ Comment (
"" "Api key obtained on https://rapidapi.com (go to MyApps -> Add New App -> Enter Name -> Application key)" "" ) ]
public string RapidApiKey { get ; set ; }
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
https : //locationiq.com api key (register and you will receive the token in the email).
Used only for . time command .
"" ")]
2024-09-20 23:23:21 +12:00
public string LocationIqApiKey { get ; set ; }
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
https : //timezonedb.com api key (register and you will receive the token in the email).
Used only for . time command
"" ")]
2024-09-20 23:23:21 +12:00
public string TimezoneDbApiKey { get ; set ; }
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
https : //pro.coinmarketcap.com/account/ api key. There is a free plan for personal use.
Used for cryptocurrency related commands .
"" ")]
2024-09-20 23:23:21 +12:00
public string CoinmarketcapApiKey { get ; set ; }
2024-10-03 17:24:13 +13:00
// [Comment(@"https://polygon.io/dashboard/api-keys api key. Free plan allows for 5 queries per minute.
// Used for stocks related commands.")]
// public string PolygonIoApiKey { get; set; }
2024-09-20 23:23:21 +12:00
[Comment("""Api key used for Osu related commands. Obtain this key at https://osu.ppy.sh/p/api""")]
public string OsuApiKey { get ; set ; }
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
Optional Trovo client id .
You should use this if Trovo stream notifications stopped working or you ' re getting ratelimit errors .
"" ")]
2024-09-20 23:23:21 +12:00
public string TrovoClientId { get ; set ; }
[Comment("""Obtain by creating an application at https://dev.twitch.tv/console/apps""")]
public string TwitchClientId { get ; set ; }
[Comment("""Obtain by creating an application at https://dev.twitch.tv/console/apps""")]
public string TwitchClientSecret { get ; set ; }
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
Command and args which will be used to restart the bot .
Only used if bot is executed directly ( NOT through the coordinator )
placeholders :
{ 0 } - > shard id
{ 1 } - > total shards
Linux default
2025-03-12 11:31:22 +13:00
cmd : EllieBot
args : "{0}"
2024-10-03 17:24:13 +13:00
Windows default
cmd : EllieBot . exe
args : "{0}"
"" ")]
2024-09-20 23:23:21 +12:00
public RestartConfig RestartCommand { get ; set ; }
2024-10-03 17:24:13 +13:00
[ Comment ( "" "
Settings for the grpc api .
We don ' t provide support for this .
If you leave certPath empty , the api will run on http .
"" ")]
2024-10-03 18:46:10 +13:00
public GrpcApiConfig GrpcApi { get ; set ; }
2024-10-03 17:24:13 +13:00
2024-10-05 11:44:44 +13:00
[ Comment ( "" "
2024-10-05 13:29:09 +13:00
Url and api key to a seq server . If url is set , bot will try to send logs to it .
2024-10-05 11:44:44 +13:00
"" ")]
public SeqConfig Seq { get ; set ; }
2024-09-20 23:23:21 +12:00
public Creds ( )
{
Token = string . Empty ;
UsePrivilegedIntents = true ;
OwnerIds = new List < ulong > ( ) ;
TotalShards = 1 ;
GoogleApiKey = string . Empty ;
2025-03-29 21:05:43 +13:00
Votes = new VotesSettings ( ) ;
2024-09-20 23:23:21 +12:00
Patreon = new PatreonSettings ( string . Empty , string . Empty , string . Empty , string . Empty ) ;
BotListToken = string . Empty ;
CleverbotApiKey = string . Empty ;
Gpt3ApiKey = string . Empty ;
BotCache = BotCacheImplemenation . Memory ;
RedisOptions = "localhost:6379,syncTimeout=30000,responseTimeout=30000,allowAdmin=true,password=" ;
Db = new DbOptions ( )
{
Type = "sqlite" ,
ConnectionString = "Data Source=data/EllieBot.db"
} ;
CoordinatorUrl = "http://localhost:3442" ;
RestartCommand = new RestartConfig ( ) ;
Google = new GoogleApiConfig ( ) ;
2024-10-03 17:24:13 +13:00
2024-10-05 11:44:44 +13:00
GrpcApi = new ( ) ;
Seq = new ( ) ;
2024-09-20 23:23:21 +12:00
}
2024-10-03 17:24:13 +13:00
2024-09-20 23:23:21 +12:00
public class DbOptions
: IDbOptions
{
[ Comment ( "" "
2025-01-15 19:31:27 +13:00
Database type . "sqlite" and "postgresql" are supported .
2024-10-03 17:24:13 +13:00
Default is "sqlite"
"" ")]
2024-09-20 23:23:21 +12:00
public string Type { get ; set ; }
[ Comment ( "" "
2024-10-03 17:24:13 +13:00
Database connection string .
You MUST change this if you ' re not using " sqlite " type.
Default is "Data Source=data/EllieBot.db"
Example for postgresql : "Server=localhost;Port=5432;User Id=postgres;Password=my_super_secret_postgres_password;Database=ellie;"
"" ")]
2024-09-20 23:23:21 +12:00
public string ConnectionString { get ; set ; }
}
public sealed record PatreonSettings : IPatreonSettings
{
public string ClientId { get ; set ; }
public string AccessToken { get ; set ; }
public string RefreshToken { get ; set ; }
public string ClientSecret { get ; set ; }
[ Comment (
"" "Campaign ID of your patreon page. Go to your patreon page (make sure you're logged in) and type " prompt ( ' Campaign ID ' , window . patreon . bootstrap . creator . data . id ) ; " in the console. (ctrl + shift + i)" "" ) ]
public string CampaignId { get ; set ; }
public PatreonSettings (
string accessToken ,
string refreshToken ,
string clientSecret ,
string campaignId )
{
AccessToken = accessToken ;
RefreshToken = refreshToken ;
ClientSecret = clientSecret ;
CampaignId = campaignId ;
}
public PatreonSettings ( )
{
}
}
public sealed record VotesSettings : IVotesSettings
{
2025-03-29 21:05:43 +13:00
public string Host { get ; set ; }
public int Port { get ; set ; }
public string DblApiKey { get ; set ; }
public string DiscordsApiKey { get ; set ; }
2024-09-20 23:23:21 +12:00
}
2024-10-03 17:24:13 +13:00
2024-10-03 18:46:10 +13:00
public sealed record GrpcApiConfig
2024-10-03 17:24:13 +13:00
{
public bool Enabled { get ; set ; } = false ;
2024-10-11 19:58:25 +13:00
public string CertChain { get ; set ; } = string . Empty ;
public string CertPrivateKey { get ; set ; } = string . Empty ;
2024-10-03 17:24:13 +13:00
public string Host { get ; set ; } = "localhost" ;
public int Port { get ; set ; } = 43120 ;
}
2024-09-20 23:23:21 +12:00
}
2024-10-05 11:44:44 +13:00
public sealed class SeqConfig
{
public string Url { get ; init ; }
public string ApiKey { get ; init ; }
}
2024-09-20 23:23:21 +12:00
public class GoogleApiConfig : IGoogleApiConfig
{
public string SearchId { get ; init ; }
public string ImageSearchId { get ; init ; }
2024-10-03 17:24:13 +13:00
}