Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
2be7b3c3
Commit
2be7b3c3
authored
Oct 03, 2015
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix
parent
35394a63
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
7 deletions
+28
-7
README.md
README.md
+8
-7
DB.php
src/DB.php
+2
-0
Message.php
src/Entities/Message.php
+18
-0
No files found.
README.md
View file @
2be7b3c3
# PHP Telegram Bot
======================
[
!
[
Join the chat at
https://gitter.im/akalongman/php-telegram-bot](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/akalongman/php-telegram-bot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
...
...
@@ -192,9 +191,8 @@ try {
// log telegram errors
echo
$e
;
}
```
give to the file the permission for execution:
```
chmod 775 getUpdateCLI.php
...
...
@@ -224,8 +222,7 @@ $telegram->enableMySQL($credentials, $BOT_NAME.'_');
All types implemented (except InputFile) according to Telegram API (2015 September 18).
### Commands
The bot is able to recognise commands in chat with multiple bot(
/command@mybot ).
The bot is able to recognise commands in chat with multiple bot(/command@mybot ).
It can execute command triggering a chat event. Here's the list:
-
Group chat created (
**GroupchatcreatedCommand.php**
)
...
...
@@ -234,11 +231,13 @@ It can execute command triggering a chat event. Here's the list:
-
New chat title (
**NewchattitleCommand.php**
)
-
Left chat participant (
**LeftchatparticipantCommand.php**
)
**GenericCommand.php**
let
s
you handle commands that don't exist or to
**GenericCommand.php**
let you handle commands that don't exist or to
use commands as a variable:
Favourite colour?
**/black, /red**
Favourite number?
**/1, /134**
**GenericmessageCommand.php**
let you handle any type of message.
Maybe you would like to develop your own commands. A good practice is
to store them outside
*vendor/*
. This can be done adding the method:
...
...
@@ -247,6 +246,8 @@ $COMMANDS_FOLDER = __DIR__.'/Commands/';
$telegram
->
addCommandsPath
(
$COMMANDS_FOLDER
);
```
Inside
*CommandsExamples/*
there are some sample that show how to use types.
### Admin Commands
Enabling this feature, the admin bot can perform some super user command like send message to all.
You can specify one or more admin with this option:
...
...
@@ -286,7 +287,7 @@ print_r($results);
### Logging
Thrown Exception are stored in TelegramException.log file.
You can also log incoming messages
on a text file, set this option with the methods:
Incoming update can be logged
on a text file, set this option with the methods:
```
php
$telegram
->
setLogRequests
(
true
);
$telegram
->
setLogPath
(
$BOT_NAME
.
'.log'
);
...
...
src/DB.php
View file @
2be7b3c3
...
...
@@ -238,6 +238,8 @@ class DB
$forward_date
=
self
::
toTimestamp
(
$message
->
getForwardDate
());
$photo
=
$message
->
getPhoto
();
$new_chat_participant
=
$message
->
getNewChatParticipant
();
$new_chat_photo
=
$message
->
getNewChatPhoto
();
$left_chat_participant
=
$message
->
getLeftChatParticipant
();
//inser user and the relation with the chat
...
...
src/Entities/Message.php
View file @
2be7b3c3
...
...
@@ -129,6 +129,7 @@ class Message extends Entity
}
$this
->
photo
=
$photos
;
}
$this
->
sticker
=
isset
(
$data
[
'sticker'
])
?
$data
[
'sticker'
]
:
null
;
if
(
!
empty
(
$this
->
sticker
))
{
$this
->
sticker
=
new
Sticker
(
$this
->
sticker
);
...
...
@@ -173,6 +174,16 @@ class Message extends Entity
$this
->
type
=
'new_chat_title'
;
}
$this
->
new_chat_photo
=
isset
(
$data
[
'new_chat_photo'
])
?
$data
[
'new_chat_photo'
]
:
null
;
//array of photosize
if
(
!
empty
(
$this
->
new_chat_photo
))
{
foreach
(
$this
->
new_chat_photo
as
$photo
)
{
if
(
!
empty
(
$photo
))
{
$photos
[]
=
new
PhotoSize
(
$photo
);
}
}
$this
->
new_chat_photo
=
$photos
;
}
$this
->
delete_chat_photo
=
isset
(
$data
[
'delete_chat_photo'
])
?
$data
[
'delete_chat_photo'
]
:
null
;
if
(
$this
->
delete_chat_photo
)
{
$this
->
type
=
'delete_chat_photo'
;
...
...
@@ -328,6 +339,13 @@ class Message extends Entity
return
$this
->
new_chat_title
;
}
public
function
getNewChatPhoto
()
{
return
$this
->
new_chat_photo
;
}
public
function
getDeleteChatPhoto
()
{
return
$this
->
delete_chat_photo
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment