Compare commits
26 Commits
5f67f9b4ee
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 97a0d1a13c | |||
| d8dadbe127 | |||
| 64402dc4cd | |||
| ff6d980fd0 | |||
| dbd77f41b2 | |||
| 10ae2f0965 | |||
| ae00fa4afb | |||
| 9dbee4889a | |||
| ae314454cb | |||
| aedb5b8a71 | |||
| 28a31df152 | |||
| 2c4565cdff | |||
| 3c94d56379 | |||
| 0e91353e37 | |||
| 29e6093714 | |||
| c8e77e1cff | |||
| 903ccf91b2 | |||
| ae2a29f374 | |||
| 9efcc1c98d | |||
| 9a6465d8c6 | |||
| efec65f79f | |||
| 6b3eb77e10 | |||
| 2317ada993 | |||
| a16978ca67 | |||
| 231076d63b | |||
| 0f71b3e431 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ vendor/
|
|||||||
|
|
||||||
# Enviroment variables
|
# Enviroment variables
|
||||||
.env
|
.env
|
||||||
|
.solargraph.yml
|
||||||
2
Gemfile
2
Gemfile
@@ -3,3 +3,5 @@ source 'https://rubygems.org'
|
|||||||
|
|
||||||
gem 'discordrb', git: 'https://github.com/shardlab/discordrb.git', branch: 'main'
|
gem 'discordrb', git: 'https://github.com/shardlab/discordrb.git', branch: 'main'
|
||||||
gem 'dotenv'
|
gem 'dotenv'
|
||||||
|
gem 'pg'
|
||||||
|
gem 'solargraph', group: :development
|
||||||
155
Gemfile.lock
155
Gemfile.lock
@@ -16,7 +16,11 @@ GIT
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
ast (2.4.3)
|
||||||
|
backport (1.2.0)
|
||||||
base64 (0.3.0)
|
base64 (0.3.0)
|
||||||
|
benchmark (0.5.0)
|
||||||
|
diff-lcs (1.6.2)
|
||||||
domain_name (0.6.20240107)
|
domain_name (0.6.20240107)
|
||||||
dotenv (3.2.0)
|
dotenv (3.2.0)
|
||||||
event_emitter (0.2.6)
|
event_emitter (0.2.6)
|
||||||
@@ -34,26 +38,125 @@ GEM
|
|||||||
http-accept (1.7.0)
|
http-accept (1.7.0)
|
||||||
http-cookie (1.1.0)
|
http-cookie (1.1.0)
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
|
jaro_winkler (1.6.1)
|
||||||
|
json (2.18.0)
|
||||||
|
kramdown (2.5.1)
|
||||||
|
rexml (>= 3.3.9)
|
||||||
|
kramdown-parser-gfm (1.1.0)
|
||||||
|
kramdown (~> 2.0)
|
||||||
|
language_server-protocol (3.17.0.5)
|
||||||
|
lint_roller (1.1.0)
|
||||||
logger (1.7.0)
|
logger (1.7.0)
|
||||||
mime-types (3.7.0)
|
mime-types (3.7.0)
|
||||||
logger
|
logger
|
||||||
mime-types-data (~> 3.2025, >= 3.2025.0507)
|
mime-types-data (~> 3.2025, >= 3.2025.0507)
|
||||||
mime-types-data (3.2025.0924)
|
mime-types-data (3.2025.0924)
|
||||||
|
mini_portile2 (2.8.9)
|
||||||
mutex_m (0.3.0)
|
mutex_m (0.3.0)
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
|
nokogiri (1.19.0)
|
||||||
|
mini_portile2 (~> 2.8.2)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.19.0-aarch64-linux-gnu)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.19.0-aarch64-linux-musl)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.19.0-arm-linux-gnu)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.19.0-arm-linux-musl)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.19.0-arm64-darwin)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.19.0-x86_64-darwin)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.19.0-x86_64-linux-gnu)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.19.0-x86_64-linux-musl)
|
||||||
|
racc (~> 1.4)
|
||||||
|
observer (0.1.2)
|
||||||
|
open3 (0.2.1)
|
||||||
opus-ruby (1.0.1)
|
opus-ruby (1.0.1)
|
||||||
ffi
|
ffi
|
||||||
|
ostruct (0.6.3)
|
||||||
|
parallel (1.27.0)
|
||||||
|
parser (3.3.10.0)
|
||||||
|
ast (~> 2.4.1)
|
||||||
|
racc
|
||||||
|
pg (1.6.3)
|
||||||
|
pg (1.6.3-aarch64-linux)
|
||||||
|
pg (1.6.3-aarch64-linux-musl)
|
||||||
|
pg (1.6.3-arm64-darwin)
|
||||||
|
pg (1.6.3-x86_64-darwin)
|
||||||
|
pg (1.6.3-x86_64-linux)
|
||||||
|
pg (1.6.3-x86_64-linux-musl)
|
||||||
|
prism (1.7.0)
|
||||||
|
racc (1.8.1)
|
||||||
|
rainbow (3.1.1)
|
||||||
|
rbs (3.10.2)
|
||||||
|
logger
|
||||||
|
regexp_parser (2.11.3)
|
||||||
rest-client (2.1.0)
|
rest-client (2.1.0)
|
||||||
http-accept (>= 1.7.0, < 2.0)
|
http-accept (>= 1.7.0, < 2.0)
|
||||||
http-cookie (>= 1.0.2, < 2.0)
|
http-cookie (>= 1.0.2, < 2.0)
|
||||||
mime-types (>= 1.16, < 4.0)
|
mime-types (>= 1.16, < 4.0)
|
||||||
netrc (~> 0.8)
|
netrc (~> 0.8)
|
||||||
|
reverse_markdown (3.0.1)
|
||||||
|
nokogiri
|
||||||
|
rexml (3.4.4)
|
||||||
|
rubocop (1.82.1)
|
||||||
|
json (~> 2.3)
|
||||||
|
language_server-protocol (~> 3.17.0.2)
|
||||||
|
lint_roller (~> 1.1.0)
|
||||||
|
parallel (~> 1.10)
|
||||||
|
parser (>= 3.3.0.2)
|
||||||
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
|
regexp_parser (>= 2.9.3, < 3.0)
|
||||||
|
rubocop-ast (>= 1.48.0, < 2.0)
|
||||||
|
ruby-progressbar (~> 1.7)
|
||||||
|
unicode-display_width (>= 2.4.0, < 4.0)
|
||||||
|
rubocop-ast (1.49.0)
|
||||||
|
parser (>= 3.3.7.2)
|
||||||
|
prism (~> 1.7)
|
||||||
|
ruby-progressbar (1.13.0)
|
||||||
|
solargraph (0.58.1)
|
||||||
|
ast (~> 2.4.3)
|
||||||
|
backport (~> 1.2)
|
||||||
|
benchmark (~> 0.4)
|
||||||
|
bundler (>= 2.0)
|
||||||
|
diff-lcs (~> 1.4)
|
||||||
|
jaro_winkler (~> 1.6, >= 1.6.1)
|
||||||
|
kramdown (~> 2.3)
|
||||||
|
kramdown-parser-gfm (~> 1.1)
|
||||||
|
logger (~> 1.6)
|
||||||
|
observer (~> 0.1)
|
||||||
|
open3 (~> 0.2.1)
|
||||||
|
ostruct (~> 0.6)
|
||||||
|
parser (~> 3.0)
|
||||||
|
prism (~> 1.4)
|
||||||
|
rbs (>= 3.6.1, <= 4.0.0.dev.4)
|
||||||
|
reverse_markdown (~> 3.0)
|
||||||
|
rubocop (~> 1.76)
|
||||||
|
thor (~> 1.0)
|
||||||
|
tilt (~> 2.0)
|
||||||
|
yard (~> 0.9, >= 0.9.24)
|
||||||
|
yard-activesupport-concern (~> 0.0)
|
||||||
|
yard-solargraph (~> 0.1)
|
||||||
|
thor (1.5.0)
|
||||||
|
tilt (2.7.0)
|
||||||
|
unicode-display_width (3.2.0)
|
||||||
|
unicode-emoji (~> 4.1)
|
||||||
|
unicode-emoji (4.2.0)
|
||||||
websocket (1.2.11)
|
websocket (1.2.11)
|
||||||
websocket-client-simple (0.9.0)
|
websocket-client-simple (0.9.0)
|
||||||
base64
|
base64
|
||||||
event_emitter
|
event_emitter
|
||||||
mutex_m
|
mutex_m
|
||||||
websocket
|
websocket
|
||||||
|
yard (0.9.38)
|
||||||
|
yard-activesupport-concern (0.0.1)
|
||||||
|
yard (>= 0.8)
|
||||||
|
yard-solargraph (0.1.0)
|
||||||
|
yard (~> 0.9)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
aarch64-linux-gnu
|
aarch64-linux-gnu
|
||||||
@@ -71,9 +174,15 @@ PLATFORMS
|
|||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
discordrb!
|
discordrb!
|
||||||
dotenv
|
dotenv
|
||||||
|
pg
|
||||||
|
solargraph
|
||||||
|
|
||||||
CHECKSUMS
|
CHECKSUMS
|
||||||
|
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
|
||||||
|
backport (1.2.0) sha256=912c7dfdd9ee4625d013ddfccb6205c3f92da69a8990f65c440e40f5b2fc7f75
|
||||||
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
||||||
|
benchmark (0.5.0) sha256=465df122341aedcb81a2a24b4d3bd19b6c67c1530713fd533f3ff034e419236c
|
||||||
|
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
|
||||||
discordrb (3.7.2)
|
discordrb (3.7.2)
|
||||||
discordrb-webhooks (3.7.2)
|
discordrb-webhooks (3.7.2)
|
||||||
domain_name (0.6.20240107) sha256=5f693b2215708476517479bf2b3802e49068ad82167bcd2286f899536a17d933
|
domain_name (0.6.20240107) sha256=5f693b2215708476517479bf2b3802e49068ad82167bcd2286f899536a17d933
|
||||||
@@ -92,15 +201,61 @@ CHECKSUMS
|
|||||||
ffi (1.17.3-x86_64-linux-musl) sha256=086b221c3a68320b7564066f46fed23449a44f7a1935f1fe5a245bd89d9aea56
|
ffi (1.17.3-x86_64-linux-musl) sha256=086b221c3a68320b7564066f46fed23449a44f7a1935f1fe5a245bd89d9aea56
|
||||||
http-accept (1.7.0) sha256=c626860682bfbb3b46462f8c39cd470fd7b0584f61b3cc9df5b2e9eb9972a126
|
http-accept (1.7.0) sha256=c626860682bfbb3b46462f8c39cd470fd7b0584f61b3cc9df5b2e9eb9972a126
|
||||||
http-cookie (1.1.0) sha256=38a5e60d1527eebc396831b8c4b9455440509881219273a6c99943d29eadbb19
|
http-cookie (1.1.0) sha256=38a5e60d1527eebc396831b8c4b9455440509881219273a6c99943d29eadbb19
|
||||||
|
jaro_winkler (1.6.1) sha256=c056b61bbf7f1fc0151bde7c8f589a2d666d42d0cdb889395b9b73b328e1b393
|
||||||
|
json (2.18.0) sha256=b10506aee4183f5cf49e0efc48073d7b75843ce3782c68dbeb763351c08fd505
|
||||||
|
kramdown (2.5.1) sha256=87bbb6abd9d3cebe4fc1f33e367c392b4500e6f8fa19dd61c0972cf4afe7368c
|
||||||
|
kramdown-parser-gfm (1.1.0) sha256=fb39745516427d2988543bf01fc4cf0ab1149476382393e0e9c48592f6581729
|
||||||
|
language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
|
||||||
|
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
||||||
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
||||||
mime-types (3.7.0) sha256=dcebf61c246f08e15a4de34e386ebe8233791e868564a470c3fe77c00eed5e56
|
mime-types (3.7.0) sha256=dcebf61c246f08e15a4de34e386ebe8233791e868564a470c3fe77c00eed5e56
|
||||||
mime-types-data (3.2025.0924) sha256=f276bca15e59f35767cbcf2bc10e023e9200b30bd6a572c1daf7f4cc24994728
|
mime-types-data (3.2025.0924) sha256=f276bca15e59f35767cbcf2bc10e023e9200b30bd6a572c1daf7f4cc24994728
|
||||||
|
mini_portile2 (2.8.9) sha256=0cd7c7f824e010c072e33f68bc02d85a00aeb6fce05bb4819c03dfd3c140c289
|
||||||
mutex_m (0.3.0) sha256=cfcb04ac16b69c4813777022fdceda24e9f798e48092a2b817eb4c0a782b0751
|
mutex_m (0.3.0) sha256=cfcb04ac16b69c4813777022fdceda24e9f798e48092a2b817eb4c0a782b0751
|
||||||
netrc (0.11.0) sha256=de1ce33da8c99ab1d97871726cba75151113f117146becbe45aa85cb3dabee3f
|
netrc (0.11.0) sha256=de1ce33da8c99ab1d97871726cba75151113f117146becbe45aa85cb3dabee3f
|
||||||
|
nokogiri (1.19.0) sha256=e304d21865f62518e04f2bf59f93bd3a97ca7b07e7f03952946d8e1c05f45695
|
||||||
|
nokogiri (1.19.0-aarch64-linux-gnu) sha256=11a97ecc3c0e7e5edcf395720b10860ef493b768f6aa80c539573530bc933767
|
||||||
|
nokogiri (1.19.0-aarch64-linux-musl) sha256=eb70507f5e01bc23dad9b8dbec2b36ad0e61d227b42d292835020ff754fb7ba9
|
||||||
|
nokogiri (1.19.0-arm-linux-gnu) sha256=572a259026b2c8b7c161fdb6469fa2d0edd2b61cd599db4bbda93289abefbfe5
|
||||||
|
nokogiri (1.19.0-arm-linux-musl) sha256=23ed90922f1a38aed555d3de4d058e90850c731c5b756d191b3dc8055948e73c
|
||||||
|
nokogiri (1.19.0-arm64-darwin) sha256=0811dfd936d5f6dd3f6d32ef790568bf29b2b7bead9ba68866847b33c9cf5810
|
||||||
|
nokogiri (1.19.0-x86_64-darwin) sha256=1dad56220b603a8edb9750cd95798bffa2b8dd9dd9aa47f664009ee5b43e3067
|
||||||
|
nokogiri (1.19.0-x86_64-linux-gnu) sha256=f482b95c713d60031d48c44ce14562f8d2ce31e3a9e8dd0ccb131e9e5a68b58c
|
||||||
|
nokogiri (1.19.0-x86_64-linux-musl) sha256=1c4ca6b381622420073ce6043443af1d321e8ed93cc18b08e2666e5bd02ffae4
|
||||||
|
observer (0.1.2) sha256=d8a3107131ba661138d748e7be3dbafc0d82e732fffba9fccb3d7829880950ac
|
||||||
|
open3 (0.2.1) sha256=8e2d7d2113526351201438c1aa35c8139f0141c9e8913baa007c898973bf3952
|
||||||
opus-ruby (1.0.1) sha256=8dc808d6773a488469374cccf252808b2ad7bc7e00229a319832f0e09012ce53
|
opus-ruby (1.0.1) sha256=8dc808d6773a488469374cccf252808b2ad7bc7e00229a319832f0e09012ce53
|
||||||
|
ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912
|
||||||
|
parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
|
||||||
|
parser (3.3.10.0) sha256=ce3587fa5cc55a88c4ba5b2b37621b3329aadf5728f9eafa36bbd121462aabd6
|
||||||
|
pg (1.6.3) sha256=1388d0563e13d2758c1089e35e973a3249e955c659592d10e5b77c468f628a99
|
||||||
|
pg (1.6.3-aarch64-linux) sha256=0698ad563e02383c27510b76bf7d4cd2de19cd1d16a5013f375dd473e4be72ea
|
||||||
|
pg (1.6.3-aarch64-linux-musl) sha256=06a75f4ea04b05140146f2a10550b8e0d9f006a79cdaf8b5b130cde40e3ecc2c
|
||||||
|
pg (1.6.3-arm64-darwin) sha256=7240330b572e6355d7c75a7de535edb5dfcbd6295d9c7777df4d9dddfb8c0e5f
|
||||||
|
pg (1.6.3-x86_64-darwin) sha256=ee2e04a17c0627225054ffeb43e31a95be9d7e93abda2737ea3ce4a62f2729d6
|
||||||
|
pg (1.6.3-x86_64-linux) sha256=5d9e188c8f7a0295d162b7b88a768d8452a899977d44f3274d1946d67920ae8d
|
||||||
|
pg (1.6.3-x86_64-linux-musl) sha256=9c9c90d98c72f78eb04c0f55e9618fe55d1512128e411035fe229ff427864009
|
||||||
|
prism (1.7.0) sha256=10062f734bf7985c8424c44fac382ac04a58124ea3d220ec3ba9fe4f2da65103
|
||||||
|
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
||||||
|
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
|
||||||
|
rbs (3.10.2) sha256=bd8a5dc4c62f229f020146b61844a31f9c79e649449d212904a474eb79c846fc
|
||||||
|
regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
|
||||||
rest-client (2.1.0) sha256=35a6400bdb14fae28596618e312776c158f7ebbb0ccad752ff4fa142bf2747e3
|
rest-client (2.1.0) sha256=35a6400bdb14fae28596618e312776c158f7ebbb0ccad752ff4fa142bf2747e3
|
||||||
|
reverse_markdown (3.0.1) sha256=2cac1f448ac5c9d6d858fafb84db2a0c0fa244f6a5684ea6d14ca448895de283
|
||||||
|
rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
|
||||||
|
rubocop (1.82.1) sha256=09f1a6a654a960eda767aebea33e47603080f8e9c9a3f019bf9b94c9cab5e273
|
||||||
|
rubocop-ast (1.49.0) sha256=49c3676d3123a0923d333e20c6c2dbaaae2d2287b475273fddee0c61da9f71fd
|
||||||
|
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
||||||
|
solargraph (0.58.1) sha256=356ae338069b724ca6a1baf9f5af7097600c2b28708eb8694462f7c9d938aaca
|
||||||
|
thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
|
||||||
|
tilt (2.7.0) sha256=0d5b9ba69f6a36490c64b0eee9f6e9aad517e20dcc848800a06eb116f08c6ab3
|
||||||
|
unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
|
||||||
|
unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
|
||||||
websocket (1.2.11) sha256=b7e7a74e2410b5e85c25858b26b3322f29161e300935f70a0e0d3c35e0462737
|
websocket (1.2.11) sha256=b7e7a74e2410b5e85c25858b26b3322f29161e300935f70a0e0d3c35e0462737
|
||||||
websocket-client-simple (0.9.0) sha256=f9a37c5e4922b35a711e21e6d73ed1e25892efa47d183203ab2f5beb4e563109
|
websocket-client-simple (0.9.0) sha256=f9a37c5e4922b35a711e21e6d73ed1e25892efa47d183203ab2f5beb4e563109
|
||||||
|
yard (0.9.38) sha256=721fb82afb10532aa49860655f6cc2eaa7130889df291b052e1e6b268283010f
|
||||||
|
yard-activesupport-concern (0.0.1) sha256=be790cb0efc23e2e87677063598ac8b743586154657bbd9655a7f03ce78390ef
|
||||||
|
yard-solargraph (0.1.0) sha256=a19a4619c942181a618fb9458970a9d2534cf7fda69fc43949629a7948a5930e
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
4.0.3
|
4.0.3
|
||||||
|
|||||||
32
POLICY.md
Normal file
32
POLICY.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Why we collect and use data
|
||||||
|
|
||||||
|
Collecting data is necessary in order to make the bot run properly.
|
||||||
|
Without storing some aspects of your user data, the bot would not be able to run.
|
||||||
|
|
||||||
|
# What data is collected
|
||||||
|
|
||||||
|
We collect the following:
|
||||||
|
|
||||||
|
* User IDs and Guild IDs
|
||||||
|
|
||||||
|
Required for functionality of the blacklist command.
|
||||||
|
|
||||||
|
* Messages
|
||||||
|
|
||||||
|
Messages are not stored, but they are used for the main functionality of cheeseBot.
|
||||||
|
A message gets checked, if it has a keyword that's in the list of possible cheese words,
|
||||||
|
it will react and send a DM, then it will move on to check the next message sent.
|
||||||
|
Users can opt-out of this feature by using the button attached to the DM.
|
||||||
|
|
||||||
|
# Where data is stored and secured
|
||||||
|
|
||||||
|
Data that we collect is stored in a database. This database is not accessible by other entities.
|
||||||
|
The server that the database is kept on is stored in the US.
|
||||||
|
|
||||||
|
# Where data is shared
|
||||||
|
|
||||||
|
Raw data is not shared with other entities.
|
||||||
|
|
||||||
|
# Concerns
|
||||||
|
|
||||||
|
If you have any concerns about the usage of your data, please contact NXkDV via email.
|
||||||
35
README.md
35
README.md
@@ -1,6 +1,37 @@
|
|||||||
# CheeseBot - REWRITE.
|
# cheeseBot - rewrite
|
||||||
|
|
||||||
This is a work in progress...
|
cheeseBot is a bot made by Eri/Rei related to stuff about cheese.
|
||||||
|
Its main function gets triggered whenever it detects a message with a cheese keyword. Users can opt-out of this feature by using the button attached to the DM sent by cheeseBot.
|
||||||
|
|
||||||
|
A server can also opt-out of this feature, by running the command `/server_blacklist`. Be advised that only admins can use this command.
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
Other commands from cheeseBot are...
|
||||||
|
|
||||||
|
1. `/cheese`
|
||||||
|
|
||||||
|
Sends a cheese wedge (🧀) to the channel.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
2. `/photo`
|
||||||
|
|
||||||
|
Sends a cheese photo to the channel.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
3. `/fact`
|
||||||
|
|
||||||
|
Sends a cheese fact to the channel.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
4. `/truth`
|
||||||
|
|
||||||
|
Sends a phrase that's 100% the truth to the channel (This is a joke).
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
## License
|
## License
|
||||||
This project is licensed under the [GNU General Public License v3.0](https://spdx.org/licenses/GPL-3.0-or-later.html).
|
This project is licensed under the [GNU General Public License v3.0](https://spdx.org/licenses/GPL-3.0-or-later.html).
|
||||||
|
|||||||
12
TOS.md
Normal file
12
TOS.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# By adding this bot to your server, you agree to the following:
|
||||||
|
|
||||||
|
* Data collection (User ID and Guild ID)
|
||||||
|
* Application sending you DMs (These can be disabled if you find it too annoying)
|
||||||
|
|
||||||
|
# Privacy Policy
|
||||||
|
|
||||||
|
You can check our Privacy Policy on the [POLICY](POLICY.md) file
|
||||||
|
|
||||||
|
# Concerns
|
||||||
|
|
||||||
|
If you have any concerns about the usage of your data, please contact NXkDV via email.
|
||||||
24
main.rb
Normal file
24
main.rb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
require 'dotenv/load'
|
||||||
|
require_relative 'src/bot'
|
||||||
|
|
||||||
|
# Instantiate the class
|
||||||
|
bot = CheeseBot.new
|
||||||
|
|
||||||
|
# Run it
|
||||||
|
bot.run
|
||||||
18
src/bot.rb
18
src/bot.rb
@@ -15,15 +15,29 @@
|
|||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
require 'discordrb'
|
require 'discordrb'
|
||||||
|
require 'securerandom'
|
||||||
|
require_relative 'events/message_check'
|
||||||
|
require_relative 'events/button_handler'
|
||||||
|
|
||||||
class CheeseBot
|
class CheeseBot
|
||||||
def initialize
|
def initialize
|
||||||
|
puts "Initializing bot..."
|
||||||
@bot = Discordrb::Bot.new(
|
@bot = Discordrb::Bot.new(
|
||||||
token: ENV['BOT_TOKEN'],
|
token: ENV['BOT_TOKEN'],
|
||||||
intents: []
|
intents: [:servers, :server_messages]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
puts "Registering the Message Checker and Button Handler..."
|
||||||
|
MessageCheck.register(@bot)
|
||||||
|
ButtonHandler.register(@bot)
|
||||||
|
|
||||||
|
puts "Initializing database..."
|
||||||
|
Database.setup
|
||||||
|
|
||||||
|
puts "Loading commands..."
|
||||||
load_commands
|
load_commands
|
||||||
|
|
||||||
|
puts "Starting bot..."
|
||||||
start_bot
|
start_bot
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -52,7 +66,7 @@ class CheeseBot
|
|||||||
def start_bot
|
def start_bot
|
||||||
@bot.ready do
|
@bot.ready do
|
||||||
puts "#{@bot.profile.username} is online... GIVE ME THE CHEESE."
|
puts "#{@bot.profile.username} is online... GIVE ME THE CHEESE."
|
||||||
@bot.update_status("online", "We're so back.", nil, 0, false, 0)
|
@bot.update_status("online", "Eating cheese.", nil, 0, false, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
32
src/commands/cheese_related/cheese.rb
Normal file
32
src/commands/cheese_related/cheese.rb
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
module Commands
|
||||||
|
module Cheese
|
||||||
|
extend self
|
||||||
|
|
||||||
|
def register(bot)
|
||||||
|
cmd_key = :cheese
|
||||||
|
cmd_desc = "Cheese."
|
||||||
|
|
||||||
|
bot.register_application_command(cmd_key, cmd_desc)
|
||||||
|
|
||||||
|
bot.application_command(cmd_key) do |event|
|
||||||
|
event.respond(content: "🧀")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
34
src/commands/cheese_related/facts.rb
Normal file
34
src/commands/cheese_related/facts.rb
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
require_relative '../../lists/cheese_facts.rb'
|
||||||
|
|
||||||
|
module Commands
|
||||||
|
module Facts
|
||||||
|
extend self
|
||||||
|
|
||||||
|
def register(bot)
|
||||||
|
cmd_key = :fact
|
||||||
|
cmd_desc = "Get a random cheese fact."
|
||||||
|
|
||||||
|
bot.register_application_command(cmd_key, cmd_desc)
|
||||||
|
|
||||||
|
bot.application_command(cmd_key) do |event|
|
||||||
|
event.respond(content: Lists::CHEESE_FACTS.sample)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
34
src/commands/cheese_related/photos.rb
Normal file
34
src/commands/cheese_related/photos.rb
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
require_relative '../../lists/cheese_photos'
|
||||||
|
|
||||||
|
module Commands
|
||||||
|
module Photos
|
||||||
|
extend self
|
||||||
|
|
||||||
|
def register(bot)
|
||||||
|
cmd_key = :photo
|
||||||
|
cmd_desc = "Get a cheese photo."
|
||||||
|
|
||||||
|
bot.register_application_command(cmd_key, cmd_desc)
|
||||||
|
|
||||||
|
bot.application_command(cmd_key) do |event|
|
||||||
|
event.respond(content: Lists::CHEESE_PHOTOS.sample)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
34
src/commands/cheese_related/truth.rb
Normal file
34
src/commands/cheese_related/truth.rb
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
require_relative '../../lists/cheese_of_truth'
|
||||||
|
|
||||||
|
module Commands
|
||||||
|
module Truth
|
||||||
|
extend self
|
||||||
|
|
||||||
|
def register(bot)
|
||||||
|
cmd_key = :truth
|
||||||
|
cmd_desc = "The Cheese of Truth. Get a random phrase that's 100% the truth."
|
||||||
|
|
||||||
|
bot.register_application_command(cmd_key, cmd_desc)
|
||||||
|
|
||||||
|
bot.application_command(cmd_key) do |event|
|
||||||
|
event.respond(content: Lists::CHEESE_OF_TRUTH.sample)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
45
src/commands/not_cheese_related/blacklist.rb
Normal file
45
src/commands/not_cheese_related/blacklist.rb
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
require_relative '../../modules/database'
|
||||||
|
|
||||||
|
module Commands
|
||||||
|
module Blacklist
|
||||||
|
extend self
|
||||||
|
|
||||||
|
def register(bot)
|
||||||
|
cmd_key_server = :server_blacklist
|
||||||
|
cmd_desc_server = "Blacklist the server from the trigger DMs (using the command again will whitelist the server.)"
|
||||||
|
|
||||||
|
bot.register_application_command(cmd_key_server, cmd_desc_server)
|
||||||
|
|
||||||
|
bot.application_command(cmd_key_server) do |event|
|
||||||
|
unless event.user.permission?(:administrator)
|
||||||
|
event.respond(content: "You're not an admin. You can't use this command.", ephemeral: true)
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
added = Database.toggle_server_blacklist(event.server.id)
|
||||||
|
|
||||||
|
if added
|
||||||
|
event.respond(content: "Server has been added to the blacklist. Users from this server will no longer receive DMs from cheeseBot when triggered.")
|
||||||
|
else
|
||||||
|
event.respond(content: "Server has been removed from the blacklist. Users from this server will now receive DMs from cheeseBot when triggered.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
32
src/commands/not_cheese_related/donate.rb
Normal file
32
src/commands/not_cheese_related/donate.rb
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
module Commands
|
||||||
|
module Donate
|
||||||
|
extend self
|
||||||
|
|
||||||
|
def register(bot)
|
||||||
|
cmd_key = :donate
|
||||||
|
cmd_desc = "Only if you can and want, of course."
|
||||||
|
|
||||||
|
bot.register_application_command(cmd_key, cmd_desc)
|
||||||
|
|
||||||
|
bot.application_command(cmd_key) do |event|
|
||||||
|
event.respond(content:"[Donate a ko-fi](https://ko-fi.com/reicore) to my creator if you can, and want.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
58
src/commands/not_cheese_related/help.rb
Normal file
58
src/commands/not_cheese_related/help.rb
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
require 'securerandom'
|
||||||
|
|
||||||
|
module Commands
|
||||||
|
module Help
|
||||||
|
extend self
|
||||||
|
|
||||||
|
def register(bot)
|
||||||
|
cmd_key = :help
|
||||||
|
cmd_desc = "Use this command to know more."
|
||||||
|
|
||||||
|
bot.register_application_command(cmd_key, cmd_desc)
|
||||||
|
|
||||||
|
bot.application_command(cmd_key) do |event|
|
||||||
|
random_color = ("0x" + Random.bytes(3).unpack1('H*')).to_i(16)
|
||||||
|
author = event.user
|
||||||
|
|
||||||
|
embed_generated = {
|
||||||
|
title: "About cheeseBot...",
|
||||||
|
description: "Here's everything you need to know!",
|
||||||
|
color: random_color,
|
||||||
|
timestamp: Time.now.iso8601,
|
||||||
|
author: {
|
||||||
|
name: author.username,
|
||||||
|
icon_url: author.avatar_url
|
||||||
|
},
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "Who am I?",
|
||||||
|
value: "I'm cheeseBot. Made by <@396376536070094848> related to cheese stuff."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "What are your commands?",
|
||||||
|
value: "/cheese, /fact, /photo, /truth, and more!"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
event.respond(embeds: [embed_generated])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
31
src/events/button_handler.rb
Normal file
31
src/events/button_handler.rb
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
require_relative '../modules/database'
|
||||||
|
|
||||||
|
module ButtonHandler
|
||||||
|
def self.register(bot)
|
||||||
|
bot.button(custom_id: 'toggle_cheese_blacklist') do |event|
|
||||||
|
added = Database.toggle_user_blacklist(event.user.id)
|
||||||
|
|
||||||
|
if added
|
||||||
|
event.respond(content: "You have been added to the blacklist. You will no longer receive DMs from cheeseBot when triggered.\n(Click this button again anytime to re-enable them.)", ephemeral: true)
|
||||||
|
else
|
||||||
|
event.respond(content: "You have been removed from the blacklist. You will now receive DMs from cheeseBot when triggered.", ephemeral: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
69
src/events/message_check.rb
Normal file
69
src/events/message_check.rb
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
require 'securerandom'
|
||||||
|
require_relative '../modules/cheese_checker'
|
||||||
|
require_relative '../modules/database'
|
||||||
|
|
||||||
|
module MessageCheck
|
||||||
|
def self.register(bot)
|
||||||
|
bot.message do |event|
|
||||||
|
next if event.user.bot_account || event.server.nil?
|
||||||
|
|
||||||
|
cheese_content = CheeseChecker.check_content(event.content)
|
||||||
|
next unless cheese_content
|
||||||
|
|
||||||
|
event.message.react("🧀")
|
||||||
|
|
||||||
|
if Database.server_blacklisted?(event.server.id)
|
||||||
|
puts "[DEBUG] Ignored: Server #{event.server.name} is blacklisted."
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
if Database.user_blacklisted?(event.user.id)
|
||||||
|
puts "[DEBUG] Ignored: User #{event.user.id} is blacklisted."
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
view = Discordrb::Webhooks::View.new
|
||||||
|
view.row do |r|
|
||||||
|
r.button(
|
||||||
|
label: "Toggle Blacklist",
|
||||||
|
style: :secondary,
|
||||||
|
custom_id: "toggle_cheese_blacklist"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
random_color = ("0x" + Random.bytes(3).unpack1('H*')).to_i(16)
|
||||||
|
author = event.user
|
||||||
|
|
||||||
|
embed_generated = {
|
||||||
|
title: "Cheese detected!",
|
||||||
|
description: cheese_content,
|
||||||
|
color: random_color,
|
||||||
|
timestamp: Time.now.iso8601,
|
||||||
|
footer: { text: "Click the button to stop these messages." }
|
||||||
|
}
|
||||||
|
|
||||||
|
# send_message(content, tts, embed, attachments, allowed_mentions, message_reference, components)
|
||||||
|
event.user.pm.send_message(nil, false, [embed_generated], nil, nil, nil, view)
|
||||||
|
rescue Discordrb::Errors::NoPermission
|
||||||
|
puts "Could not DM user #{event.user.username} (#{event.user.id})"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
BIN
src/images/cheese.png
Normal file
BIN
src/images/cheese.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
65
src/lists/cheese_facts.rb
Normal file
65
src/lists/cheese_facts.rb
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
module Lists
|
||||||
|
CHEESE_FACTS = [
|
||||||
|
'Cheese is a dairy! It is the resulting product of curdling milk. In cheese factories, bacteria is added to milk to convert the lactose into lactic acid, and then an enzyme is added, which curdles the milk. This enzyme is called rennet, which used to be taken from the stomachs of young cows but is now found from genetically engineered bacteria and yeast.',
|
||||||
|
'It takes about 10 pounds of milk to make 1 pound of cheese, though this ratio changes depending on the type of milk.',
|
||||||
|
'Cheddar cheese is not naturally yellow. The bright orange cheddar cheese we all know and love is not a natural result of its curdled milk components. All cheese is naturally white, off-white, or golden yellow (dependent on the milk). To get the orange color of cheddar cheese, like the irresistible cheese in our Chicago Baked Cheddar popcorn, flavorless Annatto seed is added.',
|
||||||
|
'Gouda cheese accounts for 50-60% of the world’s consumption of cheese.',
|
||||||
|
'The state which produces the most amount of cheese is Wisconsin. More than two and a half billion pounds of cheese are produced in Wisconsin every year. The next top producer is California.',
|
||||||
|
'Cheese was discovered by accident! Ancient people more than 7000 years ago discovered cheese by carrying milk in the stomach linings of animals, which carried the bacteria rennet that curdles milk.',
|
||||||
|
'The most popular cheese recipe in America is Mac and Cheese.',
|
||||||
|
'There are about 2,000 varieties of cheese.',
|
||||||
|
'The biggest and heaviest cheese ever created was 32 feet long and weighed 57,518 pounds! A Canadian cheese maker used 540,000 pounds of milk to make this record-breaking cheddar cheese.',
|
||||||
|
'National Dairy month is in June.',
|
||||||
|
'Cheese is one of the most popular flavors of popcorn nationwide.',
|
||||||
|
'‘Cheese’ comes from the Latin word ‘caseus’, which has been found to mean ‘to ferment/to sour’.',
|
||||||
|
'Cheese is made from the milk of cows, buffalo’s, goats, sheep, horses and camels.',
|
||||||
|
'Some cheeses can be curdled by adding lemon juice or vinegar.',
|
||||||
|
'There are many types of cheese such as hard cheese, soft cheese, cream cheese, and processed cheese, all which can be used in cooking.',
|
||||||
|
'Blue cheese, which has distinctive smells and tastes, have blue veins running through, which is caused by piercing the cheese and its crust with stainless steel needles and copper wires, to allow air into the product.',
|
||||||
|
'The US produces over 4275 tonnes of cheese a year. Germany produces 1927 tonnes, whereas France produces 1884 tonnes.',
|
||||||
|
'Greece consumes over 31.1 kg of cheese a year. France consumes 26.1 kg, whereas Iceland consumes 25.4 kg.',
|
||||||
|
'A seller of cheese is known as a ‘cheesemonger’.',
|
||||||
|
'Those who are lactose intolerant (unable to process a type of sugar found in milk and milk products) should avoid eating cheese.',
|
||||||
|
'It was once believed that eating cheese before bed could cause nightmares, but in fact it had health benefits.',
|
||||||
|
'Collecting cheese labels is known as ‘tyrosemiophilia’.',
|
||||||
|
'The famous characters Wallace and Gromit are partial to Wensleydale cheese on crackers.',
|
||||||
|
'People once believed the proverb that ‘the moon is made of green cheese’.',
|
||||||
|
'The most stolen food item in the world is cheese, with 4% of all cheese being sold end up stolen.',
|
||||||
|
'President Andrew Jackson once had a block of cheddar cheese delivered to the white house that was four feet in diameter and two feet thick, weighed nearly 1400 pounds. He invited 10,000 visitors to the White House to eat it and it was gone within two hours.',
|
||||||
|
'When cheese is digested, it breaks down into an opioid. Other opioids you may know about are heroin and morphine.',
|
||||||
|
'The “holes” in Swiss cheese were, until recently, seen as a sign of imperfection and something cheese makers tried to avoid.',
|
||||||
|
'Albertville, France’s electricity is powered by Beaufort cheese. Since whey is unnecessary to make Beaufort cheese, bacteria is added to the whey. This transforms the whey into biogas. This gas is then fed through an engine which heats water to 90°C (194°F) to generate 2800 MWh/yr of electricity.',
|
||||||
|
'There’s a cheese from Sardinia with maggots in it that’s outlawed by European Union food hygiene-health regulations, however, it’s still made and sold on the black market.',
|
||||||
|
'People started dying cheese orange back in the 17th century to fool people into thinking it was higher quality.',
|
||||||
|
'Stilton blue cheese is known to frequently cause odd, vivid dreams.',
|
||||||
|
'American Cheese cannot be legally sold as “cheese” in the United States. It must instead be labeled as “cheese product,” “cheese food,” or “American Singles,” since its manufacturing process varies so significantly from that of other cheeses.',
|
||||||
|
'Philadelphia cream cheese is named after a village in upstate New York, not the famous Pennsylvania city.',
|
||||||
|
'Scientists have successfully created cheese using human bacteria collected from toes and belly buttons.',
|
||||||
|
'In the 2013 American Cheese Competition, only one cheese was entered in the Dry Jack category, it came in third. The judges chose to not award first or second.',
|
||||||
|
'Cheese can be addictive, as it contains trace amounts of naturally occurring morphine, that comes from the cow’s liver.',
|
||||||
|
'The crunchy bits you sometimes get inside of aged cheese are amino acid crystals.',
|
||||||
|
'The French have a different cheese for every day of the year. Cheese experts estimate the total number of different French cheeses is around 1000.',
|
||||||
|
'Västerbottensost, a prized cheese from Sweden, can only be made in one village (Burträsk). After forensic DNA tests, multiple scientific studies and several documentaries, nobody knows why.',
|
||||||
|
'Kraft Singles cannot be called cheese because less than 51% of it is actually cheese.',
|
||||||
|
'Moose cheese costs around $420 per pound, since each milking takes two hours, and must be done in complete silence.',
|
||||||
|
'Pule cheese is the world’s most expensive cheese and it comes from the milk of Balkan donkeys from Serbia. It’s valued at $600 per pound; it’s so expensive because there are only ~100 jennies (female donkeys) that are milked for pule-making. It takes 3 gallons of milk to create 1 pound of cheese.',
|
||||||
|
'Edam Cheese never goes bad, it only hardens. This resulted in its popularity at sea and in remote places.',
|
||||||
|
'Sales of Wensleydale cheese strongly improved because of Wallace and Gromit, saving the cheese.'
|
||||||
|
].freeze
|
||||||
|
end
|
||||||
41
src/lists/cheese_of_truth.rb
Normal file
41
src/lists/cheese_of_truth.rb
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
module Lists
|
||||||
|
CHEESE_OF_TRUTH = [
|
||||||
|
"""[Immigrants cause cancer.](https://youtube.com/shorts/S9AgVFNOibs?si=X2XV8E3dch6B2Cqj)
|
||||||
|
(This is just a reference to the vine.)""",
|
||||||
|
"Your bestie is gay.",
|
||||||
|
"Sperm whales can't cum.",
|
||||||
|
"VoxelFoxKae was indeed here.",
|
||||||
|
"I am the cheesiest bot alive.",
|
||||||
|
"You're loved.",
|
||||||
|
"You do not recognize the bodies in the water.",
|
||||||
|
"Never back down, never what? Never give up.",
|
||||||
|
"We are not sorry for party rocking.",
|
||||||
|
"Cats are cool.",
|
||||||
|
"It's muffin time.",
|
||||||
|
"It's pizza time.",
|
||||||
|
"You should try MarriageBot.",
|
||||||
|
"You should try Flower.",
|
||||||
|
"You should try StalkerBot.",
|
||||||
|
"Your bestie has $30000 dollars in credit card debt.",
|
||||||
|
"You're valid.",
|
||||||
|
"Unity sucks.",
|
||||||
|
"You should buy a coffee"
|
||||||
|
].freeze
|
||||||
|
end
|
||||||
|
|
||||||
39
src/lists/cheese_photos.rb
Normal file
39
src/lists/cheese_photos.rb
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
module Lists
|
||||||
|
CHEESE_PHOTOS = [
|
||||||
|
"https://th.bing.com/th/id/OIP.cOvvr0w2LI04ck2r8yKDogHaEK?pid=ImgDet&rs=1",
|
||||||
|
"https://cdn.cnn.com/cnnnext/dam/assets/150529121116-swiss-cheese-live-video.jpg",
|
||||||
|
"https://th.bing.com/th/id/OIP.4FdvM8-87v5F4Fk-MGGX0gAAAA?pid=ImgDet&w=300&h=300&rs=1",
|
||||||
|
"https://img.static-rmg.be/a/view/q75/w718/h/1801996/gruyere-jpg.jpg",
|
||||||
|
"https://th.bing.com/th/id/OIP.BBxFgPD3rDD14sfFes0iNAHaHa?pid=ImgDet&w=1250&h=1250&rs=1",
|
||||||
|
"https://th.bing.com/th/id/OIP.ikZUFeqM9tvZzsENF2DuFAAAAA?pid=ImgDet&w=306&h=369&rs=1",
|
||||||
|
"https://stat.ameba.jp/user_images/20190108/08/golbahorn-mejirobach/b7/d0/j/o0661047314335317934.jpg",
|
||||||
|
"https://th.bing.com/th/id/OIP.DRetaM1i8hMsRE5CmRGgfgHaFj?pid=ImgDet&rs=1",
|
||||||
|
"https://cdn1.vox-cdn.com/uploads/chorus_asset/file/2887320/diet_snacks_cheese.0.jpg",
|
||||||
|
"https://www.drgourmet.com/images/food/swisscheese.jpg",
|
||||||
|
"https://www.babyswiss.com/content/images/thumbs/0000051_2lb-baby-swiss-2lb-premium-swiss-combo.jpeg",
|
||||||
|
"https://www.elreporte.com.uy/wp-content/uploads/2015/06/queso-10407.jpeg",
|
||||||
|
"https://cdn.tasteatlas.com/images/social/e9ef14798ff84fa1afc705b034c18554.jpg",
|
||||||
|
"https://images-prod.healthline.com/hlcmsresource/images/AN_images/healthiest-cheese-1296x728-swiss.jpg",
|
||||||
|
"https://upload.wikimedia.org/wikipedia/commons/d/d9/Gruyere_alpage_th_wa.jpg",
|
||||||
|
"https://www.cartmelcheeses.co.uk/wp-content/uploads/2021/05/IMG_20210523_131813-scaled.jpg",
|
||||||
|
"https://post.healthline.com/wp-content/uploads/2022/04/swiss-cheese-1200x628-facebook-1200x628.jpg",
|
||||||
|
"https://images.theconversation.com/files/316919/original/file-20200224-24701-1lk36vg.jpg?ixlib=rb-1.1.0&q=45&auto=format&w=1200&h=1200.0&fit=crop",
|
||||||
|
"https://dfwblobstorage.blob.core.windows.net/ewcmediacontainer/eatwisconsincheese/media/content/cheesemasters-2019/swiss-cheese-header_2.jpg",
|
||||||
|
].freeze
|
||||||
|
end
|
||||||
105
src/lists/cheese_words.rb
Normal file
105
src/lists/cheese_words.rb
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
module Lists
|
||||||
|
CHEESE_WORDS = [
|
||||||
|
"abertam",
|
||||||
|
"abondance",
|
||||||
|
"acapella",
|
||||||
|
"accasciato",
|
||||||
|
"ackawi",
|
||||||
|
"acorn",
|
||||||
|
"adelost",
|
||||||
|
"backstein",
|
||||||
|
"bergader",
|
||||||
|
"bonifaz",
|
||||||
|
"brie",
|
||||||
|
"burrata",
|
||||||
|
"butterkäse",
|
||||||
|
"cambozola",
|
||||||
|
"camembert",
|
||||||
|
"caseus",
|
||||||
|
"casgiu",
|
||||||
|
"cheddar",
|
||||||
|
"cheese",
|
||||||
|
"cheesy",
|
||||||
|
"chiiz",
|
||||||
|
"chisi",
|
||||||
|
"chizi",
|
||||||
|
"colby",
|
||||||
|
"cottage",
|
||||||
|
"cuku",
|
||||||
|
"cáis",
|
||||||
|
"djathë",
|
||||||
|
"edelpilzkäse",
|
||||||
|
"farmaajo",
|
||||||
|
"feta",
|
||||||
|
"formaggio",
|
||||||
|
"formatge",
|
||||||
|
"fromage",
|
||||||
|
"fromazy",
|
||||||
|
"fromaĝo",
|
||||||
|
"fwomaj",
|
||||||
|
"gazta",
|
||||||
|
"gorgonzola",
|
||||||
|
"gouda",
|
||||||
|
"halloumi",
|
||||||
|
"handkäse",
|
||||||
|
"harzer",
|
||||||
|
"hirtenkäse",
|
||||||
|
"hohenheim",
|
||||||
|
"juust",
|
||||||
|
"juusto",
|
||||||
|
"kaas",
|
||||||
|
"kashkaval",
|
||||||
|
"keju",
|
||||||
|
"keso",
|
||||||
|
"kochkäse",
|
||||||
|
"käse",
|
||||||
|
"limburger",
|
||||||
|
"milbenkäse",
|
||||||
|
"mozzarella",
|
||||||
|
"nieheimer",
|
||||||
|
"obatzda",
|
||||||
|
"ostur",
|
||||||
|
"paneer",
|
||||||
|
"parmesan",
|
||||||
|
"pendir",
|
||||||
|
"penêr",
|
||||||
|
"peynir",
|
||||||
|
"pepperjack",
|
||||||
|
"provolone",
|
||||||
|
"quark",
|
||||||
|
"queijo",
|
||||||
|
"queixo",
|
||||||
|
"queso",
|
||||||
|
"raclette",
|
||||||
|
"rauchkäse",
|
||||||
|
"ricotta",
|
||||||
|
"roquefort",
|
||||||
|
"sajt",
|
||||||
|
"ser",
|
||||||
|
"sires",
|
||||||
|
"sisi",
|
||||||
|
"spundekäs",
|
||||||
|
"swiss",
|
||||||
|
"sūris",
|
||||||
|
"tsiis",
|
||||||
|
"ziegel",
|
||||||
|
"チーズ",
|
||||||
|
"\N{CHEESE WEDGE}"
|
||||||
|
].freeze
|
||||||
|
end
|
||||||
38
src/modules/cheese_checker.rb
Normal file
38
src/modules/cheese_checker.rb
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
require_relative '../lists/cheese_words'
|
||||||
|
|
||||||
|
module CheeseChecker
|
||||||
|
WORDS_LIST = Lists::CHEESE_WORDS
|
||||||
|
PUNCTUATION = "!\"£$%^&*()[]{}'@#~;:,<.>/?-+\\|`¬"
|
||||||
|
|
||||||
|
NO_CHEESE = /[\s#{Regexp.escape(PUNCTUATION)}]*/
|
||||||
|
|
||||||
|
pattern_strings = WORDS_LIST.map do |word|
|
||||||
|
Regexp.escape(word).chars.map { |char| char + NO_CHEESE.source }.join
|
||||||
|
end
|
||||||
|
|
||||||
|
CHEESE_REGEX = /((?:#{pattern_strings.join('|')}))/im
|
||||||
|
|
||||||
|
def self.check_content(content)
|
||||||
|
changed_content = content.gsub(CHEESE_REGEX, "**\\1**")
|
||||||
|
|
||||||
|
return nil if changed_content == content
|
||||||
|
|
||||||
|
changed_content
|
||||||
|
end
|
||||||
|
end
|
||||||
118
src/modules/database.rb
Normal file
118
src/modules/database.rb
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
# cheeseBot
|
||||||
|
# Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
require 'pg'
|
||||||
|
|
||||||
|
module Database
|
||||||
|
DB_NAME = ENV['DB_NAME']
|
||||||
|
DB_USER = ENV['DB_USER']
|
||||||
|
DB_HOST = ENV['DB_HOST']
|
||||||
|
DB_PASSWORD = ENV['DB_PASSWORD']
|
||||||
|
|
||||||
|
def self.setup
|
||||||
|
create_database_if_not_exists
|
||||||
|
create_tables
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.connect(db_name = DB_NAME)
|
||||||
|
PG.connect(
|
||||||
|
dbname: db_name,
|
||||||
|
user: DB_USER,
|
||||||
|
host: DB_HOST,
|
||||||
|
password: DB_PASSWORD
|
||||||
|
)
|
||||||
|
rescue PG::Error => e
|
||||||
|
puts "Database connection error: #{e.message}"
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.user_blacklisted?(user_id)
|
||||||
|
exists?("blacklist", user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.server_blacklisted?(server_id)
|
||||||
|
exists?("server_blacklist", server_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.toggle_user_blacklist(user_id)
|
||||||
|
toggle("blacklist", user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.toggle_server_blacklist(server_id)
|
||||||
|
toggle("server_blacklist", server_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def self.exists?(table, id)
|
||||||
|
conn = connect
|
||||||
|
result = conn.exec_params("SELECT 1 FROM #{table} WHERE id = $1", [id])
|
||||||
|
conn.close
|
||||||
|
!result.ntuples.zero?
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.toggle(table, id)
|
||||||
|
conn = connect
|
||||||
|
|
||||||
|
if exists?(table, id)
|
||||||
|
conn.exec_params("DELETE FROM #{table} WHERE id = $1", [id])
|
||||||
|
conn.close
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
conn.exec_params("INSERT INTO #{table} (id) VALUES ($1)", [id])
|
||||||
|
conn.close
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.create_database_if_not_exists
|
||||||
|
begin
|
||||||
|
conn = connect('postgres')
|
||||||
|
rescue PG::Error
|
||||||
|
puts "Could not connect to 'postgres' system database. Please create '#{DB_NAME}' manually."
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
result = conn.exec_params("SELECT 1 FROM pg_database WHERE datname = $1", [DB_NAME])
|
||||||
|
|
||||||
|
if result.ntuples.zero?
|
||||||
|
puts "Database '#{DB_NAME}' not found. Creating it..."
|
||||||
|
conn.exec("CREATE DATABASE \"#{DB_NAME}\"")
|
||||||
|
puts "Database '#{DB_NAME}' created successfully!"
|
||||||
|
end
|
||||||
|
conn.close
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.create_tables
|
||||||
|
conn = connect
|
||||||
|
|
||||||
|
conn.exec(<<~SQL)
|
||||||
|
CREATE TABLE IF NOT EXISTS blacklist (
|
||||||
|
id BIGINT PRIMARY KEY
|
||||||
|
);
|
||||||
|
SQL
|
||||||
|
|
||||||
|
conn.exec(<<~SQL)
|
||||||
|
CREATE TABLE IF NOT EXISTS server_blacklist (
|
||||||
|
id BIGINT PRIMARY KEY
|
||||||
|
);
|
||||||
|
SQL
|
||||||
|
|
||||||
|
puts "Tables verified."
|
||||||
|
conn.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Reference in New Issue
Block a user