Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bits_tg_bot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Fred
bits_tg_bot
Commits
ce1cb4f5
Commit
ce1cb4f5
authored
Oct 09, 2020
by
JackV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use environment variables, cleanup
parent
4b53ce63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
main.py
main.py
+10
-9
No files found.
main.py
View file @
ce1cb4f5
import
websockets
import
asyncio
from
telegram
import
Bot
import
json
import
os
import
websockets
from
telegram
import
Bot
WS_URL
=
"wss://bits.poul.org/ws"
CHAT_ID
=
123
#CHANGE ME
MESSAGE_ID
=
123
#CHANGE ME
TOKEN
=
"KEK"
WS_URL
=
os
.
environ
.
get
(
'WS_URL'
,
"wss://bits.poul.org/ws"
)
CHAT_ID
=
int
(
os
.
environ
.
get
(
'CHAT_ID'
))
MESSAGE_ID
=
int
(
os
.
environ
.
get
(
'MESSAGE_ID'
))
TOKEN
=
os
.
environ
.
get
(
'TOKEN'
)
bot
=
Bot
(
TOKEN
)
def
bits_handler
(
text
):
m
eme
=
json
.
loads
(
text
)
bot
.
edit_message_text
(
"POuL HQ is now {}"
.
format
(
m
eme
[
"status"
][
"value"
]),
CHAT_ID
,
MESSAGE_ID
)
m
sg
=
json
.
loads
(
text
)
bot
.
edit_message_text
(
"POuL HQ is now {}"
.
format
(
m
sg
[
"status"
][
"value"
]),
CHAT_ID
,
MESSAGE_ID
)
return
class
WebSocketClient
:
...
...
@@ -50,4 +51,4 @@ if __name__ == '__main__':
asyncio
.
ensure_future
(
client
.
heartbeat
()),
asyncio
.
ensure_future
(
client
.
receiveMessage
(
connection
,
bits_handler
)),
]
loop
.
run_until_complete
(
asyncio
.
wait
(
tasks
))
\ No newline at end of file
loop
.
run_until_complete
(
asyncio
.
wait
(
tasks
))
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