private void AddQuestionnaire(IIQuestionnaire quest, Action <string> method, int userid, PalBot bot) { PrivateInstances.Add(userid, new KeyValuePair <IIQuestionnaire, Action <string> >(quest, method)); quest.Next = (a) => PrivateInstances[userid] = new KeyValuePair <IIQuestionnaire, Action <string> >(quest, a); quest.Finish = () => { QuestionnaireFinished(quest); PrivateInstances.Remove(userid); }; quest.MoveToPrivate = () => false; quest.MoveToGroup = (i) => { if (!GroupInstances.ContainsKey(i)) { GroupInstances.Add(i, new Dictionary <int, KeyValuePair <IIQuestionnaire, Action <string> > >()); } if (GroupInstances[i].ContainsKey(userid)) { return(false); } AddQuestionnaire(quest, PrivateInstances[userid].Value, i, userid, bot); PrivateInstances.Remove(userid); return(true); }; ((IQuestionnaire)quest)._doStartUp(bot); }
/// <summary> /// Removes an instance of a Forum based on the specifications of the Message supplied. /// </summary> /// <param name="msg"></param> public void RemoveInstance(Message msg) { if (msg.MesgType == MessageType.Group && GroupInstances.ContainsKey(msg.GroupId) && GroupInstances[msg.GroupId].ContainsKey(msg.SourceUser)) { GroupInstances[msg.GroupId].Remove(msg.SourceUser); } else if (msg.MesgType == MessageType.Private && PrivateInstances.ContainsKey(msg.SourceUser)) { PrivateInstances.Remove(msg.SourceUser); } }