summaryrefslogtreecommitdiff
path: root/src/plugins/SenderIdentica.class.php
blob: ea9b3430653f365f6a146a84beb7f228eb146dde (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('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);
	}
}