Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3b24e9e
Rename CSS class
fguillot Jan 8, 2017
bfc5e26
Fix bug concerning task overdue events
fguillot Mar 2, 2017
6bea6eb
Extract method to send message to group chat
fguillot Mar 2, 2017
d46c8cd
Update Travis settings
fguillot Sep 12, 2017
68be99a
Initial code import
manuvarkey Dec 23, 2017
1540a18
Reduce icon size
manuvarkey Dec 23, 2017
d80f18a
Fix issues. Basic integration successful.
manuvarkey Dec 23, 2017
3b82bcc
Notification interface working
manuvarkey Dec 24, 2017
7502f16
First stable release with documentation
manuvarkey Dec 24, 2017
ca2ca64
Minor fixes
manuvarkey Dec 24, 2017
1075eb5
Minor corrections
manuvarkey Dec 24, 2017
d3b80f3
Update translations.php
Dec 25, 2017
696f567
Merge pull request #1 from urbalazs/hun
manuvarkey Dec 25, 2017
bbb3aa4
Uncomment translations
manuvarkey Dec 25, 2017
13ac009
Edit Readme
manuvarkey Dec 25, 2017
d8a3403
More detailed notifications
manuvarkey Jan 5, 2018
114bc0e
Bump up version
manuvarkey Jan 6, 2018
ac59cb6
Added disclaimer regarding curl error on windows
manuvarkey Jan 8, 2018
d662f01
Update README.md
manuvarkey Jan 8, 2018
17c83ec
Fix bug in sending files uploaded using screenshot option
manuvarkey Feb 12, 2018
abca39e
Translate to russian language
vistar Feb 12, 2018
eb4449b
Fix mistakes
vistar Feb 12, 2018
617bfc7
Merge pull request #4 from vistar/patch-1
manuvarkey Feb 12, 2018
84ca0a0
Merge pull request #5 from vistar/patch-2
manuvarkey Feb 12, 2018
a6f8d48
Do not show description if nil
manuvarkey Feb 14, 2018
755b85c
automation of receive chat_id
linvinus Feb 22, 2018
d49f5c3
improved code formatting
linvinus Feb 22, 2018
5ab7470
improve offset handling
linvinus Feb 22, 2018
28f67ae
German translation
sfahrenholz Feb 22, 2018
ae5f359
Notify user if telegram bot is not configured.
linvinus Feb 22, 2018
ae8f4bc
code cleanup
linvinus Feb 22, 2018
812062c
fix php error in some cases
linvinus Feb 23, 2018
cf68083
store icon in Asset directory according to https://github.com/kanboar…
linvinus Feb 24, 2018
f4d5107
Merge pull request #7 from sfahrenholz/sfahrenholz-german-translation
manuvarkey Feb 25, 2018
7763957
Merge pull request #6 from linvinus/chat_id_automation
manuvarkey Feb 25, 2018
4c4c1aa
Update README.me for automated retreival of chatid
manuvarkey Feb 25, 2018
9196523
merge with current master
linvinus Feb 25, 2018
b240160
Merge pull request #8 from linvinus/fix_asset
manuvarkey Feb 25, 2018
9ebe48a
Bug fixes, code cleanup
manuvarkey Mar 21, 2018
10b3e72
Update translations.php
manuvarkey Apr 5, 2018
55ec08c
Update plugin version
kenlog Feb 3, 2019
5125aaa
Merge pull request #15 from kenlog/patch-1
manuvarkey Feb 6, 2019
510c578
Update translation of the Italian language
kenlog Mar 6, 2019
f2deb44
Merge pull request #16 from kenlog/patch-2
manuvarkey Mar 7, 2019
042da7e
Update es_Es translation
rodoviario Mar 31, 2019
073e633
Merge pull request #17 from rodoviario/patch-1
manuvarkey Apr 1, 2019
281f8b0
Expand translations, add support for proxy
manuvarkey Apr 26, 2019
9bd3fdd
Preventing non-numeric offset
benchonaut Jun 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

Binary file added Asset/telegram-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
160 changes: 160 additions & 0 deletions Controller/TelegramController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<?php
namespace Kanboard\Plugin\Telegram\Controller;

use Kanboard\Controller\BaseController;
use Kanboard\Core\Controller\AccessForbiddenException;

use Longman\TelegramBot\Request;
use Longman\TelegramBot\Telegram as TelegramClass;
use Longman\TelegramBot\Exception\TelegramException;
use Kanboard\Core\Base;

class TelegramController extends BaseController
{
public function get_user_chat_id()
{
$user = $this->getUser();
//$this->checkCSRFParam();
$apikey = $this->userMetadataModel->get($user['id'], 'telegram_apikey', $this->configModel->get('telegram_apikey'));
$bot_username = $this->userMetadataModel->get($user['id'], 'telegram_username', $this->configModel->get('telegram_username'));
try {
$offset = 0 + (int)$this->userMetadataModel->get($user['id'], 'telegram_offset', $this->configModel->get('telegram_offset'));
} catch (Exception $e) {
$offset=0;
}

// Preventing "A non-numeric value encountered in /var/www/app/plugins/Telegram/Controller/TelegramController.php"

$offset = 0 + $this->userMetadataModel->get($user['id'], 'telegram_offset', $this->configModel->get('telegram_offset'));
$private_message = mb_substr(urldecode($this->request->getStringParam('private_message')), 0, 32);

list($offset, $chat_id, $user_name) = $this->get_chat_id($apikey, $bot_username, $offset, $private_message);

if ($offset != 0)
{
//ok
$this->userMetadataModel->save($user['id'], array('telegram_offset' => $offset));
$this->response->html($this->template->render('telegram:user/save_chat_id', array('chat_id' => $chat_id, 'user_name' => $user_name, 'private_message' => $private_message, 'bot_url' => "https://t.me/" . $bot_username, 'user' => $user)));
}
else
{
//error
$this->response->redirect($this->helper->url->to('UserViewController', 'integrations', array('user_id' => $user['id'])), true);
}
}

public function get_project_chat_id()
{
$project = $this->getProject();
//$this->checkCSRFParam();
$apikey = $this->projectMetadataModel->get($project['id'], 'telegram_apikey', $this->configModel->get('telegram_apikey'));
$bot_username = $this->projectMetadataModel->get($project['id'], 'telegram_username', $this->configModel->get('telegram_username'));
$offset = 0 + $this->projectMetadataModel->get($project['id'], 'telegram_offset', $this->configModel->get('telegram_offset'));
$private_message = mb_substr(urldecode($this->request->getStringParam('private_message')), 0, 32);

list($offset, $chat_id, $user_name) = $this->get_chat_id($apikey, $bot_username, $offset, $private_message);

if ($offset != 0)
{
//ok
$this->projectMetadataModel->save($project['id'], array('telegram_offset' => $offset));
$this->response->html($this->template->render('telegram:project/save_chat_id', array('chat_id' => $chat_id, 'user_name' => $user_name, 'private_message' => $private_message, 'bot_url' => "https://t.me/" . $bot_username, 'project' => $project)));
}
else
{
//error
$this->response->redirect($this->helper->url->to('ProjectViewController', 'integrations', array('project_id' => $project['id'])), true);
}
}

private function get_chat_id($apikey, $bot_username, $offset, $private_message)
{
try
{
if (empty($private_message) || mb_strlen($private_message) != 32)
{
throw new TelegramException("empty private_message!");
}

// Create Telegram API object
$telegram = new TelegramClass($apikey, $bot_username);

$limit = 100;
$timeout = 1;
$response = Request::getUpdates(['offset' => $offset + 1, 'limit' => $limit, 'timeout' => $timeout, ]);

$chat_id = "";
$user_name = "";

if ($response->isOk())
{
//Process all updates

/** @var Update $result */
foreach ((array)$response->getResult() as $result)
{
$offset = $result->getUpdateId();
if ($result->getMessage() != NULL)
{
if ($private_message === mb_substr(trim($result->getMessage()->getText()), 0, 32))
{
$chat_id = $result->getMessage()->getChat()->getId();
$user_name = $result->getMessage()->getChat()->getFirstName();
break;
}
}
}
}
else
{
throw new TelegramException($response->printError(true));
}
}
catch(TelegramException $e)
{
// log telegram errors
error_log($e->getMessage());
$this->flash->failure(t('Telegram error: ') . $e->getMessage());
return 0; //$this->response->redirect($this->helper->url->to('UserViewController', 'integrations', array('user_id' => $user['id'] )), true);

}

return array($offset, $chat_id, $user_name);
}

public function save_user_chat_id()
{
$user = $this->getUser();
$this->checkCSRFParam();

$chat_id = urldecode($this->request->getStringParam('chat_id'));
if (is_numeric($chat_id))
{
$this->userMetadataModel->save($user['id'], array('telegram_user_cid' => $chat_id));
$this->flash->success(t("Chat id was updated to %s", $chat_id));
}
else
{
$this->flash->failure(t('Telegram error: wrong chat id'));
}
return $this->response->redirect($this->helper->url->to('UserViewController', 'integrations', array('user_id' => $user['id'])), true);
}

public function save_project_chat_id()
{
$project = $this->getProject();
$this->checkCSRFParam();

$chat_id = urldecode($this->request->getStringParam('chat_id'));
if (is_numeric($chat_id))
{
$this->projectMetadataModel->save($project['id'], array('telegram_group_cid' => $chat_id));
$this->flash->success(t("Chat id was updated to %s", $chat_id));
}
else
{
$this->flash->failure(t('Telegram error: wrong chat id'));
}
return $this->response->redirect($this->helper->url->to('ProjectViewController', 'integrations', array('project_id' => $project['id'])), true);
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2015 Frédéric Guillot
Copyright (c) 2017 Manu Varkey

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
28 changes: 21 additions & 7 deletions Locale/cs_CZ/translations.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
<?php

return array(
// 'Jabber (XMPP)' => '',
// 'XMPP server address' => '',
// 'Jabber domain' => '',
// 'Jabber nickname' => '',
// 'Multi-user chat room' => '',
// 'Help on Jabber integration' => '',
// 'The server address must use this format: "tcp://hostname:5222"' => '',
// 'Telegram' => '',
// 'Telegram bot username' => '',
// 'Telegram bot API key' => '',
// 'Chat id of private chat with bot' => '',
// 'Chat id of group chat with bot' => '',
// 'Help on how to generate a bot' => '',
// 'Sent attachments along with notification' => '',
// 'Telegram bot is not configured in Kanboard settings.' => '',
// 'Go to ' => '',
// 'Settings > Integrations > Telegram' => '',
// ' and fill the form:' => '',
// 'Telegram bot username: Username of your Telegram Bot' => '',
// 'Telegram bot API key: HTTP API token generated by BotFather after bot creation' => '',
// 'Save Chat ID' => '',
// 'Message %s not found!' => '',
// 'Please send message %s ' => '',
// 'Save chat id="%s" from "%s"?' => '',
// 'To get your Telegram chat id,' => '',
// '1. Send the message %s to' => '',
// '2. Press' => '',
// 'Get chat id' => '',
);

28 changes: 21 additions & 7 deletions Locale/da_DK/translations.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
<?php

return array(
// 'Jabber (XMPP)' => '',
// 'XMPP server address' => '',
// 'Jabber domain' => '',
// 'Jabber nickname' => '',
// 'Multi-user chat room' => '',
// 'Help on Jabber integration' => '',
// 'The server address must use this format: "tcp://hostname:5222"' => '',
// 'Telegram' => '',
// 'Telegram bot username' => '',
// 'Telegram bot API key' => '',
// 'Chat id of private chat with bot' => '',
// 'Chat id of group chat with bot' => '',
// 'Help on how to generate a bot' => '',
// 'Sent attachments along with notification' => '',
// 'Telegram bot is not configured in Kanboard settings.' => '',
// 'Go to ' => '',
// 'Settings > Integrations > Telegram' => '',
// ' and fill the form:' => '',
// 'Telegram bot username: Username of your Telegram Bot' => '',
// 'Telegram bot API key: HTTP API token generated by BotFather after bot creation' => '',
// 'Save Chat ID' => '',
// 'Message %s not found!' => '',
// 'Please send message %s ' => '',
// 'Save chat id="%s" from "%s"?' => '',
// 'To get your Telegram chat id,' => '',
// '1. Send the message %s to' => '',
// '2. Press' => '',
// 'Get chat id' => '',
);

28 changes: 21 additions & 7 deletions Locale/de_DE/translations.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
<?php

return array(
'Jabber (XMPP)' => 'Jabber (XMPP)',
'XMPP server address' => 'XMPP-Server-Adresse',
'Jabber domain' => 'Jabber-Domain',
'Jabber nickname' => 'Jabber-Nickname',
'Multi-user chat room' => 'Multi-User-Chatroom',
'Help on Jabber integration' => 'Hilfe zur Jabber-Integration',
'The server address must use this format: "tcp://hostname:5222"' => 'Die Server-Adresse muss in diesem Format sein: "tcp://hostname:5222"',
'Telegram' => 'Telegram',
'Telegram bot username' => 'Telegram Bot Benutzername',
'Telegram bot API key' => 'API Schlüssel für Telegram Bot',
'Chat id of private chat with bot' => 'Chat ID für privaten Chat mit dem Bot',
'Chat id of group chat with bot' => 'Chat ID für den Gruppen Chat mit dem Bot',
'Help on how to generate a bot' => 'Hilfe für das Erzeugen eines Bots',
// 'Sent attachments along with notification' => '',
// 'Telegram bot is not configured in Kanboard settings.' => '',
// 'Go to ' => '',
// 'Settings > Integrations > Telegram' => '',
// ' and fill the form:' => '',
// 'Telegram bot username: Username of your Telegram Bot' => '',
// 'Telegram bot API key: HTTP API token generated by BotFather after bot creation' => '',
// 'Save Chat ID' => '',
// 'Message %s not found!' => '',
// 'Please send message %s ' => '',
// 'Save chat id="%s" from "%s"?' => '',
// 'To get your Telegram chat id,' => '',
// '1. Send the message %s to' => '',
// '2. Press' => '',
// 'Get chat id' => '',
);

28 changes: 21 additions & 7 deletions Locale/es_ES/translations.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
<?php

return array(
'Jabber (XMPP)' => 'Jabber (XMPP)',
'XMPP server address' => 'Dirección del servidor XMPP',
'Jabber domain' => 'Dominio Jabber',
'Jabber nickname' => 'Apodo Jabber',
'Multi-user chat room' => 'Sala de chat multiusuario',
'Help on Jabber integration' => 'Ayuda para la integración con Jabber',
'The server address must use this format: "tcp://hostname:5222"' => 'La dirección del servidor debe usar este formato: "tcp://hostname:5222"',
// 'Telegram' => 'Telegram',
// 'Telegram bot username' => 'Nombre de usuario del bot de Telegram',
// 'Telegram bot API key' => 'API key del bot de Telegram',
// 'Chat id of private chat with bot' => 'Id del Chat privado con el bot',
// 'Chat id of group chat with bot' => 'Id del Chat grupal con el bot',
// 'Help on how to generate a bot' => 'Ayuda sobre cómo generar un bot',
// 'Sent attachments along with notification' => '',
// 'Telegram bot is not configured in Kanboard settings.' => '',
// 'Go to ' => '',
// 'Settings > Integrations > Telegram' => '',
// ' and fill the form:' => '',
// 'Telegram bot username: Username of your Telegram Bot' => '',
// 'Telegram bot API key: HTTP API token generated by BotFather after bot creation' => '',
// 'Save Chat ID' => '',
// 'Message %s not found!' => '',
// 'Please send message %s ' => '',
// 'Save chat id="%s" from "%s"?' => '',
// 'To get your Telegram chat id,' => '',
// '1. Send the message %s to' => '',
// '2. Press' => '',
// 'Get chat id' => '',
);

28 changes: 21 additions & 7 deletions Locale/fi_FI/translations.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
<?php

return array(
// 'Jabber (XMPP)' => '',
// 'XMPP server address' => '',
// 'Jabber domain' => '',
// 'Jabber nickname' => '',
// 'Multi-user chat room' => '',
// 'Help on Jabber integration' => '',
// 'The server address must use this format: "tcp://hostname:5222"' => '',
// 'Telegram' => '',
// 'Telegram bot username' => '',
// 'Telegram bot API key' => '',
// 'Chat id of private chat with bot' => '',
// 'Chat id of group chat with bot' => '',
// 'Help on how to generate a bot' => '',
// 'Sent attachments along with notification' => '',
// 'Telegram bot is not configured in Kanboard settings.' => '',
// 'Go to ' => '',
// 'Settings > Integrations > Telegram' => '',
// ' and fill the form:' => '',
// 'Telegram bot username: Username of your Telegram Bot' => '',
// 'Telegram bot API key: HTTP API token generated by BotFather after bot creation' => '',
// 'Save Chat ID' => '',
// 'Message %s not found!' => '',
// 'Please send message %s ' => '',
// 'Save chat id="%s" from "%s"?' => '',
// 'To get your Telegram chat id,' => '',
// '1. Send the message %s to' => '',
// '2. Press' => '',
// 'Get chat id' => '',
);

Loading