messages using mesibo javascript api not delivered,it shows only sent status - chat

sending message using below function
function sendTextMessage(to, message) {
var profile = api.getProfile(to, 0);
var id = parseInt(Math.random()*10000);
profile.sendMessage(id, message);
}
after that when i log listner response using
MesiboListener.prototype.Mesibo_OnMessageStatus = function(m) {
console.log("Mesibo_OnMessageStatus: from "
+ m.peer + " status: " + m.status);
}
it show Mesibo_OnMessageStatus: from 4688250 status: 1 but not change status to 2(delivered)

We answered you on the mesibo tickets with minor corrections in your code (check SPAM if you have not received it).
You are giving UID as the destination. You should give the address as the destination. Try the code below
var demo1_user_token = '81...';
var demo1_destination = 'vivek';
var demo_appid = 'com.f...';
var demo2_user_token = 'c9...';
var demo2_destination = 'maulik';

Related

App Scripts: Attempting to grab a specific form response, get a URL, and email that URL

I'm attempting to capture a directly link or the response ID to create a link and forward it into a ticketing queue but every function seems to give me the wrong ID.
function onFormSubmit()
{
//email content creation
var formID = '(copy/pasted from form url)';
var emailBody = "You have received a form submission: ";
var emailAddress = 'TestEmail';
var emailSubject = 'Your form has a new response';
//find the form
var form = FormApp.openById(formID)
var formResponses = form.getResponses();
//find the last response
var lastResponse = formResponses[formResponses.length-1];
var responseID = lastResponse.getID();
//build link
var url = https://docs.google.com/forms/d/ + formID + "/edit#response=" + responseID;
//send email
MailApp.sendEmail(emailAddress, emailSubject, emailBody + url);
}
Hopefully this comes off as coherent on what I'm trying to do. I've attempted to use the
onFormSubmit(e)
responseID = e.getResponses[e.length-1].getID();
but that doesn't work either.
I've found numerous posts on how to do this, but even copy/pasting the test code throws errors of getID being undefined.
If anyone can help figure this out, I would appreciate it!

Socket programming in yii2 to provide web service support to the mobile app

I have a requirement to provide the real time data to the mobile app through web services. I have developed the project in yii2 and want to implement socket programming so that i could connect the mobile app and can send the updated real time data to the app.
For Details :
We have to provide the live tracking feature to our mobile app user.
For that we are storing the mobile app user's current location(Lat/long) and storing it on server. When any user want to track his friend(Which is the user of our app) location he can, for which we have to keep sending his friend's current location to the app so that he can see him moving on map when he is roaming anywhere.
I have google for the socket programming with Yii2 but every where i am getting the example for chat functionality through sockets.
Can any body help who has worked something matching with my requirements.
Socket programming to send data from server to mobile app client.
Thanks in advance.
Finally, After putting so much efforts and spent a week of time on R&D i just got what i was require.
Here i am posting the solution which i have developed for my requirements considering for those who have the similar requirements, may be it could help full for them :
Server.js
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var clientsids = {};
var response_array = get_response_array();
server.listen(8786);
io.on('connection', async function (socket) {
var uchannel = socket.handshake['query']['r_var'];
var myid = socket.handshake['query']['myid'];
clientsids[uchannel+'_'+myid] = socket.id;
socket.join(uchannel);
socket.emit('connectSuccess',response_array);
//sending current data to the user
socket.on('currentlocation', function(data) {
console.log("User with id :"+data.myid+ " has shared the location : lat :"+data.lat+",lng :"+data.lng+" in channel :"+data.channel);
//dump user location to a file for future save to the db
fileobj.savelocation(data.myid,data.lat,data.lng);
response_array = get_response_array();
response_array['msg_code'] = 103;
response_array['msg'] = get_msg_code(103);
var datainfo = {};
datainfo['lat'] = data.lat;
datainfo['lng'] = data.lng;
datainfo['channel_name'] = data.channel;
datainfo['u_id'] = data.myid;
response_array['data'] = datainfo;
fileobj.dumpdata("User with id :"+data.myid+" has shared the location : lat :"+data.lat+",lng :"+data.lng+" in channel :"+data.channel+" \n"+JSON.stringify(response_array));
io.to(data.channel).emit(data.channel, response_array); //broadcast the data to all the users in the channel
//console.log('current clients :'+ JSON.parse(clientsids));
});
socket.on('disconnect', function() {
//redisClient.quit();
socket.disconnect('disconnect');
});
});
Client.php
var room ='';
var myid ='';
var socket ='';
$( document ).ready(function() {
room = $("#channel").val();
room2 = $("#channel2").val();
myid = $("#myid").val();
socket = io.connect('serverip:port',{
query: 'r_var='+room+'&myid='+myid
});
socket.on(room, function (data) {
$( "#notifications" ).prepend( "<p><strong>Message :" + data.msg + " </strong> <strong>Channel :" + data.data.channel_name + "</strong> <strong>Lat :" + data.data.lat + "</strong> <strong>Long :" + data.data.lng + "</strong></p>" );
});
socket.on('connectSuccess', function (data) {
$( "#notifications" ).prepend( "<p><strong>" +data.msg+ "</strong>: ");
});
});

Microsoft Bot Framework channel integration: more endpoints?

I'm using Microsoft Bot Framework using the channel registration product and the REST API. I have setup the "messaging endpoint" and everything works fine for sending and receiving messages.
But I don't just want to send/receive messages. Something as simple as setting up a welcome message seems impossible because my endpoint receives nothing other than messaging events (when the bot is in the channel / conversation.)
Is there something I have missed?
I would like to setup several endpoints, or use the same, whatever, to listen to other types of events.
You need to implement in the MessageController something like these:
Pay attention in the else if. The funcition in the controller is HandleSystemMessage.
else if (message.Type == ActivityTypes.ConversationUpdate)
{
// Handle conversation state changes, like members being added and removed
// Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
// Not available in all channels
IConversationUpdateActivity update = message;
var cliente = new ConnectorClient(new System.Uri(message.ServiceUrl), new MicrosoftAppCredentials());
if (update.MembersAdded != null && update.MembersAdded.Count > 0)
{
foreach(var member in update.MembersAdded)
{
if(member.Id != message.Recipient.Id)
{
//var username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
var username = message.From.Name;
var reply = message.CreateReply();
//string dir = System.AppDomain.CurrentDomain.BaseDirectory + "Images" + Path.DirectorySeparatorChar + "cajamar.png";
string dir = HttpRuntime.AppDomainAppPath + "Images" + Path.DirectorySeparatorChar + "cajamar.png";
reply.Attachments.Add(new Attachment(
contentUrl: dir,
contentType: "image/png",
name: "cajamar.png"
));
reply.Text = $"Bienvenido {username} al ChatBot de convenios:";
cliente.Conversations.ReplyToActivity(reply);
//var reply = message.CreateReply();
//reply.Text = $"El directorio base es: {HttpRuntime.AppDomainAppPath}";
//cliente.Conversations.ReplyToActivityAsync(reply);
}
}
}
}

Moodle get course information + all lessons through Api

I am trying to collect all information related to Moodle course (course + lessons) Using Moodle Api I got the course information, but gets only some basic information, I want course details and its lessons (created under course)
Eg : var domainname = 'http://<server URL>/moodle';
var token = 'df337369637c692303d903f8cacf1eb0';
var functionname = 'core_course_get_courses';
var serverurl = domainname + '/webservice/rest/server.php' ;
var data = {
wstoken: token,
wsfunction: functionname,
moodlewsrestformat: 'json'
} var response = $.ajax(
{ type: 'GET',
data: data,
url: serverurl
}
);
And the output looks like
{"id":2,"shortname":"IV Support Queries","categoryid":1,"categorysortorder":10001,"fullname":"IV Support Queries","displayname":"IV Support Queries","idnumber":"","summary":"<p>IV Support Queries Desc<br \/><\/p>","summaryformat":1,"format":"topics","showgrades":1,"newsitems":5,"startdate":1479168000,"numsections":5,"maxbytes":0,"showreports":0,"visible":1,"hiddensections":1,"groupmode":0,"groupmodeforce":0,"defaultgroupingid":0,"timecreated":1479127227,"timemodified":1479198758,"enablecompletion":0,"completionnotify":0,"lang":"","forcetheme":"","courseformatoptions":[{"name":"numsections","value":5},{"name":"hiddensections","value":1},{"name":"coursedisplay","value":1}]}
I want the lesson details created under course .How can i get the information through Api . Thanks
Using function
"core_course_get_contents"
getting all the informations related with course.
var domainname = 'http://<server URL>/moodle';
var token = 'df337369637c692303d903f8cacf1eb0';
var functionname = 'core_course_get_contents';
var serverurl = domainname + '/webservice/rest/server.php' ;
var data = {
wstoken: token,
wsfunction: functionname,
moodlewsrestformat: 'json' ,
courseid: 2 //Retrieve results based on course Id 2
}
var response = $.ajax(
{ type: 'GET',
data: data,
url: serverurl
}
);
Thanks

getting data from mongodb collection

Trying to get some messages from a db collection, I've tried that code (server side):
MongoClient.connect('mongodb://127.0.0.1:27017/gt-chat', function(err, db) {
if(err) throw err;
var history="";
var collection = db.collection('gt-chat');
console.log("******************************Printing docs from Cursor Each")
collection.find({}, {_id: 0}).sort({$natural: 1}).limit(20).each(function(err, doc) {
console.log(doc)
if(doc != null) {
console.log("Doc from Each ");
history=history+console.dir(doc)+"\r\n";
console.dir(doc);
}
});
console.log("/////////////HISTORY//////////////////");
console.log(history); ; // data is shown there under the shell console, all is fine !
socket.emit('updatechat', 'SERVER', history); // should send the messages using socket
});
and then on the client side, I've tried :
// listener, whenever the server emits 'updatechat', this updates the chat body
socket.on('updatechat', function (username, data) {
date = new Date;
h = date.getHours();
if (h<10) {
h = "0"+h;
}
m = date.getMinutes();
if (m<10) {
m = "0"+m;
}
s = date.getSeconds();
if (s<10) {
s = "0"+s;
}
var time = h+":"+m+":"+s;
$('#conversation').append('<b><strong>' + time + '</strong> '+username + ':</b> ' + data + '<br>');
});
which doesn't show anything as expected :(
I am quite sure about the updatechat function because I can get message with it, as I've tried:
socket.emit('updatechat', 'SERVER',"this is history"); // < message is well sent, so no problem there!
but I don't get the all history.
So the goal is to get some messages from a mongodb collection and to display them under the browser using socket emit
Under the shell, to debug, it's showing:
Doc from Each { message: '<strong>12:16:27</strong><span style=\'color:#2fed7e\'><b>guibs</b>< /span><em> hum</em>' } { message: '<strong>12:16:27</strong><span style=\'color:#2fed7e\'><b>guibs</b>< /span><em> hum</em>' }
So, data and messages exist, but I can't read them from the browser. The shell says: 'history is not defined' ! What is wrong with concatenation? And my variable declaration? I don't understand, thanks for your help!