Google Wave allows two or more participants to speak privately within a wave. When my robot is added to the wave, I recognize the WAVELET_SELF_ADDED event and call the method below. However, nothing happens.
I can tell that the code is executed because of the Debug and Info statements in the logs. Is there any reason why the robot does not start a private blip when it's added?
def start_private_wavelet(properties, context):
"""Start a private conversation between the robot and some participants."""
participants = []
participants.append('my-username#googlewave.com')
participants.append('my-robot#appspot.com')
logging.debug('Getting wave info')
root_wavelet = context.GetRootWavelet()
root_wave_id = root_wavelet.GetWaveId()
root_wave = context.GetWaveById(root_wave_id)
logging.debug('Creating private wave in %s' % root_wave_id)
private_wavelet = root_wave.CreateWavelet(participants)
message = private_wavelet.CreateBlip()
message.GetDocument().SetText("This is a private conversation...")
logging.debug('Private wave created')
A private conversion is created through a Wavelet.
So, using the Python API, I think you're looking for OpBasedWave.CreateWavelet.
participants = []
participants.append('other-user#googlewave.com')
participants.append('self-robot#appspot.com') # Remember to add your robot!
private_wavelet = root_wave.CreateWavelet(participants)
message = private_wavelet.CreateBlip()
message.GetDocument().SetText("Hi there, this is just a secret!")
Related
my friend made a script for a club game and the audio seems to not work please help
local playlist = {4773093598, 727844285}
local mubic = game.Workspace.moosesack
local G_egg = true
while G_egg == true do
for i, v in ipairs(playlist) do
mubic.SoundId = v
mubic:Play()
wait(mubic.TimeLength)
end
end
Why are you trying to assign multiple Audio ID’s to a single Sound Instance at one time?
To create a functioning music playlist, you would need to create a queue.
And also, because you are using a while loop you are exhausting the Lua thread processor, you would need to add wait().
Furthermore, the while loop is an actual loop, so it will execute the same code infinitely until your boolean switches to false.
From the information that you've given ("seems to not work"), there is 1 error in your code.
mubic.SoundId = v
What the code is being read as is "mubic.SoundId = 4773093598"
To roblox, this is not correct as the SoundId must be defined as a string and as an asset id. Your code should look like:
local playlist = {4773093598, 727844285}
local mubic = game.Workspace.moosesack
local G_egg = true
while G_egg == true do
for i, v in ipairs(playlist) do
mubic.SoundId = "rbxassetid://"..tostring(v)
mubic:Play()
wait(mubic.TimeLength)
end
end
I have two monitors and I would like to change client focused by shortcut. Right now I have awful.client.focus.byidx(1) but it only changes clients on one monitor. I know there is awful.client.focus.global_bydirection("right") that works on multiple screens but it only goes to one direction and it stops working when get to last client. I like awful.client.focus.byidx(1) behavior which loops through all clients, so from the last client it goes to the first one.
I would like to use a hybrid between: going through clients as in awful.client.focus.byidx(1) but on all monitors/screens like awful.client.focus.global_bydirection("right") does. Is there a function that would have that behavior so I could use it? If not, do you know how could I achieve that goal?
First, let's look at how awful.client.focus.byidx is implemented.
The function itself calls awful.client.next and then focused the returned client, if any is found:
https://github.com/awesomeWM/awesome/blob/9781f14b105ee700c5bca339bf49bb52d2cca4b5/lib/awful/client/focus.lua#L65-L71
awful.client.next is implemented here: https://github.com/awesomeWM/awesome/blob/9781f14b105ee700c5bca339bf49bb52d2cca4b5/lib/awful/client.lua#L262-L284
It does the following:
line 263: Get the currently focused client
line 267: Get all visible clients on the screen of the visible client
line 270-274: Filter out unfocusable clients from the list
line 277 - 278: Find the focused client in the resulting list
line 280: Get the client at the wanted offset and return it
So, your request sounds like you only need to change one step here: Get the list of all visible clients instead of only those at the currently focused screen.
To get that list, you need to call awful.client.visible with nil instead of a specific screen.
Untested code:
function next_global(i, sel, stacked)
sel = sel or client.focus
if not sel then return end
local cls = awful.client.visible(nil, stacked)
local fcls = {}
for _, c in ipairs(cls) do
if awful.client.focus.filter(c) or c == sel then
table.insert(fcls, c)
end
end
cls = fcls
for idx, c in ipairs(cls) do
if c == sel then
return cls[gears.math.cycle(#cls, idx + i)]
end
end
end
function focus_byidx_global(i, c)
local target = next_global(i, c)
if target then
target:emit_signal("request::activate", "client.focus.byidx", {raise=true})
end
end
I don't know which version of AwesomeWM you are using. If in doubt, look at the installed files in /usr/share/awesome/lib/ and copy the code from there, then change it.
(A little more ugly solution would be something like the following, even though it requires less code; I leave it as an exercise to the reader to figure out what this does, but note that this "breaks stuff" in case a Lua error occurs and the monkey-patching becomes permanent)
function focus_byidx_global(i, c)
local old = awful.client.visible
awful.client.visible = function(_, s) return old(nil, s) end
awful.client.focus.byidx(i, c)
awful.client.visible = old
end
I want to search the last message for a few strings and then echo the message back with those strings replaced with other strings.
I searched multiple documentations but didn't find a way to get the last message.
This is the first forum I ask as I already have an account so have no real starting point to give you.
Thanks in advance!
There is no way in the WoW API to get the last chat message of a specific channel. You will have to handle the CHAT_MSG_CHANNEL event (see Event Handling) to read all messages, and store the newest one. Specifically for the say or yell (shout) channels there are the CHAT_MSG_SAY and CHAT_MSG_YELL events respectively.
To do this your addon needs to own a Frame, these frames can register event handlers and you will have to store the last message you receive from that handler in a local variable in your script (let's call it last_message). Then when your other piece of code executes you can read the last_message variable:
local frame = CreateFrame("FRAME", "FooAddonFrame");
local last_message = nil;
frame:RegisterEvent("CHAT_MSG_CHANNEL");
local function eventHandler(self, event, ...)
-- Look up the arguments that are given to your specific event
-- and assign them to variables in order by retrieving them from
-- the `...` variable arguments
local msg, author, language, channel = ...
print("Hello World! Hello " .. event);
last_message = msg
end
frame:SetScript("OnEvent", eventHandler);
I am trying to create a bot where when ever someone send a message about a type of food to the bot, then the bot will respond with the location that serves that food. However I am trying to establish context so that the conversation can flow more thoroughly.
I have tried nesting the if statement, and it gets it to display the message, but it would have to rely on the if-statement prior to be true before testing for the ones that comes after.
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse
from intents import fallback_intent, getLocation
import random
app = Flask(__name__)
location_fallback = ['What kind of restaurant are you seeking?', 'What kind? Nearby, Cheap or The best?']
welcome = ['hello', 'what\'s up', 'hey','hi', 'what\'s happening?']
near = ['near', 'nearby']
cheap = ['cheap', 'good for my pockets']
good = ['good', 'top rated']
intro_resp = ['''Hey! Welcome to Crave! This interactive platform connects you to the top foodies in the world! We provide you with the best food places where ever you are. The instructions are simple:
1. Save our number in your Phone as Crave.
2. Text us and tell us what type of food you are craving!
This is from python''', '''
Welcome to Crave! Are you ready to get some food for today?
1. Save our number in your Phone as Crave.
2. Text us and tell us what type of food you are craving!
''']
#app.route('/sms', methods=['GET','POST'])
def sms():
num = request.form['From']
msg = request.form['Body'].lower()
resp = MessagingResponse()
#welcome intent
if any(word in msg for word in welcome):
if any(near_word in msg for near_word in near):
resp.message('These are the location of places near you!')
print(str(msg.split()))
return str(resp)
elif any(cheap_word in msg for cheap_word in cheap):
resp.message('These are the location of places that are low cost to you!')
return str(resp)
elif any(good_word in msg for good_word in good):
resp.message('These are the best places in town!')
return str(resp)
else:
location_fallback[random.randint(0,1)]
resp.message(intro_resp[random.randint(0, 1)])
print(str(msg.split()))
return str(resp)
else:
resp.message(fallback_intent())
print(str(msg))
return str(resp)
if __name__ == '__main__':
app.run(debug=True)
I want the user to say 'hi'' or something related to initiate the bot, then I want the bot to prompt the user to ask what kind of food they would like. Then the bot will ask what parameters for the restaurant they would like(i.e Close, cheap, or good). Then the user will answer accordingly, and then the bot needs to use these parameters to search for the restaurant near them with these attributes.
Twilio developer evangelist here.
You could store this in many places, in cookies as part of the conversation with Twilio, in a database where you use the user's number as a key to look up previous messages, or even just in memory.
If you're looking for a more robust way to achieve this, with better natural language processing, have you checked out Twilio Autopilot? It stores the context of a conversation for you and is built to collect information before giving a response based on the complete set like you are doing.
I have some code applying a map function on a dask bag. I need a lookup dictionary to apply that function and it doesn't work with client.scatter.
I don't know if I am doing the right things, because the workers starts, but they don't do anything. I have tried different configuration looking to different examples, but I can't get it to work. Any support will be appreciated.
I know from Spark, you define a broadcast variable and you access the content by variable.value inside the function you want to apply. I don't see the same with dask.
# Function to map
def transform_contacts_add_to_historic_sin(data,historic_dict):
raw_buffer = ''
line = json.loads(data)
if line['timestamp] > historic_dict['timestamp]:
raw_buffer = raw_buffer + line['vid']
return raw_buffer
# main program
# historic_dict is a dictionary previously filled, which is the lookup variable for map function
# file_records will be a list of json.dump getting from a S3 file
from distributed import Client
client = Client()
historic_dict_scattered = client.scatter(historic_dict, broadcast=True)
file_records = []
raw_data = s3_procedure.read_raw_file(... S3 file.......)
data = TextIOWrapper(raw_data)
for line in data:
file_records.append(line)
bag_chunk = db.from_sequence(file_records, npartitions=16)
bag_transform = bag_chunk.map(lambda x: transform_contacts_add_to_historic(x), args=[historic_dict_scattered])
bag_transform.compute()
If your dictionary is small you can just include it directly
def func(partition, d):
return ...
my_dict = {...}
b = b.map(func, d=my_dict)
If it's large then you might want to wrap it up in Dask delayed first
my_dict = dask.delayed(my_dict)
b = b.map(func, d=my_dict)
If it's very large then yes, you might want to scatter it first (though I would avoid this if things work out with either of the approaches above).
[my_dict] = client.scatter([my_dict])
b = b.map(func, d=my_dict)