Skip to content

Commit

Permalink
added option to define separate ranges for bits
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaae committed Oct 5, 2019
1 parent 54d92ac commit f86f99c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
12 changes: 5 additions & 7 deletions lib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ def Start(self):
# Bits
#
if cmd == "5":
self.woofer.woofer_addtoqueue({
"message" : random.SystemRandom().choice(self.woofer.settings.Messages['bits']),
"sender" : "testname",
"bits" : "1000",
"customtag" : "bits",
"id" : "bits"
})
self.woofer.woofer_bits({
"display-name" : "testname",
"bits" : "1000",
"custom-tag" : "bits"
})

#
# New chatter
Expand Down
15 changes: 12 additions & 3 deletions lib/woofer.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,22 @@ def woofer_subgift(self,jsonData):
# woofer_bits
#---------------------------
def woofer_bits(self,jsonData):
# "bits_total"
# "bits", "bits_total"

customBitsId = 'bits'
customBitsMessage = random.SystemRandom().choice(self.settings.Messages['bits'])
for customBits in self.settings.CustomBits:
if int(jsonData['bits']) >= int(customBits['From']) and int(jsonData['bits']) <= int(customBits['To']):
customBitsId = customBits['Name']
if customBitsId in self.settings.Messages:
customBitsMessage = random.SystemRandom().choice(self.settings.Messages[customBitsId])

self.woofer_addtoqueue({
"message" : random.SystemRandom().choice(self.settings.Messages['bits']),
"message" : customBitsMessage,
"sender" : jsonData['display-name'],
"bits" : jsonData['bits'],
"customtag" : jsonData['custom-tag'],
"id" : 'bits'
"id" : customBitsId
})
return

Expand Down
4 changes: 3 additions & 1 deletion settings.json.default
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,7 @@
],
"Commands": {
},
"NanoleafEnabled": false
"NanoleafEnabled": false,
"CustomBits": [
]
}

0 comments on commit f86f99c

Please sign in to comment.