Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Barry
/
discordbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
21820359
authored
2016-06-17 00:09:54 +0000
by
Barry
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Bug fixes for pinging.
1 parent
aeb9e40a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
17 deletions
db.sqlite3
hellsbot.py
db.sqlite3
View file @
2182035
No preview for this file type
hellsbot.py
View file @
2182035
...
...
@@ -184,8 +184,8 @@ def search_google_images(query, animated=False):
def
ping
(
hostname
,
timeout
):
ping_response
=
subprocess
.
Popen
([
"/bin/ping"
,
"-c1"
,
"-w100"
,
hostname
],
stdout
=
subprocess
.
PIPE
)
.
stdout
.
read
()
log
(
ping_response
)
matches
=
re
.
match
(
'.*time=([0-9]+) ms.*'
,
ping_response
,
re
.
DOTALL
)
#
log(ping_response)
matches
=
re
.
match
(
'.*time=([0-9
\
.
]+) ms.*'
,
ping_response
,
re
.
DOTALL
)
if
matches
:
return
matches
.
group
(
1
)
else
:
...
...
@@ -193,22 +193,22 @@ def ping(hostname, timeout):
def
check_pings
():
ping_list
=
data
.
db_get_pings
()
new_ping
=
ping
(
ping_list
[
0
]
.
get
(
'ip_address'
),
1000
)
if
new_ping
:
log
(
"New Ping: {}"
.
format
(
new_ping
))
data
.
db_update_ping
(
ping_list
[
0
]
.
get
(
'ping_id'
),
new_ping
)
for
channel
in
client
.
get_all_channels
():
if
channel
.
id
==
'193028170184785920'
:
# Reflex channel
send_message
(
client
,
channel
,
"{} - {}ms Average: {}ms"
.
format
(
ping_list
[
0
]
.
get
(
'ip_address'
),
new_ping
,
ping_list
[
0
]
.
get
(
'average_ping'
)))
break
else
:
for
member
in
client
.
get_all_members
():
if
member
.
id
==
'122079633796497409'
:
send_message
(
client
,
member
,
"Outage! {} - {}ms Average: {}ms"
.
format
(
ping_list
[
0
]
.
get
(
'ip_address'
),
new_ping
,
ping_list
[
0
]
.
get
(
'average_ping'
)))
break
for
ping_row
in
data
.
db_get_pings
():
new_ping
=
ping
(
ping_row
.
get
(
'ip_address'
),
1000
)
if
new_ping
:
log
(
"{} - New Ping: {}"
.
format
(
ping_row
.
get
(
'ip_address'
),
new_ping
))
data
.
db_update_ping
(
ping_row
.
get
(
'ping_id'
),
new_ping
)
for
channel
in
client
.
get_all_channels
():
if
channel
.
id
==
'193028170184785920'
:
# Reflex channel
send_message
(
client
,
channel
,
"{} - {}ms Average: {}ms"
.
format
(
ping_row
.
get
(
'ip_address'
),
new_ping
,
ping_row
.
get
(
'average_ping'
)))
break
else
:
#
for member in client.get_all_members():
#
if member.id == '122079633796497409':
# send_message(client, member, "Outage! {} - {}ms Average: {}ms".format(ping_row.get('ip_address'), new_ping, ping_row
.get('average_ping')))
#
break
data
.
db_update_ping
(
ping_list
[
0
]
.
get
(
'ping_id'
),
False
)
data
.
db_update_ping
(
ping_row
.
get
(
'ping_id'
),
False
)
def
check_msg_queue
(
client
):
...
...
Please
register
or
sign in
to post a comment