public static User UserExists(string phoneNum, string nickName) { WhatsUserManager man = new WhatsUserManager(); var whatsUser = man.CreateUser(phoneNum, phoneNum); var tmpUser = new User(phoneNum, nickName); tmpUser.SetUser(whatsUser); return tmpUser; }
public User(string phone, string name, string jid) { WhatsUserManager man = new WhatsUserManager(); this.PhoneNumber = phone; this.UserName = name; this.Jid = jid; this.WhatsUser = man.CreateUser(jid, name); this.Last = ""; }
private static void ProcessChat(WhatsApp wa, string dst) { var thRecv = new Thread(t => { try { while (wa != null) { wa.PollMessages(); Thread.Sleep(100); continue; } } catch (ThreadAbortException) { } }) {IsBackground = true}; thRecv.Start(); WhatsUserManager usrMan = new WhatsUserManager(); var tmpUser = usrMan.CreateUser(dst, "User"); while (true) { string line = Console.ReadLine(); if (line == null && line.Length == 0) continue; string command = line.Trim(); switch (command) { case "/query": //var dst = dst//trim(strstr($line, ' ', FALSE)); Console.WriteLine("[] Interactive conversation with {0}:", tmpUser); break; case "/accountinfo": Console.WriteLine("[] Account Info: {0}", wa.GetAccountInfo().ToString()); break; case "/lastseen": Console.WriteLine("[] Request last seen {0}", tmpUser); wa.SendQueryLastOnline(tmpUser.GetFullJid()); break; case "/exit": wa = null; thRecv.Abort(); return; case "/start": wa.SendComposing(tmpUser.GetFullJid()); break; case "/pause": wa.SendPaused(tmpUser.GetFullJid()); break; default: Console.WriteLine("[] Send message to {0}: {1}", tmpUser, line); wa.SendMessage(tmpUser.GetFullJid(), line); break; } } }
private WhatsUser getUser(string dst) { WhatsUserManager usrMan = new WhatsUserManager(); WhatsUser user = usrMan.CreateUser(dst, "User"); log.DebugFormat("getUser {0} = {1}", dst, user.GetFullJid()); return user; }