style changes
This commit is contained in:
parent
9cd136c563
commit
a6c369c6c3
|
@ -1,9 +1,9 @@
|
|||
# bot-specific data
|
||||
uploaded_images/
|
||||
vendor/
|
||||
|
||||
bot_data/
|
||||
.env
|
||||
|
||||
# composer packages
|
||||
vendor/
|
||||
# unneccessary
|
||||
bot.err
|
||||
bot.out
|
||||
*.json
|
||||
!composer.json
|
||||
|
|
29
bot.php
29
bot.php
|
@ -8,12 +8,6 @@ include __DIR__.'/vendor/autoload.php';
|
|||
use Discord\DiscordCommandClient;
|
||||
use Discord\Parts\User\Game;
|
||||
use Discord\Parts\Embed\Embed;
|
||||
use Discord\Parts\Embed\Author;
|
||||
use Discord\Parts\Embed\Image;
|
||||
use Discord\Parts\Embed\Footer;
|
||||
use Discord\Parts\Embed\Field;
|
||||
use Discord\Helpers\Collection;
|
||||
use Discord\Helpers\Process;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
|
@ -28,9 +22,9 @@ $yomamajokes = file("yomamajokes.txt");
|
|||
$jokes = explode("---", file_get_contents(__DIR__.'/miscjokes.txt'));
|
||||
|
||||
$starttime = Carbon::now();
|
||||
$defs = new Definitions(__DIR__.'/definitions.json');
|
||||
$imgs = new Definitions(__DIR__.'/img_urls.json');
|
||||
$cities = new Definitions(__DIR__.'/cities.json');
|
||||
$defs = new Definitions(__DIR__.'/bot_data/definitions.json');
|
||||
$imgs = new Definitions(__DIR__.'/bot_data/img_urls.json');
|
||||
$cities = new Definitions(__DIR__.'/bot_data/cities.json');
|
||||
$help = [];
|
||||
|
||||
|
||||
|
@ -84,7 +78,22 @@ $discord->on('ready', function ($discord) use ($game, $defs, $imgs, $starttime)
|
|||
}
|
||||
}
|
||||
|
||||
if ($msg->channel->guild->id === "233603102047993856") {
|
||||
if (strpos(strtolower($text), 'dib') !== false) {
|
||||
$msg->react(":dib:284335774823088129")->otherwise(function ($e) {
|
||||
echo $e->getMessage(), PHP_EOL;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// if (!$msg->author->bot) {
|
||||
// if (checkForSwears(strtolower($text))) {
|
||||
// echo "someone swore", PHP_EOL;
|
||||
// $msg->react("‼")->otherwise(function ($e) {
|
||||
// echo $e->getMessage(), PHP_EOL;
|
||||
// });
|
||||
//}
|
||||
// }
|
||||
|
||||
});
|
||||
|
||||
|
@ -742,7 +751,7 @@ registerHelp('img');
|
|||
|
||||
|
||||
$img->registerSubCommand('list', function ($msg, $args) use ($imgs) {
|
||||
send($msg, "list of uploaded images:\n\n" . implode(", ", $imgs->list_keys()));
|
||||
send($msg, "list of uploaded images:\n\n" . implode(", ", $imgs->getKeys()));
|
||||
}, [
|
||||
'description' => 'saved image list',
|
||||
]);
|
||||
|
|
|
@ -4,47 +4,58 @@ class Definitions {
|
|||
protected $defs;
|
||||
protected $filepath;
|
||||
|
||||
public function __construct($filepath = __DIR__.'/definitions.json') {
|
||||
public function __construct($filepath = __DIR__.'/definitions.json')
|
||||
{
|
||||
$this->filepath = $filepath;
|
||||
$this->defs = json_decode(file_get_contents($filepath), true);
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
public function __toString()
|
||||
{
|
||||
return print_r($this->defs, true);
|
||||
}
|
||||
|
||||
public function get($key, $nullable = false) {
|
||||
public function get($key, $nullable = false)
|
||||
{
|
||||
return $this->defs[$key] ?? ($nullable ? false : "**not set**");
|
||||
}
|
||||
|
||||
public function set($key, $val) {
|
||||
public function set($key, $val)
|
||||
{
|
||||
$this->defs[$key] = $val;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function unset($key) {
|
||||
public function unset($key)
|
||||
{
|
||||
unset($this->defs[$key]);
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function list_keys() {
|
||||
public function getKeys()
|
||||
{
|
||||
return array_keys($this->defs);
|
||||
}
|
||||
|
||||
public function save() {
|
||||
private function save()
|
||||
{
|
||||
file_put_contents($this->filepath, json_encode($this->defs));
|
||||
}
|
||||
|
||||
public function print() {
|
||||
public function print()
|
||||
{
|
||||
$ret = [];
|
||||
foreach ($this->defs as $key => $val)
|
||||
foreach ($this->defs as $key => $val) {
|
||||
$ret[] = $key . ": " . $val;
|
||||
}
|
||||
return implode(", ", $ret);
|
||||
}
|
||||
|
||||
public function iter() {
|
||||
foreach ($this->defs as $key => $val)
|
||||
public function iter()
|
||||
{
|
||||
foreach ($this->defs as $key => $val) {
|
||||
yield $key => $val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -336,3 +336,7 @@ $bs = ":ok_hand: :joy:
|
|||
:joy: :ok_hand:
|
||||
:joy: :ok_hand:
|
||||
:ok_hand:";
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
1477
miscjokes.txt
1477
miscjokes.txt
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
|||
anal|anus|arse|ass|ballsack|balls|bastard|bitch|biatch|bloody|blowjob|blow job|bollock|bollok|boner|boob|bugger|bum|butt|buttplug|clitoris|cock|coon|crap|cunt|damn|dick|dildo|dyke|fag|feck|fellate|fellatio|felching|fuck|f u c k|fudgepacker|fudge packer|flange|Goddamn|God damn|hell|homo|jerk|jizz|knobend|knob end|labia|lmao|lmfao|muff|nigger|nigga|omg|penis|piss|poop|prick|pube|pussy|queer|scrotum|shit|s hit|sh1t|slut|smegma|spunk|tit|tosser|turd|twat|vagina|wank|whore|jesus|ni🅱🅱a
|
16
util_fns.php
16
util_fns.php
|
@ -61,8 +61,8 @@ function asciiFromImg($filepath)
|
|||
];
|
||||
$chars = array_reverse($chars);
|
||||
$c_count = count($chars);
|
||||
for($y = 0; $y <= $height - $scale - 1; $y += $scale) {
|
||||
for($x = 0; $x <= $width - ($scale / 2) - 1; $x += ($scale / 2)) {
|
||||
for ($y = 0; $y <= $height - $scale - 1; $y += $scale) {
|
||||
for ($x = 0; $x <= $width - ($scale / 2) - 1; $x += ($scale / 2)) {
|
||||
$rgb = imagecolorat($img, $x, $y);
|
||||
$r = (($rgb >> 16) & 0xFF);
|
||||
$g = (($rgb >> 8) & 0xFF);
|
||||
|
@ -75,6 +75,18 @@ function asciiFromImg($filepath)
|
|||
return $ret;
|
||||
}
|
||||
|
||||
function checkForSwears($text)
|
||||
{
|
||||
$text = $text;
|
||||
$bad_words = file_get_contents(__DIR__.'/swearWords.txt');
|
||||
$b = '/\W' . $bad_words . '\W/i';
|
||||
|
||||
if(preg_match($b, $text)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fahr($celsius)
|
||||
|
|
Loading…
Reference in New Issue