public WindowsRunner(IBotInfo botInfo, MessengerType messengerType)
        {
            try
            {
                this.MessengerType  = messengerType;
                this.MessageProcess = new MessageProcess(botInfo);
                switch (messengerType)
                {
                case MessengerType.Bale:
                    _tlBotClient = new TelegramBotClient(botInfo.Token_Bale);
                    break;

                case MessengerType.Telegram:
                    _tlBotClient = new TelegramBotClient(botInfo.Token_Telegram, baseUrl: "https://api.telegram.org/bot");
                    break;

                default:
                    throw new NotImplementedException("WindowsRunner is writed only for telegram and bale");
                }
                _tlBotClient.OnUpdate += TlBotClient_OnUpdate;
            }
            catch (Exception e)
            {
                OnLogEvent(LogEntity.GetLogEntity(e));
            }
        }
Exemple #2
0
 public Messenger(string name, MessengerType type)
 {
     Name     = name;
     Type     = type;
     Children = new ObservableCollection <Messenger>();
     HasChild = false;
 }
Exemple #3
0
        public static Type CreateMessengerType(MessengerType messenger, Type[] types)
        {
            if ((types?.Length ?? 0) != (Int32)messenger)
            {
                throw new ArgumentException("Wrong types number.");
            }
            Contract.EndContractBlock();

            switch (messenger)
            {
            case MessengerType.Raw:
                return(typeof(RawMessenger));

            case MessengerType.Topic:
                return(typeof(TopicMessenger <>).MakeGenericType(types));

            case MessengerType.Service:
                return(typeof(ServiceMessenger <,>).MakeGenericType(types));

            case MessengerType.Action:
                return(typeof(ActionMessenger <, ,>).MakeGenericType(types));

            default:
                return(null);
            }
        }
Exemple #4
0
        public static Setting LoadOrCreate(MessengerType type)
        {
            var fullPath = GetFullPath(type);

            Setting setting = null;

            if (File.Exists(fullPath))
            {
                setting = Load(type);
            }
            else
            {
                var savePath = GetSavePath(type);

                switch (type)
                {
                case MessengerType.Slack:
                    setting = ScriptableObject.CreateInstance <SlackSetting>();
                    break;

                case MessengerType.Discord:
                    setting = ScriptableObject.CreateInstance <DiscordSetting>();
                    break;
                }

                AssetDatabase.CreateAsset(setting, savePath);
                AssetDatabase.SaveAssets();
            }

            return(setting);
        }
 public RecivedData(string message, string jsonData, string userId, string name, int sex, MessengerType messengerType)
 {
     this.Message       = message;
     this.Name          = name;
     this.Sex           = sex;
     this.UserId        = userId;
     this.MessengerType = messengerType;
     this.Data          = JsonConvert.DeserializeObject <Dictionary <string, string> >(jsonData);
 }
Exemple #6
0
 public Messenger(string name, string image, MessengerType type, string username)
 {
     Name         = name;
     Image        = LoadImage(image);
     EncodedImage = Convert.ToBase64String(BitmapImageToByte(Image));
     Children     = new ObservableCollection <Messenger>();
     Type         = type;
     HasChild     = false;
     Username     = username;
 }
Exemple #7
0
        public static Setting Load(MessengerType type)
        {
            var scriptableObject = Resources.Load(GetLoadPath(type), typeof(ScriptableObject));

            switch (type)
            {
            case MessengerType.Slack:
                return(scriptableObject as SlackSetting);

            case MessengerType.Discord:
                return(scriptableObject as DiscordSetting);
            }

            return(null);
        }
 public BotNode BankMessageProcess(string recivedMessage, string jsonData, string userId, MessengerType messengerType)
 {
     if (!OnlineUsers.ContainsKey(userId))
     {
         OnlineUsers.Add(userId, BotInfo.StartNode);
     }
     else
     {
         BotTools.Models.RecivedData recivedData = new BotTools.Models.RecivedData(recivedMessage, jsonData, userId, String.Empty, 0, messengerType);
         BotNode botNode = OnlineUsers[userId];
         OnlineUsers[userId] = botNode.Process(recivedData);
     }
     return(OnlineUsers[userId]);
 }
 protected Setting(MessengerType type)
 {
     Type = type;
 }
Exemple #10
0
 public EventAggregator this[MessengerType type]
 {
     get => messengers[(int)type];
Exemple #11
0
 public static string GetFullPath(MessengerType type)
 {
     return(string.Format("{0}/Editor/Util/ScreenShooter/Resources/Setting/{1}.asset", UnityEngine.Application.dataPath, type));
 }
Exemple #12
0
 public static string GetLoadPath(MessengerType type)
 {
     return(string.Format("Setting/{0}", type.ToString()));
 }
Exemple #13
0
 public static string GetSavePath(MessengerType type)
 {
     return(string.Format("Assets/Editor/Util/ScreenShooter/Resources/Setting/{0}.asset", type));
 }