aboutsummaryrefslogtreecommitdiffstats
path: root/include/chat.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-04-26 16:27:03 -0700
committerfriendica <info@friendica.com>2014-04-26 16:27:03 -0700
commite40d2262527df91fe0161d18f2304f7095481874 (patch)
tree5cd9b014604db4a5f577c7ce884c0d8594ed81c7 /include/chat.php
parentd44b7d11a85503ec8398ab7fa73fffc85a1b86df (diff)
downloadvolse-hubzilla-e40d2262527df91fe0161d18f2304f7095481874.tar.gz
volse-hubzilla-e40d2262527df91fe0161d18f2304f7095481874.tar.bz2
volse-hubzilla-e40d2262527df91fe0161d18f2304f7095481874.zip
basic chatterbot support - though these would still require additional functionality in the API to maintain presence as they'll get kicked out of the room if they don't ping it regularly.
Diffstat (limited to 'include/chat.php')
-rw-r--r--include/chat.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/chat.php b/include/chat.php
index 5a17230e0..8e84d9be0 100644
--- a/include/chat.php
+++ b/include/chat.php
@@ -182,3 +182,44 @@ function chatroom_list($uid) {
return $r;
}
+
+/**
+ * create a chat message via API.
+ * It is the caller's responsibility to enter the room.
+ */
+
+function chat_message($uid,$room_id,$xchan,$text) {
+
+ $ret = array('success' => false);
+
+ if(! $text)
+ return;
+
+ $sql_extra = permissions_sql($uid);
+
+ $r = q("select * from chatroom where cr_uid = %d and cr_id = %d $sql_extra",
+ intval($uid),
+ intval($room_id)
+ );
+ if(! $r)
+ return $ret;
+
+ $arr = array(
+ 'chat_room' => $room_id,
+ 'chat_xchan' => $xchan,
+ 'chat_text' => $text
+ );
+
+ call_hooks('chat_message',$arr);
+
+ $x = q("insert into chat ( chat_room, chat_xchan, created, chat_text )
+ values( %d, '%s', '%s', '%s' )",
+ intval($room_id),
+ dbesc($xchan),
+ dbesc(datetime_convert()),
+ dbesc($arr['chat_text'])
+ );
+
+ $ret['success'] = true;
+ return $ret;
+}