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
19048f8f
Commit
19048f8f
authored
Jan 02, 2016
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix chat type and cs
parent
7f170b07
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
40 deletions
+40
-40
ChatsCommand.php
src/Admin/ChatsCommand.php
+1
-1
SendtoallCommand.php
src/Admin/SendtoallCommand.php
+1
-1
ChannelchatcreatedCommand.php
src/Commands/ChannelchatcreatedCommand.php
+1
-1
GroupchatcreatedCommand.php
src/Commands/GroupchatcreatedCommand.php
+1
-1
WeatherCommand.php
src/Commands/WeatherCommand.php
+31
-31
DB.php
src/DB.php
+2
-2
Chat.php
src/Entities/Chat.php
+2
-2
Telegram.php
src/Telegram.php
+1
-1
No files found.
src/Admin/ChatsCommand.php
View file @
19048f8f
...
...
@@ -69,7 +69,7 @@ class ChatsCommand extends Command
$chat
=
new
Chat
(
$result
);
if
(
$chat
->
isPrivateChat
())
{
$text
.=
'- P '
.
$chat
->
tryMention
Chat
()
.
"
\n
"
;
$text
.=
'- P '
.
$chat
->
tryMention
()
.
"
\n
"
;
++
$user_chats
;
}
elseif
(
$chat
->
isGroupChat
())
{
$text
.=
'- G '
.
$chat
->
getTitle
()
.
"
\n
"
;
...
...
src/Admin/SendtoallCommand.php
View file @
19048f8f
...
...
@@ -38,7 +38,7 @@ class SendtoallCommand extends Command
$data
[
'text'
]
=
'Sorry no database connection, unable to execute '
.
$this
->
name
.
' command.'
;
$result
=
Request
::
sendMessage
(
$data
);
return
$result
->
isOk
();
}
}
public
function
execute
()
{
...
...
src/Commands/ChannelchatcreatedCommand.php
View file @
19048f8f
...
...
@@ -30,6 +30,6 @@ class ChannelchatcreatedCommand extends Command
$channel_chat_created
=
$message
->
getChannelChatCreated
();
// temporary do nothing
return
1
return
1
;
}
}
src/Commands/GroupchatcreatedCommand.php
View file @
19048f8f
...
...
@@ -30,6 +30,6 @@ class GroupchatcreatedCommand extends Command
$group_chat_created
=
$message
->
getGroupChatCreated
();
// temporary do nothing
return
1
return
1
;
}
}
src/Commands/WeatherCommand.php
View file @
19048f8f
...
...
@@ -57,37 +57,37 @@ class WeatherCommand extends Command
return
false
;
}
try
{
$data
=
$this
->
getWeather
(
$location
);
$decode
=
json_decode
(
$data
,
true
);
if
(
empty
(
$decode
)
||
$decode
[
'cod'
]
!=
200
)
{
return
false
;
}
$city
=
$decode
[
'name'
];
$country
=
$decode
[
'sys'
][
'country'
];
$temp
=
'The temperature in '
.
$city
.
' ('
.
$country
.
') is '
.
$decode
[
'main'
][
'temp'
]
.
'°C'
;
$conditions
=
'Current conditions are: '
.
$decode
[
'weather'
][
0
][
'description'
];
switch
(
strtolower
(
$decode
[
'weather'
][
0
][
'main'
]))
{
case
'clear'
:
$conditions
.=
' ☀'
;
break
;
case
'clouds'
:
$conditions
.=
' ☁☁'
;
break
;
case
'rain'
:
$conditions
.=
' ☔'
;
break
;
case
'thunderstorm'
:
$conditions
.=
' ☔☔☔☔'
;
break
;
}
$result
=
$temp
.
"
\n
"
.
$conditions
;
try
{
$data
=
$this
->
getWeather
(
$location
);
$decode
=
json_decode
(
$data
,
true
);
if
(
empty
(
$decode
)
||
$decode
[
'cod'
]
!=
200
)
{
return
false
;
}
$city
=
$decode
[
'name'
];
$country
=
$decode
[
'sys'
][
'country'
];
$temp
=
'The temperature in '
.
$city
.
' ('
.
$country
.
') is '
.
$decode
[
'main'
][
'temp'
]
.
'°C'
;
$conditions
=
'Current conditions are: '
.
$decode
[
'weather'
][
0
][
'description'
];
switch
(
strtolower
(
$decode
[
'weather'
][
0
][
'main'
]))
{
case
'clear'
:
$conditions
.=
' ☀'
;
break
;
case
'clouds'
:
$conditions
.=
' ☁☁'
;
break
;
case
'rain'
:
$conditions
.=
' ☔'
;
break
;
case
'thunderstorm'
:
$conditions
.=
' ☔☔☔☔'
;
break
;
}
$result
=
$temp
.
"
\n
"
.
$conditions
;
}
catch
(
\Exception
$e
)
{
$result
=
''
;
}
...
...
src/DB.php
View file @
19048f8f
...
...
@@ -59,7 +59,7 @@ class DB
*
* @param array credential, string table_prefix
*/
public
static
function
initialize
(
array
$credentials
,
$table_prefix
=
null
,
Telegram
$telegram
)
public
static
function
initialize
(
array
$credentials
,
Telegram
$telegram
,
$table_prefix
=
null
)
{
self
::
$telegram
=
$telegram
;
if
(
empty
(
$credentials
))
{
...
...
@@ -338,7 +338,7 @@ class DB
//this can be also a message sent by the bot to the user
$fake_update
[
'update_id'
]
=
0
;
$fake_update
[
'message'
]
=
$reply_to_message
->
reflect
();
// please notice that, as explaied in the documentation, reply_to_message don't contain other
// please notice that, as explaied in the documentation, reply_to_message don't contain other
// reply_to_message field so recursion deep is 1
self
::
insertRequest
(
new
Update
(
$fake_update
,
self
::
$telegram
->
getBotName
(),
1
));
}
...
...
src/Entities/Chat.php
View file @
19048f8f
...
...
@@ -117,7 +117,7 @@ class Chat extends Entity
public
function
tryMention
()
{
if
(
$
chat
->
isPrivateChat
())
{
if
(
$
this
->
isPrivateChat
())
{
if
(
is_null
(
$this
->
username
))
{
if
(
!
is_null
(
$this
->
last_name
))
{
return
$this
->
first_name
.
' '
.
$this
->
last_name
;
...
...
@@ -126,6 +126,6 @@ class Chat extends Entity
}
return
'@'
.
$this
->
username
;
}
return
$
chat
->
getTitle
();
return
$
this
->
getTitle
();
}
}
src/Telegram.php
View file @
19048f8f
...
...
@@ -180,7 +180,7 @@ class Telegram
*/
public
function
enableMySQL
(
array
$credential
,
$table_prefix
=
null
)
{
$this
->
pdo
=
DB
::
initialize
(
$credential
,
$t
able_prefix
,
$this
);
$this
->
pdo
=
DB
::
initialize
(
$credential
,
$t
his
,
$table_prefix
);
$this
->
mysql_enabled
=
true
;
}
...
...
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