Esempio n. 1
0
        private static void ProcessOutgoingMsgList()
        {
            do
            {
                Thread.Sleep(5000);
                OutgoingMsg msg = outgoingMsgMngr.PopFirstExpired();

                if (msg != null)
                {
                    if (commonModule.Config.AllDisabled > 0)
                    {
                        Log.Debug("AllDisabled: Not sending  " + msg.Message);
                    }
                    else
                    {
                        Log.Debug("Sending  " + msg.Message);
                        var tm = globalSettings.TUserToAccounts.FindAll(m => m.TUserName.Equals(msg.TUserName));
                        tm.ForEach(m =>
                        {
                            var account = globalSettings.Accounts.Find(a => a.Name.Equals(m.TUserName));
                            var ps      = plugins.ToList().FindAll(p => p.GetName().Equals(m.ProtocolName));
                            ps.ForEach(p => p.SendMessage(m.TUserName, msg.Message));
                        });


                        //      globalSettings.TUserToAccounts.FindAll(m=>m.TUserName.Equals( msg.TUserName)).ForEach(z=>)

                        //session.Messaging.Send(new IcqSharp.Base.Message(contact, MessageType.Incoming, msg.Message));
                        //  plugins.ToList().ForEach(p => p.SendMessage(       ))
                    }
                }
            } while (true);
        }
Esempio n. 2
0
        public List <OutgoingMsg> Generate(CommonModule commonModule)
        {
            var outgoingMsgList = new List <OutgoingMsg>();

            if (!Config.Settings.Enabled)
            {
                return(outgoingMsgList);
            }

            List <MessageGroup> messageGroups = Config.Messages.FindAll(mg => mg.DaysList.Count == 0 || mg.DaysList.Exists(dayOfWeek => dayOfWeek.Equals(DateTime.Now.DayOfWeek)));

            messageGroups = messageGroups.FindAll(mg => Utils.Common.Random(mg.Chance * Config.Settings.ChanceMultiplier) == 0);

            messageGroups.ForEach(delegate(MessageGroup messageGroup)
            {
                DateTime executeTime = messageGroup.BotTime.FromTime.AddMinutes(Utils.Common.Random((int)messageGroup.BotTime.TotalMinutes));
                var msgs             = messageGroup.Msgs.ToList().FindAll(mg => Utils.Common.Random(mg.Chance) == 0);

                msgs.ForEach(delegate(Message message)
                {
                    var text = Parse.DoParse(message.Text, commonModule.Config.variables);
                    foreach (var s in Utils.StringUtils.ReplaceRandomTokens(text).Split('\n'))
                    {
                        executeTime     = executeTime.AddSeconds(Utils.Common.Random(20) + 5);
                        var outgoingMsg = new OutgoingMsg
                        {
                            MsgType     = MsgTypes.Daily,
                            Message     = s,
                            ExecuteTime = executeTime
                        };
                        outgoingMsgList.Add(outgoingMsg);
                    }
                });
            });
            return(outgoingMsgList);
        }