add license, start music and tictactoe

This commit is contained in:
Ben Harris 2017-04-16 13:59:33 -04:00
parent 96fd7d2ea4
commit b7a116c827
5 changed files with 123 additions and 1 deletions

21
LICENSE.md Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Ben Harris
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -30,6 +30,7 @@ class BenBot extends Discord {
public $yomamajokes;
public $copypastas;
public $devbot;
public $chatgame;
protected $help;
protected $game;
@ -54,7 +55,8 @@ class BenBot extends Discord {
$this->copypastas = explode("---", file_get_contents("$dir/copypasta.txt"));
$this->yomamajokes = file("$dir/yomamajokes.txt");
$this->banner = file_get_contents("{$this->dir}/banner.txt");
$this->devbot = false;
$this->devbot = true;
$this->chatgame = [];
$this->game = $this->factory(Game::class, [
@ -197,6 +199,8 @@ class BenBot extends Discord {
Commands\Images::register($this);
Commands\Jokes::register($this);
Commands\Misc::register($this);
Commands\Music::register($this);
Commands\Poll::register($this);
Commands\Time::register($this);
Commands\Weather::register($this);
}

31
src/Commands/Music.php Normal file
View File

@ -0,0 +1,31 @@
<?php
namespace BenBot\Commands;
use BenBot\Utils;
class Music {
private static $bot;
public static function register(&$that)
{
self::$bot = $that;
self::$bot->registerCommand('play', [__CLASS__, 'playSong'], [
'description' => 'plays',
]);
echo __CLASS__ . " registered", PHP_EOL;
}
public static function playSong($msg, $args)
{
self::$bot->joinVoiceChannel($msg->channel)->then(function (VoiceClient $vc) {
echo "joined voice channel", PHP_EOL;
$vc->playFile(self::$bot->dir . "/music/mytype.m4a");
}, function ($e) {
echo "there was an error joining the voice channel: {$e->getMessage()}", PHP_EOL, $e->getTraceAsString(), PHP_EOL;
});
}
}

43
src/Commands/Poll.php Normal file
View File

@ -0,0 +1,43 @@
<?php
namespace BenBot\Commands;
use BenBot\Utils;
class Poll {
private static $bot;
public static function register(&$that)
{
self::$bot = $that;
self::$bot->registerCommand('poll', [__CLASS__, 'createPoll'], [
'description' => 'yes/no poll. lasts 30 seconds.',
'usage' => '<question>',
'registerHelp' => true,
]);
echo __CLASS__ . " registered", PHP_EOL;
}
public static function createPoll($msg, $args)
{
$question = implode(" ", $args);
$response = "{$msg->author}'s poll:\n**$question**";
echo $response, PHP_EOL;
Utils::send($msg, $response)->then(function ($result) use ($msg) {
print_r($result);
Utils::deleteMessage($msg);
$result->react("👍");
$result->react("👎");
self::$bot->loop->addTimer(30, function ($timer) use ($result) {
Utils::deleteMessage($result);
});
});
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace BenBot\Commands;
use BenBot\Utils;
class TicTacToe {
private static $bot;
public static function register(&$that)
{
self::$bot = $that;
echo __CLASS__ . " registered", PHP_EOL;
}
public static function startGame($msg, $args)
{
}
}