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
49fe5e0b
Commit
49fe5e0b
authored
May 18, 2016
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
introducing import from log
parent
193aa44c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
importFromLog.php
utils/importFromLog.php
+35
-0
No files found.
utils/importFromLog.php
0 → 100644
View file @
49fe5e0b
<?php
require
__DIR__
.
'/../vendor/autoload.php'
;
$filename
=
'logfile.log'
;
$API_KEY
=
'random'
;
$BOT_NAME
=
'bot_name'
;
define
(
'PHPUNIT_TESTSUITE'
,
'some value'
);
$CREDENTIALS
=
array
(
'host'
=>
'localhost'
,
'user'
=>
''
,
'password'
=>
''
,
'database'
=>
''
);
$update
=
null
;
try
{
// Create Telegram API object
$telegram
=
new
Longman\TelegramBot\Telegram
(
$API_KEY
,
$BOT_NAME
);
$telegram
->
enableMySQL
(
$CREDENTIALS
);
foreach
(
new
SplFileObject
(
$filename
)
as
$current_line
)
{
$json_decoded
=
json_decode
(
$update
,
true
);
if
(
!
is_null
(
$json_decoded
))
{
echo
$update
.
"
\n\n
"
;
$update
=
null
;
if
(
empty
(
$json_decoded
))
{
echo
"Empty update:
\n
"
;
echo
$update
.
"
\n\n
"
;
continue
;
}
$telegram
->
processUpdate
(
new
Longman\TelegramBot\Entities\Update
(
$json_decoded
,
$BOT_NAME
));
}
$update
.=
$current_line
;
}
}
catch
(
Longman\TelegramBot\Exception\TelegramException
$e
)
{
// log telegram errors
echo
$e
;
}
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