Skip to content

class Telegram

Oliver edited this page Apr 26, 2020 · 3 revisions

www/includes/telegrambot.inc.php


Telegram

In dieser Klasse befinden sich alle Funktionen zum Senden von Telegram-Messages über einen Telegram-Bot

Package

zorg\Messagesystem

author

  • IneX

date

  • 10.06.2018

version

  • 3.0

since

  • 1.0 Initial Telegram integration
  • 2.0 Refactoring of sendMessage-Methods in 2 functions: for single User & for Groups
  • 3.0 Major refactoring of the whole Telegram Integration: Class-Object, Flexible send-Methods, More API-Options support

Overview

Public Properties

No public properties found

Constants

DISABLE_NOTIFICATION() | DISABLE_WEB_PAGE_PREVIEW() | PARSE_MODE() |

Public Methods

formatText() | mentionUser() | send() |

Constants

DISABLE_NOTIFICATION

DISABLE_NOTIFICATION = 'false' :

www/includes/telegrambot.inc.php

DISABLE_WEB_PAGE_PREVIEW

DISABLE_WEB_PAGE_PREVIEW = 'false' :

www/includes/telegrambot.inc.php

PARSE_MODE

PARSE_MODE = 'html' :

Define global default Telegram Bot Settings (can be overwritten on a Message level by passing as $parameter)

www/includes/telegrambot.inc.php

Tags
  • const: TELEGRAM_BOT_PARSE_MODE Specifies the Message Format to use - either empty, Markdown or HTML
  • const: TELEGRAM_BOT_DISABLE_WEB_PAGE_PREVIEW Specifies whether link previews for links in the message should be enabled or disabled
  • const: TELEGRAM_BOT_DISABLE_NOTIFICATION Specifies whether the Bot's messages should be silent or regular notifications

Methods

formatText()

Cleanup Message for Telegram Messenger Notification

public formatText(string $notificationText) : string

See also

Tags
  • author: IneX
  • date: 25.05.2018
  • version: 3.0
  • since: 1.0 initial function
  • since: 2.0 line breaks are possible using encoded "\n" - won't strip those anymore. Added missing allowed strong & .
  • since: 3.0 22.10.2018 changed strip_html() to remove_html(), changed order of cleanup, removed valid HTML-Tags due to issue with nested tags

mentionUser()

(NOT IMPLEMENTED YET!) Format Link to Mention Telegram User inline

Gibt einen Link aus, welcher Telegram benutzt um einen spezifischen Telegram Benutzer zu @mention. Example: inline mention of a user

public mentionUser(int $userid) : string

See also

  • \usersystem::id2user()
Tags
  • author: IneX
  • date: 25.05.2018
  • version: 1.1
  • since: 1.0 IneX 25.05.2018 Method added
  • since: 1.1 IneX 18.04.2020 Code optimization and migration to mysqli_
  • TODO: Database column "telegram_user_id" must be added first, for this to work
  • TODO: probably it's more common that a userNAME is passed? => needs usersystem::user2id()
  • global: object $db Globales Class-Object mit allen MySQL-Methoden
  • global: object $user Globales Class-Object mit den User-Methoden & Variablen

send()

Send a Message via Telegram Messenger Schickt eine Notification an die Telegram Chats von Usern

public send(int|string $userScope, string $messageType, array $content) : bool

See also

  • Uses \usersystem::userHasTelegram() \Telegram::formatText() \Telegram::validateData()
Tags
  • author: IneX
  • date: 17.03.2018
  • version: 4.0
  • since: 1.0
  • TODO: implement this with TelegramBot\TelegramBotManager\BotManager?
  • var: mit aktuellen Telegram-Bot Settings
  • global: object $user Globales Class-Object mit den User-Methoden & Variablen
  • global: array $botconfigs Array mit allen Telegram Bot-Configs

validateData()

Validate Data agains Model for various Telegram Message Types

Check for valid parameters and returns Array with key:value pairs assigned This function is related (but no depending!) to the following MySQL-table: - Table: messages_telegram_queue - Column: :method - Column: :content - Column: :content_additional

private validateData(string $messageType, array $parameters) : array|bool

See also

Tags
  • author: IneX
  • date: 10.06.2018
  • version: 1.0
  • since: 1.0

\ » Classes » Telegram

Clone this wiki locally