• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

/topic Command

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
13 posts • Page 1 of 1

Postby Jaybird » Mon Jun 28, 2010 9:59 am

Hello everyone,

I have written a /topic command.. it stores the topic in chanmeta data and works with sites that have multiple rooms, only operators and admins can change the topic.

/src/commands/topic.class.php
Code: Select all
<?php

require_once(dirname(__FILE__)."/../pfccommand.class.php");

class pfcCommand_topic extends pfcCommand
{
  var $usage = "/topic {message}";

  function run(&$xml_reponse, $p)
  {
    $clientid    = $p["clientid"];
    $param       = $p["param"];
    $sender      = $p["sender"];
    $recipient   = $p["recipient"];
    $recipientid = $p["recipientid"];
   
    $c  =& pfcGlobalConfig::Instance();
    $u  =& pfcUserConfig::Instance();
    $ct =& pfcContainer::Instance();

    $isadmin = $ct->getUserMeta($u->nickid, 'isadmin');

    if (trim($param) == "")
    {
   $room = str_replace('ch_', "", $recipient);
   $topic = $ct->getChanMeta($recipient, "topic");
   $ct->write($recipient, "*notice*", $this->name, "[b]".$room."[/b] - current topic: [i][u]".$topic."[/i][/u]");
    return;
    }
    if ($isadmin) {
        $msg = phpFreeChat::PreFilterMsg($param);
   $ct->setChanMeta($recipient, "topic", $msg);
   $cmdp = $p;
   $cmdp["recipient"] = $recipient;
   $cmdp["recipientid"] = $recipientid;
   $cmdp["param"] = _pfc('%s changes the topic to: %s',$u->getNickname(), $msg);
   $cmd =& pfcCommand::Factory("notice");
   $cmd->run($xml_reponse, $cmdp);
    }else{
    $xml_reponse->script("pfc.handleResponse('help', 'ok', 'only ops can change the topic');");
 }
}

?>

Add this next line to the main.php file for the language your using. These files are located in the /i18n/ folder.

example: /i18n/en_US/main.php (line 405)
Code: Select all
// topic.class.php
$GLOBALS["i18n"]["%s changes the topic to: %s"] = "%s changes the topic to: %s";

Then add these few lines to /join to display the topic to the room when a new user enters.

/src/commands/join.php (line 56)
Code: Select all
//topic displayed when joining
$topic = $ct->getChanMeta($chanrecip, "topic");
if ($topic != ""){
$ct->write($chanrecip, "*notice*", "topic", "[b]".$channame."[/b] - current topic: [i][u]".$topic."[/i][/u]");
} else {
$ct->write($chanrecip, "*notice*", "topic", "[b]".$channame."[/b] - current topic: [i][u]no topic set[/i][/u]");
}

enjoy!
Last edited by Jaybird on Mon Jun 28, 2010 6:36 pm, edited 1 time in total.
Jaybird
Member
 
Posts: 65
Joined: Mon Jun 28, 2010 7:59 am
Top

Postby DreadPirateVane » Sun Jul 04, 2010 1:59 am

so how do you set the topic?
Station Built by the Bands,, For the Fans!!
DreadPirateVane
Member
 
Posts: 47
Joined: Tue Dec 23, 2008 10:44 pm
Location: Kansas City, Mo.
  • Website
  • YIM
Top

Postby Jaybird » Sun Jul 04, 2010 7:59 am

only admins can set the topic.. to set the topic type: /topic (the topic)
Jaybird
Member
 
Posts: 65
Joined: Mon Jun 28, 2010 7:59 am
Top

Postby TheSeaKing » Fri Aug 20, 2010 7:50 am

How does the topic command do exactly?
Does it show a topic at the top of the chat?
TheSeaKing
Member
 
Posts: 21
Joined: Sat Nov 22, 2008 6:40 am
Top

Postby Jaybird » Mon Aug 23, 2010 11:20 pm

it doesn't show at the top of the chat, it displays when a new user joins the chat.. or when you type /topic

admins can type /topic <message> to change the topic.. Works in every chatroom, and also private messages..
Jaybird
Member
 
Posts: 65
Joined: Mon Jun 28, 2010 7:59 am
Top

Postby siwula » Tue Nov 16, 2010 7:30 pm

It doesn't work for me. Chat screen is going blank after reloading. No messagess, no userlist. Any solution?
siwula
Member
 
Posts: 10
Joined: Sun Oct 10, 2010 3:43 pm
Top

Postby bhootnath » Fri Nov 26, 2010 9:04 pm

1. one closing bracket missing from the first section of code.. add that..
2. make sure that the lines you adding to join.php or join.class.php for newer versions.. it is after the line which reads..

Code: Select all
// register the user (and his metadata) in the channel
$ct =& pfcContainer::Instance();

it should work after these two changes..
bhootnath
Member
 
Posts: 13
Joined: Fri Nov 19, 2010 10:12 pm
Top

Postby siwula » Mon Nov 29, 2010 7:03 pm

Thanks. Works great!

One more question. How to display current topic ONLY for user who is joining chat, not for everyone?
And how to disable topic or set to none (no topic)?
Last edited by siwula on Mon Nov 29, 2010 7:24 pm, edited 1 time in total.
siwula
Member
 
Posts: 10
Joined: Sun Oct 10, 2010 3:43 pm
Top

Postby bhootnath » Mon Nov 29, 2010 10:56 pm

am myself looking for that.. it is kind of annoying for everyone else to see the topic every time a new user joins the chat.. also when some user has a bad connection and he keeps on timing out the topic keeps on popping again and again whenever that user is connection is back... that is the reason that i have the notification disabled currently.. and if you wanna see the topic you have to type in topic command...

not sure if there is a way built in the code to show a message to one specific user.. first trying to look if there is something already built in which that will allow the notification to show in the chat window of only the new user.. if not then will work on a hack/ patch to do so...

there is no disabling the topic but it can be blank and in that case users will get the notification that no topic has been set.
bhootnath
Member
 
Posts: 13
Joined: Fri Nov 19, 2010 10:12 pm
Top

Postby radionow » Thu Dec 09, 2010 10:57 pm

Does this work when using the MySQL container?
My Site: http://chickentalk.org/
radionow
Member
 
Posts: 57
Joined: Sun Jan 10, 2010 6:26 pm
Top

Postby bhootnath » Fri Dec 10, 2010 7:10 pm

yes it does.. am using the MySQL container.. even that chat log is in MySQL for my chat...
bhootnath
Member
 
Posts: 13
Joined: Fri Nov 19, 2010 10:12 pm
Top

Postby SSamiK » Wed Feb 09, 2011 2:45 am

Anyone had any progress showing this only to new users?
SSamiK
Member
 
Posts: 14
Joined: Thu Dec 09, 2010 12:24 am
Top

Postby rick001 » Tue Oct 18, 2011 11:36 pm

Thanks ppl :) though i do need help with chatting in bold in real time and also it would be nice if you guys could tell me how to add diff font styles for the user to select while chatting
rick001
Member
 
Posts: 35
Joined: Sun Oct 16, 2011 1:28 pm
Top


Post a reply
13 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 18 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub