public function handlePaste(&$irc, $msg, $channel, $matches, $who) { if (!isset($this->currentPastes[$who])) { $this->currentPastes[$who] = array('text' => '', 'public' => false, 'lang' => ''); $irc->sayToChannel($who . ': you can write your paste now or use .paste [send|private|public|cancel|lang <py|md|php|rb|(...)>]', $channel); } if (isset($matches[1])) { switch ($matches[1]) { case 'send': case 'submit': $gist = new gist(); $gist->setFileName('PHPIdler' . (isset($this->currentPastes[$who]['lang']) ? '.' . $this->currentPastes[$who]['lang'] : '')); $gist->setPublic($this->currentPastes[$who]['public']); $gist->paste($this->currentPastes[$who]['text']); $irc->sayToChannel($who . ': ' . ($gist->getResult('html_url') ? $gist->getResult('html_url') : 'couldn\'t create a new gist'), $channel); unset($this->currentPastes[$who]); break; case 'private': $this->currentPastes[$who]['public'] = false; $irc->sayToChannel($who . ': your paste will be private', $channel); break; case 'public': $this->currentPastes[$who]['public'] = true; $irc->sayToChannel($who . ': your paste will be public', $channel); break; case 'cancel': unset($this->currentPastes[$who]); $irc->sayToChannel($who . ': paste cancelled', $channel); break; case 'lang': if (isset($matches[2])) { $this->currentPastes[$who]['lang'] = $matches[2]; $irc->sayToChannel($who . ': your paste will be highlighted as ' . $matches[2], $channel); break; } else { $irc->sayToChannel($who . ': try .paste lang rb/php/py/etc... ' . $matches[2], $channel); } break; default: $irc->sayToChannel($who . ': usage: .paste [send|private|public|cancel|lang <py|md|php|rb|(...)>]', $channel); break; } } if (sizeof($this->currentPastes) === 0 and $this->handlerId != null) { $irc->removeActionHandler($this->handlerId); $this->handlerId = null; } elseif (sizeof($this->currentPastes) !== 0 and $this->handlerId === null) { $this->handlerId = $irc->addActionHandler($this, 'addText', '/.*/'); } }
<?php /* Plugin Name: oEmbed Gist Plugin URI: https://github.com/miya0001/oembed-gist Description: Embed source from gist.github. Author: Takayuki Miyauchi Version: 2.0.1 Author URI: http://firegoby.jp/ */ $oe_gist = new gist(); $oe_gist->register(); class gist { private $shotcode_tag = 'gist'; private $noscript; private $regex = '#(https://gist.github.com/([^\\/]+\\/)?([a-zA-Z0-9]+)(\\/[a-zA-Z0-9]+)?)(\\#file(\\-|_)(.+))?$#i'; function register() { add_action('plugins_loaded', array($this, 'plugins_loaded')); } public function plugins_loaded() { add_action('wp_head', array($this, 'wp_head')); load_plugin_textdomain('oembed-gist', false, dirname(plugin_basename(__FILE__)) . '/languages'); wp_embed_register_handler('oe-gist', $this->get_gist_regex(), array($this, 'handler')); add_shortcode($this->get_shortcode_tag(), array($this, 'shortcode')); add_filter('jetpack_shortcodes_to_include', array($this, 'jetpack_shortcodes_to_include')); add_filter('oembed_providers', array($this, 'oembed_providers')); } public function jetpack_shortcodes_to_include($incs)