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

What command inserts a message?

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

Post a reply
3 posts • Page 1 of 1

Postby Cayenne » Wed Apr 11, 2012 4:09 am

Greetings!

Like a few others, I am trying to programmatically insert messages into my chatroom. I want this to happen without a trigger by the user.

New to this great system, I see that if I add the message to the chat data correctly, it appears in the box. But, of course, I need to do some housekeeping, like knowing what the filename is. Obviously, the program does that somwhere.

Can someone kindly point me to the command that phpFreeChat uses (and of course the file it's in) to stick the message in the place it belongs? I've been reading through the code for the quiz proxy and have not found that particular simple thing.

Thanks! I promise to report back.
Cayenne
New member
 
Posts: 4
Joined: Wed Apr 11, 2012 3:51 am
Top

Postby Cayenne » Wed Apr 11, 2012 6:15 am

Well, I created a pretty hacky approach, and hope someone can lead me back to the path of elegance.
First thing is to be sure you know your server id. I picked one instead of using the default expression

Now. here is the code. You may note that it assumes a chatroom called Ops. You'll want to change that.

Code: Select all
<?php

/********************************
* Post to a chatbox.  This works with phpFreeChat.
* This is a brute force approach, and may step on other messages.
********************************/

$params = array();
$params["title"] = "Team Messages";
$params["channels"] = array("Ops");

$params["serverid"] = 'operations';


function postMe ($message, $id){
  $fname = dirname(__FILE__)."/data/private/chat/s_".$id."/channelid-to-msgid/ch_Ops/lastmsgid";  //that's the last id
  $last = file_get_contents($fname);
  $next= 1+$last;
  print "Last message is $last and next is $next.<br>";
  file_put_contents($fname, $next); //okay, we saved the file namespace
 
  // save the message
  $fname = dirname(__FILE__)."/data/private/chat/s_".$id."/channelid-to-msg/ch_Ops/".trim($next);
  $now = time();
  $payload = $next."   $now   bot   send   $message";
  file_put_contents($fname, $payload);

}

// here is the command.
postMe("Autopost test ", $params["serverid"]);

?>
Cayenne
New member
 
Posts: 4
Joined: Wed Apr 11, 2012 3:51 am
Top

Postby Cayenne » Wed Apr 11, 2012 6:32 am

Aaaand, it looks like I found it. the "write" command in the file pfccontainer.class.php. Okay, input still welcome here!
Cayenne
New member
 
Posts: 4
Joined: Wed Apr 11, 2012 3:51 am
Top


Post a reply
3 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 15 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