-
Notifications
You must be signed in to change notification settings - Fork 37
/
userbets.py
106 lines (97 loc) · 3.05 KB
/
userbets.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import random
import time
from faker.providers import BaseProvider
MIN_AMOUNT = 2 # Min betting amount
MAX_AMOUNT = 1000 # Max betting amount
ALPHA = 50
# Adding a UserBets with 3 methods:
# * username to retrieve the username,
# * bet_amount to retrieve the amount
# * betting_channel_event to retrieve event and channel
class UserBetsProvider(BaseProvider):
def username(self):
valid_usernames = [
"nopineappleonpizza",
"catanzaro99",
"thedoctor",
"bettingexpert01",
"losingmoney66",
"manutd007",
"manutd009",
"citylife1",
"lysa_X",
"aiventest",
]
return random.choice(valid_usernames)
def bet_amount(self):
# return int(random.triangular(MIN_AMOUNT, MID_AMOUNT, MAX_AMOUNT))
return (
int((random.paretovariate(ALPHA) - 1) * (MAX_AMOUNT - MIN_AMOUNT))
+ 1
)
def bet_category_event(self):
valid_events = [
{
"category": "Sport",
"subcategory": "Football",
"event": "ManUTD vs Chelsea",
},
{
"category": "Sport",
"subcategory": "Box",
"event": "Chicken Legs vs Power Kick",
},
{
"category": "Sport",
"subcategory": "Curling",
"event": "Italy vs England",
},
{
"category": "Sport",
"subcategory": "Netball",
"event": "Sydney vs Camberra",
},
{
"category": "Lottery",
"subcategory": "Bingo",
"event": "Uk Bingo",
},
{
"category": "Lottery",
"subcategory": "WinForLife",
"event": "Win For Life America",
},
{
"category": "Event",
"subcategory": "Music",
"event": "Rick Astley #1 in World Charts",
},
{
"category": "Event",
"subcategory": "Politics",
"event": "Mickey Mouse new Italian President",
},
{
"category": "Event",
"subcategory": "Celebrities",
"event": "Donald Duck and Marge Simpson Wedding",
},
]
return random.choice(valid_events)
def produce_msg(self):
username = self.username()
bet_amount = self.bet_amount()
bet_event = self.bet_category_event()
# message composition
message = {
"username": username,
"event": {
"category": bet_event["category"],
"subcategory": bet_event["subcategory"],
"name": bet_event["event"],
},
"amount": bet_amount,
"timestap": int(time.time() * 1000),
}
key = {"event": bet_event["event"]}
return message, key