/// <summary> /// Merge two (non-conflicting) ItemIds into one. /// </summary> /// <returns>The merged ChatItemID.</returns> public static ChatItemId Merge(ChatItemId c1, ChatItemId c2) { if (c1 == null || c2 == null) { return(null); } if (c1.Conflicts(c2)) { return(null); } ChatItemId id = new ChatItemId(); foreach (KeyValuePair <string, ulong> p in c1.Ids) { id.Ids.Add(p.Key, p.Value); } foreach (KeyValuePair <string, ulong> p in c2.Ids) { if (!id.Ids.ContainsKey(p.Key)) { id.Ids.Add(p.Key, p.Value); } } return(id); }
public Message(Chat chat, User user, string text, ChatItemId id = null, MessageType type = MessageType.Unknown) { Chat = chat; User = user; Text = text; Id = id; Type = type; }
public User FindUserById(ChatItemId id, Client c = null) { int i = FindUserIndexById(id); if (i != -1) { users[i].SetClient(c); } return(i == -1 ? null : users[i]); }
public virtual bool SendMessage(ChatItemId id, string message) { Chat c = GetChatById(id); if (c == null) { c = new Chat(id, ChatType.Unknown); } return(this.SendMessage(c, message)); }
private int FindUserIndexById(ChatItemId id, Client c = null) { foreach (KeyValuePair <string, ulong> e in id.Ids) { int i = FindUserIndexById(e.Key, e.Value); if (i != -1) { users[i].SetClient(c); return(i); } } return(-1); }
public override string ToString(Matbot.Client.ChatItemId chatId) { string s = base.ToString(); if (IsChatRegistered(chatId) != ChatRegisterStatus.Empty) { s += " *R*"; } else { s += " R"; } return(s); }
/// <summary> /// Checks if there is a conflict in the ChatIds: a client in which they have different IDs. /// </summary> public bool Conflicts(ChatItemId other) { foreach (KeyValuePair <string, ulong> p in Ids) { if (other.Ids.ContainsKey(p.Key)) { if (other.Ids[p.Key] != Ids[p.Key]) { return(true); } } } return(false); }
public bool Equals(ChatItemId obj) { ChatItemId other = obj as ChatItemId; foreach (KeyValuePair <string, ulong> p in Ids) { if (!other.Ids.Contains(p)) { return(false); } } foreach (KeyValuePair <string, ulong> p in other.Ids) { if (!Ids.Contains(p)) { return(false); } } return(true); }
public void Start(Client.ChatItemId chatId, Client.Client client = null) { this.client = client; this.chatId = chatId; shell = new Process(); ProcessStartInfo p = new ProcessStartInfo("cmd"); p.CreateNoWindow = true; p.UseShellExecute = false; p.RedirectStandardError = true; p.RedirectStandardInput = true; p.RedirectStandardOutput = true; shell.StartInfo = p; shell.Start(); toShell = shell.StandardInput; fromShell = shell.StandardOutput; toShell.AutoFlush = true; shellThread = new Thread(new ThreadStart(getShellInput)); //Start a thread to read output from the shell shellThread.Start(); Running = true; }
public Chat(ChatItemId id, ChatType type) { Type = type; Id = id; }
public bool UserExists(ChatItemId id) { return(FindUserIndexById(id) != -1); }
public User(string clientId, ulong id) { Id = new ChatItemId(clientId, id); }
public virtual Chat GetChatById(ChatItemId id) { throw new NotImplementedException("GetChatById functionality not implemented in bot client with id: " + GetClientId()); }
public virtual User GetChatMemberByUsername(ChatItemId chatId, string username, bool exactMatch = true) { throw new NotImplementedException("GetChatMemberByUsername functionality not implemented in bot client with id: " + GetClientId()); }
public virtual User GetChatMemberById(ChatItemId chatId, ulong id) { throw new NotImplementedException("GetChatMember functionality not implemented in bot client with id: " + GetClientId()); }
public User(Client c, string clientId, ulong id) { Id = new ChatItemId(clientId, id); Client = c; }
public Chat(string clientId, ulong id, ChatType type) { Type = type; Id = new ChatItemId(clientId, id); }