FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
github/github/classes/chat_controller.py at master · codex-bot/github · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
codex-bot
/
github
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
16
Code
Issues
9
Pull requests
3
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
github
/
github
/
classes
/
chat_controller.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
34 lines (27 loc) · 1021 Bytes
Breadcrumbs
github
/
github
/
classes
/
chat_controller.py
Copy path
File metadata and controls
34 lines (27 loc) · 1021 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import
random
import
string
from
time
import
time
from
settings
import
USERS_COLLECTION_NAME
class
ChatController
:
def
__init__
(
self
,
sdk
):
self
.
sdk
=
sdk
def
get_chat
(
self
,
chat_id
,
bot_id
):
registered_chat
=
self
.
sdk
.
db
.
find_one
(
USERS_COLLECTION_NAME
, {
'chat'
:
chat_id
,
'bot'
:
bot_id
})
if
registered_chat
:
return
registered_chat
else
:
user_token
=
self
.
generate_user_token
()
new_chat
=
{
'chat'
:
chat_id
,
'user'
:
user_token
,
'bot'
:
bot_id
,
'dt_register'
:
time
(),
'branch'
:
"*"
,
'verbose'
:
True
}
self
.
sdk
.
log
(
"New user registered with token {}"
.
format
(
user_token
))
self
.
sdk
.
db
.
insert
(
USERS_COLLECTION_NAME
,
new_chat
)
return
new_chat
@
staticmethod
def
generate_user_token
():
return
''
.
join
(
random
.
SystemRandom
().
choice
(
string
.
ascii_uppercase
+
string
.
digits
)
for
_
in
range
(
8
))
Back
|
FazBrowse Home
|
New Git URL