public void SetUp()
        {
            skype = MockRepository.GenerateMock<ISkype>();
            chat = MockRepository.GenerateMock<IChat>();
            userCollection = MockRepository.GenerateMock<IUserCollection>();
            client = MockRepository.GenerateMock<IClient>();
            user = MockRepository.GenerateMock<IUser>();
            configurationLoader = new ConfigurationLoader();
            httpGet = MockRepository.GenerateMock<IHttpGet>();
            chats = MockRepository.GenerateMock<IChats>();
            messengerClient = new MessengerClient(skype, userCollection, chats);

            buildCollection = MockRepository.GenerateMock<IBuildCollection>();
            loader = new Loader(messengerClient, buildCollection);
            stopper = MockRepository.GenerateMock<IStopper>();
            controller = new Controller();
            controller.Container.Kernel.AddComponentInstance<ISkype>(skype);
            controller.Container.Kernel.AddComponentInstance<IUserCollection>(userCollection);
            controller.Container.Kernel.AddComponentInstance<IStopper>(stopper);
            controller.CcTrayUrl = "http://localhost/Cctray.xml";
            controller.CcTrayUsername = "******";
            controller.CcTrayPassword = "******";
            controller.HttpTimeout = 30;
            controller.Configuration = @"RealUsers.xml";
        }
예제 #2
0
        public ChatView(IChat chat)
            : base()
        {
            Chat = chat;

            Buffer = Chat.Model;
        }
예제 #3
0
파일: Poller.cs 프로젝트: eckesnuff/Poller
 public Poller(ISourceRepository sourceRepository,IChat chat,ILogger logger,IMessageGenerator messageGenerator)
 {
     _sourceRepository = sourceRepository;
     _chat = chat;
     _logger = logger;
     _messageGenerator = messageGenerator;
     _pollingInterval = int.Parse(ConfigurationManager.AppSettings["PollingInterval"]);
 }
예제 #4
0
 public void SetUp()
 {
     skype = MockRepository.GenerateMock<ISkype>();
     chat = MockRepository.GenerateMock<IChat>();
     userCollection = MockRepository.GenerateMock<IUserCollection>();
     client = MockRepository.GenerateMock<IClient>();
     chats = MockRepository.GenerateMock<IChats>();
     messengerClient = new MessengerClient(skype, userCollection, chats);
 }
 private static void _OnMessageReceived(ChatMessage pMessage, TChatMessageStatus status)
 {
     if ((status == TChatMessageStatus.cmsReceived || status == TChatMessageStatus.cmsSent) && pMessage.ChatName.IndexOf(_SkypeChatUniqueCode) >= 0)
     {
         Console.WriteLine(pMessage.Body);
         SlackSender.SendMessage("*" + (String.IsNullOrEmpty(pMessage.Sender.DisplayName) ? _BotSkypeName : pMessage.Sender.DisplayName) + "* : " + pMessage.Body);
         _chat = pMessage.Chat;
         Console.WriteLine("ChatName:" + pMessage.ChatName);
     }
 }
 public virtual bool AreEqual(IChatModel model, IChat entity)
 {
     return NameableEntityMapper.AreEqual(model, entity)
         // Chat Properties
         && model.ChannelName == entity.ChannelName
         && model.PasswordHash == entity.PasswordHash
         // Related Objects
         && model.ImageFileId == entity.ImageFileId
         ;
 }
예제 #7
0
        // protected to enforce singleton
        ServerRegistration()
        {
            coordinationconfig = Config.GetInstance().coordination;

            chat = ChatImplementationFactory.CreateInstance();
            MetaverseServer.GetInstance().Tick += new MetaverseServer.TickHandler(chat.Tick);

            chat.IMReceived += new IMReceivedHandler( this.OnRecieveMessage );

            new InputBox( "Please enter a worldname to publish your server to " + coordinationconfig.ircserver +
                 " irc " + coordinationconfig.ircchannel, new InputBox.Callback( ServernameCallback ) );
        }
예제 #8
0
        // Chathub the method
        public ChatHub(IChat chat, IDbHandler dbHandler)
        {
            if (chat == null) {
            throw new ArgumentNullException("chat");
              }
              _chat = chat;

              if (dbHandler == null) {
            throw new ArgumentNullException("dbHandler");
              }
              _dbHandler = dbHandler;
        }
        void RunChat(IChat channel, string chatNickname)
        {
            Console.WriteLine("\nPress [Enter] to exit\n");
            channel.Hello(chatNickname);

            string input = Console.ReadLine();
            while (input != string.Empty)
            {
                channel.Chat(chatNickname, input);
                input = Console.ReadLine();
            }
            channel.Bye(chatNickname);
        }
 public virtual void MapToEntity(IChatModel model, ref IChat entity, int currentDepth = 1)
 {
     currentDepth++;
     // Assign Base properties
     NameableEntityMapper.MapToEntity(model, ref entity);
     // Chat Properties
     entity.ChannelName = model.ChannelName;
     entity.PasswordHash = model.PasswordHash;
     // Related Objects
     entity.ImageFileId = model.ImageFileId;
     entity.ImageFile = (ImageFile)model.ImageFile?.MapToEntity();
     // Associated Objects
     // <None>
 }
 public virtual IChatModel MapToModel(IChat entity, int currentDepth = 1)
 {
     currentDepth++;
     var model = NameableEntityMapper.MapToModel<IChat, ChatModel>(entity);
     // Chat Properties
     model.ChannelName = entity.ChannelName;
     model.PasswordHash = entity.PasswordHash;
     // Related Objects
     model.ImageFileId = entity.ImageFileId;
     model.ImageFile = entity.ImageFile?.MapToModel();
     // Associated Objects
     // <None>
     // Return Entity
     return model;
 }
예제 #12
0
 /// <summary>
 /// Adds a chat or updates it if it already exists
 /// </summary>
 /// <param name="chat">chat to add or update</param>
 public void AddChat(IChat chat)
 {
     lock (_chatLock)
     {
         using (var database = new SqlDatabase<CachedChat>(GetDatabasePath(false)))
         {
             var chatId = TelegramUtils.GetChatId(chat);
             if (chatId == null)
             {
                 return;
             }
             CreateCachedChatAndAdd(chat, Convert.ToUInt32(chatId), database);
         }
     }
 }
예제 #13
0
파일: AdaRunner.cs 프로젝트: yvettec/Dupes
        public void Run()
        {
            // need to check that it's connected.
            Console.Write("Initialising post checker...");
            qChecker = new PostChecker();
            Console.WriteLine("done");
            Console.Write("Starting chat client...");
            chat = Configuration.ChatToConsole ? (IChat)new OfflineChat() : new Chat();

            chat.PostMessage("[Ada](https://github.com/yvettec/Dupes) started.");
            Console.WriteLine("done");
            ActiveQuestionsPoller.Register(HandleNewQuestion);
            chat.MessageHandler();
            shutdownMre.WaitOne();
        }
예제 #14
0
 private bool CheckLink(string linkUsefulPart, out IChat alreadyJoinedChat)
 {
     using (var client = new FullClientDisposable(this))
     {
         try
         {
             var result = TelegramUtils.RunSynchronously(client.Client.Methods.MessagesCheckChatInviteAsync(new MessagesCheckChatInviteArgs
             {
                 Hash = linkUsefulPart
             }));
             var chatInvite = result as ChatInvite;
             var chatInviteAlready = result as ChatInviteAlready;
             if (chatInvite != null)
             {
                 alreadyJoinedChat = null;
                 return true;
             }
             if (chatInviteAlready != null)
             {
                 alreadyJoinedChat = chatInviteAlready.Chat;
                 return true;
             }
             alreadyJoinedChat = null;
             return false;
         }
         catch (Exception ex)
         {
             DebugPrint("Exception while checking invite" + ex);
             alreadyJoinedChat = null;
             return false;
         }
     }
 }
 protected bool Deactivate(IChat entity)
 {
     // Deactivate it
     ChatsRepository.Deactivate(entity);
     // Try to Save Changes
     ChatsRepository.SaveChanges();
     // Finished!
     return true;
 }
예제 #16
0
 public DecoratorBuilder WithTextEncrypt()
 {
     chat = new TextEncryptDecorator(chat);
     return(this);
 }
예제 #17
0
 public DecoratorBuilder WithUserHide()
 {
     chat = new UserHideDecorator(chat);
     return(this);
 }
예제 #18
0
 /// <summary>
 /// Construct an <see cref="Instance"/>
 /// </summary>
 /// <param name="metadata">The value of <see cref="metadata"/></param>
 /// <param name="repositoryManager">The value of <see cref="RepositoryManager"/></param>
 /// <param name="byondManager">The value of <see cref="ByondManager"/></param>
 /// <param name="dreamMaker">The value of <see cref="DreamMaker"/></param>
 /// <param name="watchdog">The value of <see cref="Watchdog"/></param>
 /// <param name="chat">The value of <see cref="Chat"/></param>
 /// <param name="configuration">The value of <see cref="Configuration"/></param>
 /// <param name="compileJobConsumer">The value of <see cref="CompileJobConsumer"/></param>
 /// <param name="databaseContextFactory">The value of <see cref="databaseContextFactory"/></param>
 /// <param name="dmbFactory">The value of <see cref="dmbFactory"/></param>
 /// <param name="jobManager">The value of <see cref="jobManager"/></param>
 /// <param name="eventConsumer">The value of <see cref="eventConsumer"/></param>
 /// <param name="gitHubClientFactory">The value of <see cref="gitHubClientFactory"/></param>
 /// <param name="logger">The value of <see cref="logger"/></param>
 public Instance(Api.Models.Instance metadata, IRepositoryManager repositoryManager, IByondManager byondManager, IDreamMaker dreamMaker, IWatchdog watchdog, IChat chat, StaticFiles.IConfiguration configuration, ICompileJobConsumer compileJobConsumer, IDatabaseContextFactory databaseContextFactory, IDmbFactory dmbFactory, IJobManager jobManager, IEventConsumer eventConsumer, IGitHubClientFactory gitHubClientFactory, ILogger <Instance> logger)
 {
     this.metadata     = metadata ?? throw new ArgumentNullException(nameof(metadata));
     RepositoryManager = repositoryManager ?? throw new ArgumentNullException(nameof(repositoryManager));
     ByondManager      = byondManager ?? throw new ArgumentNullException(nameof(byondManager));
     DreamMaker        = dreamMaker ?? throw new ArgumentNullException(nameof(dreamMaker));
     Watchdog          = watchdog ?? throw new ArgumentNullException(nameof(watchdog));
     Chat                        = chat ?? throw new ArgumentNullException(nameof(chat));
     Configuration               = configuration ?? throw new ArgumentNullException(nameof(configuration));
     CompileJobConsumer          = compileJobConsumer ?? throw new ArgumentNullException(nameof(compileJobConsumer));
     this.databaseContextFactory = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
     this.dmbFactory             = dmbFactory ?? throw new ArgumentNullException(nameof(dmbFactory));
     this.jobManager             = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
     this.eventConsumer          = eventConsumer ?? throw new ArgumentNullException(nameof(eventConsumer));
     this.gitHubClientFactory    = gitHubClientFactory ?? throw new ArgumentNullException(nameof(gitHubClientFactory));
     this.logger                 = logger ?? throw new ArgumentNullException(nameof(logger));
 }
예제 #19
0
 public static bool IsKickCommand(IChat chat)
 {
     return(chat.Text.StartsWith("/hb ifseetno "));
 }
예제 #20
0
파일: Admin.cs 프로젝트: yojik2901/Mediator
 public Admin(IChat chat, string name)
     : base(chat, name)
 {
 }
예제 #21
0
        public ChatSubscriptions(IChat chat)
        {
            _chat = chat;
            AddField(new EventStreamFieldType
            {
                Name       = "messageAdded",
                Type       = typeof(MessageType),
                Resolver   = new FuncFieldResolver <Message>(ResolveMessage),
                Subscriber = new EventStreamResolver <Message>(Subscribe)
            });

            AddField(new EventStreamFieldType
            {
                Name      = "messageAddedByUser",
                Arguments = new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                    Name = "id"
                }
                    ),
                Type       = typeof(MessageType),
                Resolver   = new FuncFieldResolver <Message>(ResolveMessage),
                Subscriber = new EventStreamResolver <Message>(SubscribeById)
            });

            AddField(new EventStreamFieldType
            {
                Name            = "messageAddedAsync",
                Type            = typeof(MessageType),
                Resolver        = new FuncFieldResolver <Message>(ResolveMessage),
                AsyncSubscriber = new AsyncEventStreamResolver <Message>(SubscribeAsync)
            });

            AddField(new EventStreamFieldType
            {
                Name      = "messageAddedByUserAsync",
                Arguments = new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                    Name = "id"
                }
                    ),
                Type            = typeof(MessageType),
                Resolver        = new FuncFieldResolver <Message>(ResolveMessage),
                AsyncSubscriber = new AsyncEventStreamResolver <Message>(SubscribeByIdAsync)
            });

            AddField(new EventStreamFieldType
            {
                Name       = "messageGetAll",
                Type       = typeof(ListGraphType <MessageType>),
                Resolver   = new FuncFieldResolver <List <Message> >(context => context.Source as List <Message>),
                Subscriber = new EventStreamResolver <List <Message> >(context => _chat.MessagesGetAll())
            });

            AddField(new EventStreamFieldType
            {
                Name       = "newMessageContent",
                Type       = typeof(StringGraphType),
                Resolver   = new FuncFieldResolver <string>(context => context.Source as string),
                Subscriber = new EventStreamResolver <string>(context => Subscribe(context).Select(message => message.Content))
            });
        }
예제 #22
0
 public ChatSchema(IChat chat)
 {
     Query        = new ChatQuery(chat);
     Mutation     = new ChatMutation(chat);
     Subscription = new ChatSubscriptions(chat);
 }
예제 #23
0
 public ChatQuery(IChat chat)
 {
     Field <ListGraphType <MessageType> >("messages", resolve: context => chat.AllMessages.Take(100));
 }
 public static bool AreEqual(this IChatModel model, IChat entity)
 {
     return(Mapper.AreEqual(model, entity));
 }
 public static IChatModel MapToModelListing(this IChat entity, int currentDepth = 1)
 {
     return(Mapper.MapToModelListing(entity, currentDepth));
 }
 public static void MapToEntity(this IChatModel model, ref IChat entity, int currentDepth = 1)
 {
     Mapper.MapToEntity(model, ref entity, currentDepth);
 }
예제 #27
0
        public ModeBase(
            ILoggerFactory loggerFactory,
            Setups.Databases repos,
            BaseConfig baseConfig,
            StopToken stopToken,
            OverlayConnection overlayConnection,
            ProcessMessage?processMessage = null)
        {
            IClock clock = SystemClock.Instance;

            _logger = loggerFactory.CreateLogger <ModeBase>();
            PokedexData pokedexData = PokedexData.Load();
            ArgsParser  argsParser  = Setups.SetUpArgsParser(repos.UserRepo, pokedexData);

            _processMessage = processMessage ?? (_ => Task.FromResult(false));

            var chats       = new Dictionary <string, IChat>();
            var chatFactory = new ChatFactory(loggerFactory, clock,
                                              repos.UserRepo, repos.TokensBank, repos.SubscriptionLogRepo, repos.LinkedAccountRepo,
                                              overlayConnection);

            foreach (ConnectionConfig connectorConfig in baseConfig.Chat.Connections)
            {
                IChat chat = chatFactory.Create(connectorConfig);
                if (chats.ContainsKey(chat.Name))
                {
                    throw new ArgumentException($"chat name '{chat.Name}' was used multiple times. It must be unique.");
                }
                chats[chat.Name] = chat;
            }
            _chats = chats.ToImmutableDictionary();
            foreach (IChat chat in _chats.Values)
            {
                chat.IncomingMessage += MessageReceived;
            }
            _commandResponders = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => (ICommandResponder) new CommandResponder(c));
            _commandProcessors = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => Setups.SetUpCommandProcessor(loggerFactory, argsParser, repos, stopToken, c, c,
                                                  pokedexData.KnownSpecies));

            _messagequeueRepo           = repos.MessagequeueRepo;
            _messagelogRepo             = repos.MessagelogRepo;
            _forwardUnprocessedMessages = baseConfig.Chat.ForwardUnprocessedMessages;
            _clock = SystemClock.Instance;

            ILogger <Moderator> moderatorLogger = loggerFactory.CreateLogger <Moderator>();

            IImmutableList <IModerationRule> availableRules = ImmutableList.Create <IModerationRule>(
                new BannedUrlsRule(),
                new SpambotRule(),
                new EmoteRule(),
                new CopypastaRule(clock),
                new UnicodeCharacterCategoryRule()
                );

            foreach (string unknown in baseConfig.DisabledModbotRules.Except(availableRules.Select(rule => rule.Id)))
            {
                moderatorLogger.LogWarning("unknown modbot rule '{UnknownRule}' marked as disabled", unknown);
            }
            IImmutableList <IModerationRule> rules = availableRules
                                                     .Where(rule => !baseConfig.DisabledModbotRules.Contains(rule.Id))
                                                     .ToImmutableList();

            _moderators = _chats.Values.ToImmutableDictionary(
                c => c.Name,
                c => (IModerator) new Moderator(moderatorLogger, c, rules, repos.ModLogRepo, clock));
        }
 public HomeController(IChat chat)
 {
     this.chat = chat;
 }
예제 #29
0
 private static bool IsAdRanking(IChat chat)
 {
     return(chat.Text.StartsWith("/nicoad ") && chat.Text.Contains("contributionRanking"));
 }
예제 #30
0
        public const NetDeliveryMethod SYNC_MESSAGE_TYPE = NetDeliveryMethod.UnreliableSequenced; // unreliable_sequenced

        #endregion


        public Main()
        {
            res    = UIMenu.GetScreenResolutionMantainRatio();
            screen = GTA.UI.Screen.Resolution;

            LogManager.RuntimeLog("\r\n>> [" + DateTime.Now + "] GTA Network Initialization.");

            World.DestroyAllCameras();

            CrossReference.EntryPoint = this;

            GameSettings   = Misc.GameSettings.LoadGameSettings();
            PlayerSettings = Util.Util.ReadSettings(GTANInstallDir + "\\settings.xml");

            CefUtil.DISABLE_CEF = PlayerSettings.DisableCEF;
            DebugInfo.ShowFps   = PlayerSettings.ShowFPS;
            EnableMediaStream   = PlayerSettings.MediaStream;
            EnableDevTool       = PlayerSettings.CEFDevtool;

            _threadJumping = new Queue <Action>();

            NetEntityHandler = new Streamer.Streamer();
            CameraManager    = new CameraManager();

            Watcher                = new SyncEventWatcher(this);
            VehicleSyncManager     = new UnoccupiedVehicleSync();
            WeaponInventoryManager = new WeaponManager();

            Npcs         = new Dictionary <string, SyncPed>();
            _tickNatives = new Dictionary <string, NativeData>();
            _dcNatives   = new Dictionary <string, NativeData>();

            EntityCleanup = new List <int>();
            BlipCleanup   = new List <int>();

            _emptyVehicleMods = new Dictionary <int, int>();
            for (var i = 0; i < 50; i++)
            {
                _emptyVehicleMods.Add(i, 0);
            }

            Chat             = new ClassicChat();
            Chat.OnComplete += ChatOnComplete;

            _backupChat = (ClassicChat)Chat;

            LogManager.RuntimeLog("Attaching OnTick loop.");

            Tick += OnTick;

            KeyDown += OnKeyDown;

            KeyUp += (sender, args) =>
            {
                if (args.KeyCode == Keys.Escape && _wasTyping)
                {
                    _wasTyping = false;
                }
            };

            _config = new NetPeerConfiguration("GTANETWORK")
            {
                Port = 8888, ConnectionTimeout = 30f
            };
            _config.EnableMessageType(NetIncomingMessageType.ConnectionLatencyUpdated);

            LogManager.RuntimeLog("Building menu.");
            _menuPool = new MenuPool();
            BuildMainMenu();

            Function.Call(Hash._ENABLE_MP_DLC_MAPS, true); // _ENABLE_MP_DLC_MAPS
            Function.Call(Hash._LOAD_MP_DLC_MAPS);         // _LOAD_MP_DLC_MAPS / _USE_FREEMODE_MAP_BEHAVIOR

            MainMenuCamera = World.CreateCamera(new Vector3(743.76f, 1070.7f, 350.24f), new Vector3(), GameplayCamera.FieldOfView);
            MainMenuCamera.PointAt(new Vector3(707.86f, 1228.09f, 333.66f));

            RelGroup       = World.AddRelationshipGroup("SYNCPED");
            FriendRelGroup = World.AddRelationshipGroup("SYNCPED_TEAMMATES");

            RelGroup.SetRelationshipBetweenGroups(Game.Player.Character.RelationshipGroup, Relationship.Pedestrians, true);
            FriendRelGroup.SetRelationshipBetweenGroups(Game.Player.Character.RelationshipGroup, Relationship.Companion, true);

            SocialClubName = Game.Player.Name;

            LogManager.RuntimeLog("Getting welcome message.");
            GetWelcomeMessage();

            var t = new Thread(UpdateSocialClubAvatar)
            {
                IsBackground = true
            };

            t.Start();

            //Function.Call(Hash.SHUTDOWN_LOADING_SCREEN);

            Audio.SetAudioFlag(AudioFlags.LoadMPData, true);
            Audio.SetAudioFlag(AudioFlags.DisableBarks, true);
            Audio.SetAudioFlag(AudioFlags.DisableFlightMusic, true);
            Audio.SetAudioFlag(AudioFlags.PoliceScannerDisabled, true);
            Audio.SetAudioFlag(AudioFlags.OnlyAllowScriptTriggerPoliceScanner, true);
            Function.Call((Hash)0x552369F549563AD5, false); //_FORCE_AMBIENT_SIREN

            // disable fire dep dispatch service
            Function.Call((Hash)0xDC0F817884CDD856, 4, false); // ENABLE_DISPATCH_SERVICE

            GlobalVariable.Get(2576573).Write(1);              //Enable MP cars?

            LogManager.RuntimeLog("Reading whitelists.");
            ThreadPool.QueueUserWorkItem(delegate
            {
                NativeWhitelist.Init();
                SoundWhitelist.Init();
            });

            //var fetchThread = new Thread((ThreadStart) delegate
            //{
            //    var list = Process.GetProcessesByName("GameOverlayUI");
            //    if (!list.Any()) return;
            //    for (var index = list.Length - 1; index >= 0; index--) list[index].Kill();
            //});

            //fetchThread.Start();

            if (!PlayerSettings.DisableCEF)
            {
                LogManager.RuntimeLog("Initializing CEF.");
                CEFManager.InitializeCef();
            }

            LogManager.RuntimeLog("Rebuilding Server Browser.");
            RebuildServerBrowser();

            LogManager.RuntimeLog("Checking game files integrity.");
            IntegrityCheck();
        }
예제 #31
0
 private static bool IsInfo(IChat chat)
 {
     return(chat.Text.StartsWith("/info "));
 }
예제 #32
0
 public DecoratorBuilder(IChat chat)
 {
     this.chat = chat;
 }
예제 #33
0
 public animationController(IChat ch)
 {
     this.chat = ch;
 }
예제 #34
0
        public static NicoMessageType GetMessageType(IChat chat, string mainRoomThreadId)
        {
            NicoMessageType type;

            if (IsKickCommand(chat))
            {
                type = NicoMessageType.Kick;
            }
            //アリーナ以外の運営コメントは除外
            else if ((chat.Premium == 2 || chat.Premium == 3 || chat.Premium == 7) && chat.Thread != mainRoomThreadId)
            {
                type = NicoMessageType.Ignored;
            }
            else if ((chat.Premium == 2 || chat.Premium == 3 || chat.Premium == 7) && chat.Text.StartsWith("/uadpoint"))
            {
                type = NicoMessageType.Ignored;
            }
            //アリーナ以外のBSPコメントは除外
            else if (chat.IsBsp && chat.Thread != mainRoomThreadId)
            {
                type = NicoMessageType.Ignored;
            }
            else if (IsAdRanking(chat))
            {
                type = NicoMessageType.Ignored;
            }
            else if (IsAd(chat))
            {
                type = NicoMessageType.Ad;
            }
            else if (IsInfo(chat))
            {
                type = NicoMessageType.Info;
            }
            else if (IsItem(chat))
            {
                type = NicoMessageType.Item;
            }
            else if (chat.Text.StartsWith("/spi "))
            {
                //"/spi \"「あみだくじ」が貼られました\""
                //"/spi \"「第一話 これが私の御主人様!?」が貼られました\""
                //"/spi \"「お掃除ロボットと猫のいる生活」が貼られました\""
                //"/spi \"「みんなでつりっくま」が貼られました\""
                //"/spi \"「日清 カップヌードル 77g×20個」が貼られました\""
                type = NicoMessageType.Unknown;//Spi
            }
            else if (chat.Text.StartsWith("/"))
            {
                //"/disconnect"
                //"/gift champagne 30539469 \"沙耶\" 900 \"\" \"シャンパーン\" 1"
                //"/gift chocobanana 18986018 \"ハルヒ\" 600 \"\" \"チョコばなな\" 3"
                //"/vote start もういいでしょ? いいよ まだ"
                using (var sw = new System.IO.StreamWriter("nico_commands.txt", true))
                {
                    sw.WriteLine(chat.Raw);
                }
                type = NicoMessageType.Unknown;
            }
            else
            {
                type = NicoMessageType.Comment;
            }
            return(type);
        }
예제 #35
0
 private static bool IsItem(IChat chat)
 {
     return(chat.Text.StartsWith("/gift "));
 }
예제 #36
0
 /// <summary>
 ///     Silently kicks all guests (/kickguests).
 /// </summary>
 public static void KickGuests(this IChat chat)
 {
     chat.Say("/kickguests");
 }
예제 #37
0
 /// <summary>
 ///     Kills the specified username. (/kill &lt;username&gt;).
 /// </summary>
 /// <param name="chat">The chat.</param>
 /// <param name="username">The username.</param>
 public static void Kill(this IChat chat, string username)
 {
     chat.Say("/kill {0}", username);
 }
예제 #38
0
 /// <summary>
 ///     Kills all the users in the world (/killall).
 /// </summary>
 public static void KillAll(this IChat chat)
 {
     chat.Say("/killall");
 }
예제 #39
0
        private static void ProcessAdminCommand(IChat returnChat, string command)
        {
            string[] commandElements = command.Split(' ');
            int size = commandElements.Length;

            switch (commandElements[0])
            {
                case ".fetch": // list of conf-s with headadmin
                    List<string> confs = FetchDetailedConferenceList();
                    if (confs.Count == 0)
                        returnChat.SendMessage("No conference chats found");
                    else
                    {
                        string confsList = "";
                        foreach (string s in confs)
                        {
                            confsList += s + Environment.NewLine;
                        }
                        returnChat.SendMessage(confsList);
                    }
                    break;

                case ".setmain":
                    if (size == 1)
                        returnChat.SendMessage("No conference code specified");
                    else if (size == 2)
                    {
                        ChatCollection chats = skype.Chats;
                        bool found = false;

                        foreach (IChat chat in chats)
                        {
                            if (chat.Name == commandElements[1])
                            {
                                mainConference = chat.Name;
                                cfg.SetMainConf(chat.Name);
                                returnChat.SendMessage("Main conference is updated");
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                            returnChat.SendMessage("Conference chat with specified code not found");
                    }
                    break;

                case ".ban":
                    if (size == 2)
                    {
                        string userHandle = commandElements[1].ToLower();
                        bool found = false;

                        foreach (IUser user in skype.Friends)
                        {
                            if (user.Handle == userHandle)
                            {
                                skype.set_UserIsAuthorized(userHandle, false);
                                skype.set_UserIsBlocked(userHandle, true);
                                returnChat.SendMessage(string.Format("User with handle {0} banned.", userHandle));
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                            returnChat.SendMessage("User not found");
                    }
                    break;

                case ".unban":
                    if (size == 2)
                    {
                        string userHandle = commandElements[1].ToLower();
                        try
                        {
                            skype.set_UserIsBlocked(userHandle, false);
                        }
                        finally
                        {
                            returnChat.SendMessage(string.Format("User with handle {0} was unbanned.", userHandle));
                        }
                    }
                    break;

                case ".ping": // ping-pong to main conf
                    SendMessageToMainConfrence("pong");
                    break;

                case ".resender": // bot activity
                    if (size == 1)
                        returnChat.SendMessage("Resender is " + (reSender ? "enabled" : "disabled"));
                    else if (size == 2)
                    {
                        switch (commandElements[1])
                        {
                            case "enable":
                                if (!reSender)
                                {
                                    cfg.SetReSender(reSender = true);
                                    returnChat.SendMessage("Resender enabled");
                                }
                                break;

                            case "disable":
                                if (reSender)
                                {
                                    cfg.SetReSender(reSender = false);
                                    returnChat.SendMessage("Resender disabled");
                                }
                                break;

                            default:
                                returnChat.SendMessage("Usage: .resender to get Resender status, .resender [enable/disable] to change");
                                break;
                        }
                    }
                    break;

                default: break;
            }
        }
예제 #40
0
 public void Populate(IChat chat)
 {
     foreach ( IUser user in chat.Users ) {
     }
 }
예제 #41
0
 public void HasReceivedJoinRequestFrom(JID inJId)
 {
     mChat = new Chat(this.ReceiveMessage(inJId, Is.Not.Empty).From, this.Connection);
 }
        // Invoke by RightNow Workspace Rule
        public void autoSearchParameterInvoke()
        {
            string logMessage = "Invoke auto contact search";
            string logNote = "";
            _log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);

            // Get current Workspace type
            _wsTypeName = _rContext.WorkspaceTypeName;

            if (_wsTypeName == "Chat")
            {
                if (this.chatRecord == null)
                    chatRecord = _rContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Chat) as IChat;
                /*
                 * EBS Contact Search API does not support firstname/lastname search.
                 *
                if (chatRecord.FirstName != null || chatRecord.FirstName != "")
                {
                    firstNameTextBox.Text = chatRecord.FirstName;
                }
                else
                {
                    firstNameTextBox.Text = "";
                }

                if (chatRecord.LastName != null || chatRecord.LastName != "")
                {
                    lastNameTextBox.Text = chatRecord.LastName;
                }
                else
                {
                    lastNameTextBox.Text = "";
                }
                 * */

                if (chatRecord.Email != null || chatRecord.Email != "")
                {
                    emailTextBox.Text = chatRecord.Email;
                }
                phoneTextBox.Text = "";
            }

            if (_wsTypeName == "Contact" || _wsTypeName == "Incident")
            {
                //IContact contactRecord = _rContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact;
                if (this.contactRecord == null)
                {
                    contactRecord = _rContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Contact) as IContact;
                    if(contactRecord == null)
                        return;
                }
                /*
                 * EBS Contact Search API does not support firstname/lastname search.
                 *
                if (contactRecord.NameFirst != null || contactRecord.NameFirst != "")
                {
                    firstNameTextBox.Text = contactRecord.NameFirst;
                }
                else
                {
                    firstNameTextBox.Text = "";
                }

                if (contactRecord.NameLast != null || contactRecord.NameLast != "")
                {
                    lastNameTextBox.Text = contactRecord.NameLast;
                }
                else
                {
                    lastNameTextBox.Text = "";
                }
                */

                if (contactRecord.PhOffice != null || contactRecord.PhOffice != "")
                {
                    phoneTextBox.Text = contactRecord.PhOffice;
                }
                else
                {
                    phoneTextBox.Text = "";
                }

                if (contactRecord.EmailAddr != null || contactRecord.EmailAddr != "")
                {
                    emailTextBox.Text = contactRecord.EmailAddr;
                }
            }

            if (emailTextBox.Text != null || emailTextBox.Text != "" ||
                    phoneTextBox.Text != null || phoneTextBox.Text != "")
            {
                this.ebsContactSearchButton_Click(null, EventArgs.Empty);

                logMessage = "Automatically search ebs contact. Search fields: phone = " + phoneTextBox.Text + "; email = " + emailTextBox.Text;
                logNote = "";
                _log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);
            }
        }
 public LocalCmdShowColliderBoxesStrategy(IChat chat)
 {
     _chat = chat;
 }
예제 #44
0
		/// <summary>
		/// コンストラクタ
		/// </summary>
		/// <param name="chat"></param>
		public ReceiveChatEventArgs(IChat chat)
		{
			_chat = chat;
		}
 protected bool Remove(IChat entity)
 {
     if (entity == null) { return true; } // No entity found to remove, consider it passed
     // Remove it
     ChatsRepository.Remove(entity);
     // Try to Save Changes
     ChatsRepository.SaveChanges();
     // Finished!
     return true;
 }
예제 #46
0
 public void Publish(IChat message)
 {
     _busControl.Publish(message);
 }
예제 #47
0
 private void SetResultAsChat(IChat chat, string id, Action<Tuple<Contact, Contact.ID>> result)
 {
     var contact = new TelegramContact
     {
         FirstName = TelegramUtils.GetChatTitle(chat)
     };
     var contactId = new Contact.PartyID
     {
         ExtendedParty = chat is Channel,
         Id = id,
         Service = this
     };
     result(new Tuple<Contact, Contact.ID>(contact, contactId));
 }
예제 #48
0
        private void skype_MessageStatus(ChatMessage msg, TChatMessageStatus status)
        {
            main._labelMessageStatus = status.ToString();
            // Proceed only if the incoming message is a trigger, the message is of the correct type (status)
            if (msg.Body.IndexOf(trigger) == 0 && (TChatMessageStatus.cmsSent == status ||
                TChatMessageStatus.cmsReceived == status) )
            {
                last_msg = msg;
                string user = msg.Sender.FullName.ToString();
                string profile = msg.Sender.Handle.ToString();

                #region Get Role
                //note, I have no idea how this works
                TChatMemberRole sender_role = new TChatMemberRole();
                IChatMemberCollection ichatm = msg.Chat.MemberObjects;
                for (int i = 1; i - 1 < msg.Chat.MemberObjects.Count; i++)
                {
                    if (ichatm[i].Handle == msg.Sender.Handle)
                    {
                        sender_role = ichatm[i].Role;
                        i = 1000; //ridiculously large arbitrary number
                    }
                }
                string role = sender_role.ToString();
                #endregion

                #region blacklist/botspam
                //loads/checks blacklist
                bool test1 = true;
                for (int i = 0; i < blacklist.Length; i++)
                {
                    if (profile == blacklist[i])
                        test1 = false;   //only needs to be true once for the block to be active.
                }

                bool test2 = false;
                for (int i = 0; i < blacklist.Length; i++) //note- blacklist can be both a whitelist or a blacklist depending on the variable it receives.
                {
                    if (profile == blacklist[i])
                        test2 = true;
                }

                //tests for botspam
                if ((test1 != false && sbprop._EnableBlacklist == true) || (test2 == true && sbprop._EnableWhitelist == true)) //blacklist test
                {
                    if ((msg.Timestamp > last_msg_time.AddSeconds(2) || user != last_user) && profile != nick) //always blocks bot itself, regardless of blacklist
                    {
                        ichat = skype.get_Chat(msg.Chat.Name);
                        string command = msg.Body.Remove(0, trigger.Length);

                        //isolates arguments and command
                        int a = command.IndexOf(" ", 0);
                        string arg = "";
                        if (a > 0)
                        {
                            arg = command.Substring(a + 1);
                            command = command.Substring(0, a).ToLower();
                        }
                        else
                            command = command.ToLower();

                        string full = ProcessCommand(command, arg, user, role);

                        #region send message
                        main._labelCommand = command + " " + arg;
                        main._labelMessageSender = user;
                        last_user = user;
                        if (command == "help")
                            skype.SendMessage(msg.Sender.Handle, full); //sends PM to the user who sent the commands
                        else
                            ichat.SendMessage(full); //sends to whatever chat sent the message.
                        last_msg_time = msg.Timestamp;
                        msg.Seen = true;
                        #endregion
                    }
                    //if botspam
                    else
                        skype.SendMessage(msg.Sender.Handle, MasterBot[0][1]);
                }
                #endregion
            }
        }
예제 #49
0
 /// <summary>
 ///     Unmutes the specified username. (/unmute &lt;username&gt;).
 /// </summary>
 /// <param name="chat">The chat.</param>
 /// <param name="username">The username.</param>
 public static void Unmute(this IChat chat, string username)
 {
     chat.Say("/unmute {0}", username);
 }
예제 #50
0
 private static bool IsAd(IChat chat)
 {
     return(chat.Text.StartsWith("/nicoad ") && chat.Text.Contains("message"));
 }
            public XMPPAuction(IChat inChat, ISniperListener inListener)
            {
                this.NotToBeGCD = inChat;
                this.NotToBeGCD.Translator = new AuctionMessageTranslator(
                    inChat.FromId,
                    new AuctionSniper.Core.AuctionSniper(this, inListener)
                );

                mListener = inListener;
            }
예제 #52
0
 /// <summary>
 ///     Sets the team of the given player (/setteam &lt;username&gt; &lt;team&gt;).
 /// </summary>
 /// <param name="chat">The chat.</param>
 /// <param name="username">The username.</param>
 /// <param name="team">The team.</param>
 public static void SetTeam(this IChat chat, string username, Team team)
 {
     chat.Say("/setteam {0} {1}", username, team);
 }
예제 #53
0
 public async Task UnSubscribe(IChat observer)
 {
     _subManager.Unsubscribe(observer);
 }
예제 #54
0
 /// <summary>
 ///     Reports the specified user with the given reason (/reportabuse &lt;username&gt; &lt;reason&gt;).
 /// </summary>
 /// <param name="chat">The chat.</param>
 /// <param name="username">The username.</param>
 /// <param name="reason">The reason.</param>
 public static void ReportAbuse(this IChat chat, string username, string reason)
 {
     chat.Say("/reportabuse {0} {1}", username, reason);
 }
예제 #55
0
 public QueryServer()
 {
     chat = MetaverseClient.GetInstance().imimplementation;
     handler = new IMReceivedHandler( imimplementation_IMReceived );
 }
예제 #56
0
 /// <summary>
 ///     Disables god mode of the specified username (/removegod &lt;username&gt;).
 /// </summary>
 /// <param name="chat">The chat.</param>
 /// <param name="username">The username.</param>
 public static void RemoveGod(this IChat chat, string username)
 {
     chat.Say("/removegod {0}", username);
 }
예제 #57
0
        internal void EnableControl(IIncident incident = null, IContact contact = null, IChat chat = null)
        {           
            this.Controls.Clear();
            _siebelContactSearchControl.contactRecord = contact;
            _siebelContactSearchControl.incidentRecord = incident;
            _siebelContactSearchControl.chatRecord = chat;

            this._logIncidentId = 0;
            this._logContactId = 0;
            if (incident != null)
                this._logIncidentId = incident.ID;
            else if (contact != null)
                this._logContactId = contact.ID;

            _siebelContactSearchControl._logIncidentId = _logIncidentId;
            _siebelContactSearchControl._logContactId = _logContactId;

        }
예제 #58
0
 /// <summary>
 ///     Gives the crown to the specified username (/givecrown &lt;username&gt;).
 /// </summary>
 /// <param name="chat">Chat.</param>
 /// <param name="username">Username.</param>
 public static void GiveCrown(this IChat chat, string username)
 {
     chat.Say("/givecrown {0}", username);
 }
예제 #59
0
 void LoadChat()
 {
     imimplementation = ChatImplementationFactory.CreateInstance();
     userchatdialog = new UserChatDialog();
 }
예제 #60
0
 /// <summary>
 ///     Removes the crown from it's owner (/removecrown).
 /// </summary>
 /// <param name="chat">Chat.</param>
 public static void RemoveCrown(this IChat chat)
 {
     chat.Say("/removecrown");
 }