3 * Name: IRC Chat Plugin
4 * Description: add an Internet Relay Chat chatroom
6 * Author: tony baldwin <https://free-haven.org/profile/tony>
9 /* enable in admin->plugins
10 * you will then have "irc chatroom" listed at yoursite/apps
11 * and the app will run at yoursite/irc
12 * documentation at http://tonybaldwin.me/hax/doku.php?id=friendica:irc
13 * admin can set popular chans, auto connect chans in settings->plugin settings
16 function irc_install() {
17 register_hook('app_menu', 'addon/irc/irc.php', 'irc_app_menu');
18 register_hook('plugin_settings', 'addon/irc/irc.php', 'irc_addon_settings');
19 register_hook('plugin_settings_post', 'addon/irc/irc.php', 'irc_addon_settings_post');
22 function irc_uninstall() {
23 unregister_hook('app_menu', 'addon/irc/irc.php', 'irc_app_menu');
24 unregister_hook('plugin_settings', 'addon/irc/irc.php', 'irc_addon_settings');
29 function irc_addon_settings(&$a,&$s) {
35 /* Add our stylesheet to the page so we can make our settings look nice */
37 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/irc/irc.css' . '" media="all" />' . "\r\n";
39 /* setting popular channels, auto connect channels */
40 $sitechats = get_config('irc','sitechats'); /* popular channels */
41 $autochans = get_config('irc','autochans'); /* auto connect chans */
43 $s .= '<div class="settings-block">';
44 $s .= '<h3>' . t('IRC Settings') . '</h3>';
45 $s .= '<div id="irc-chans">';
46 $s .= '<label id="irc-auto-label" for="autochans">' . t('Channel(s) to auto connect (comma separated)') . '</label>';
47 $s .= '<input id="irc-autochans" type="text" name="autochans" value="' . $autochans .'" />';
48 $s .= '</div><div class="clear"></div>';
50 $s .= '<div id="irc-popchans">';
51 $s .= '<label id="irc-pop-label" for="sitechats">' . t('Popular Channels (comma separated)') . '</label>';
52 $s .= '<input id="irc-sitechats" type="text" name="sitechats" value="' . $sitechats.'" />';
53 $s .= '</div><div class="clear"></div>';
55 $s .= '<div class="settings-submit-wrapper" ><input type="submit" id="irc-submit" name="irc-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
61 function irc_addon_settings_post(&$a,&$b) {
65 if($_POST['irc-submit']) {
66 set_config('irc','autochans',trim($_POST['autochans']));
67 set_config('irc','sitechats',trim($_POST['sitechats']));
68 /* stupid pop-up thing */
69 info( t('IRC settings saved.') . EOL);
73 function irc_app_menu($a,&$b) {
74 $b['app_menu'][] = '<div class="app-title"><a href="irc">' . t('IRC Chatroom') . '</a></div>';
78 function irc_module() {
83 function irc_content(&$a) {
85 $baseurl = $a->get_baseurl() . '/addon/irc';
88 /* set the list of popular channels */
89 $sitechats = get_config('irc','sitechats');
91 $chats = explode(',',$sitechats);
93 $chats = array('friendica','chat','chatback','hottub','ircbar','dateroom','debian');
96 $a->page['aside'] .= '<div class="widget"><h3>' . t('Popular Channels') . '</h3><ul>';
97 foreach($chats as $chat) {
98 $a->page['aside'] .= '<li><a href="' . $a->get_baseurl() . '/irc?channels=' . $chat . '" >' . '#' . $chat . '</a></li>';
100 $a->page['aside'] .= '</ul></div>';
102 /* setting the channel(s) to auto connect */
103 $autochans = get_config('irc','autochans');
105 $channels = $autochans;
107 $channels = ((x($_GET,'channels')) ? $_GET['channels'] : 'friendica');
109 /* add the chatroom frame and some html */
112 <p><a href="http://tldp.org/HOWTO/IRC/beginners.html" target="_blank">A beginner's guide to using IRC. [en]</a></p>
113 <iframe src="//webchat.freenode.net?channels=$channels" width="600" height="600"></iframe>