summaryrefslogtreecommitdiff
path: root/apps/mm/plugins/SenderIdentica.class.php
blob: ab55eb92d12ebd62a1e996f9079a17122c1e9c59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require_once('Plugin.class.php');
require_once('Identica.class.php');

class SenderIdentica extends Plugin {
	protected $config = array('username'=>'',
	                          'password'=>'',
	                          'length'=>140);
	private $obj;
	
	public static function description() {
		return 'Dent messages to Identi.ca.';
	}
	
	public static function configList() {
		return array('username'=>'text',
		             'password'=>'password',
		             'length'=>'int');
	}
	
	public function init() {
		$this->obj = new Identica($this->config['username'],
		                          $this->config['password']);
	}
	
	public function sendBroadcast($id, $subject, $body) {
		global $shorturl, $messenger;
		$url = $shorturl->get($messenger->id2url($id));
		$maxlen = $this->config['length']-(strlen($url)+1);
		if($maxlen < strlen($subject)) {
			$subject = substr($subject,0,$maxlen-3).'...';
		}
		$this->obj->updateStatus($subject.' '.$url);
	}
}