public MainPage() { InitializeComponent(); ConversationList = new ObservableCollection <BotMessage>(); BindingContext = this; _botConnector = new BotConnector(); }
/// <summary> /// Discord bot. /// </summary> /// <param name="settings">Settings used to connect to Discord.</param> /// <param name="logger">Application logger.</param> public Bot(DiscordSocketClient discordSocketClient, IDiscordSettings settings, ILogger <Bot> logger) { this.discordSocketClient = discordSocketClient; Logger = logger; // TODO: Convert logging to command discordSocketClient.Log += Log; Connector = new BotConnector(settings, discordSocketClient); }
private async void InitBotConnector() { var id = Android.Provider.Settings.Secure.AndroidId; BotConnector = new BotConnector(id); BotConnector.StartBotConversation().GetAwaiter().OnCompleted(() => { SendButton.Enabled = true; }); }
/// <summary> /// Discord bot. /// </summary> /// <param name="modules">List of modules for the bot.</param> /// <param name="settings">Settings used to connect to Discord.</param> /// <param name="logger">Application logger.</param> public Bot(DiscordSocketClient discordSocketClient, IList <IModule> modules, IDiscordSettings settings, ILogger <Bot> logger) { this.discordSocketClient = discordSocketClient; Modules = modules; Logger = logger; // TODO: Convert logging to module discordSocketClient.Log += Log; Connector = new BotConnector(settings, discordSocketClient); }
public BotViewModel() { azureDataService = DependencyService.Get <AzureDataService>(); _botConnector = new BotConnector(); setupBotConnectorAsync(); EntryText = _entryText; SendMessageCommand = new RelayCommand(new Action <object>(SendMessage)); RemoveMessageCommand = new RelayCommand(new Action <object>(RemoveMessage)); }
public BotConnectorTests() { this.configuration = Options.Create( new DirectLineSettings { BotClientAuthToken = "aa-bb-cc-dd", BotClientBaseAddress = "http://localhost" }); this.botClient = Substitute.For <IDirectLineClient>(); this.botClient.StartConversationAsync().ReturnsForAnyArgs(FakeDirectLineApi.FakeStartConversationAsync()); this.connector = new BotConnector(this.botClient, this.configuration); }
/// <summary> /// Discord bot. /// </summary> /// <param name="modules">List of modules for the bot.</param> /// <param name="settings">Settings used to connect to Discord.</param> /// <param name="logger">Application logger.</param> public Bot(IList <IModule> modules, IDiscordSettings settings, ILogger <Bot> logger, DiscordSocketClient client) { Modules = modules; Logger = logger; Client = client; Client.Log += Log; // Log when the bot is disconnected. Client.Disconnected += exception => { Logger.LogCritical("Bot has been disconnected!"); return(Task.CompletedTask); }; // Set bot game. Client.Ready += () => { Task.Run(async() => { for (;;) { var memberCount = Client.Guilds.Sum(guild => guild.MemberCount); await Client.SetGameAsync($"volvox.tech | {Client.Guilds.Count} servers > {memberCount} members"); await Task.Delay(TimeSpan.FromMinutes(15)); } }); return(Task.CompletedTask); }; // Announce to Volvox when the bot joins a guild. Client.JoinedGuild += async guild => { await Client.GetGuild(VolvoxGuildId).GetTextChannel(VolvoxGuildLogsChannelId) .SendMessageAsync($"Joined Guild: {guild.Name} [{guild.MemberCount} Members]"); }; // Announce to Volvox when the bot leaves a guild. Client.LeftGuild += async guild => { await Client.GetGuild(VolvoxGuildId).GetTextChannel(VolvoxGuildLogsChannelId) .SendMessageAsync($"Left Guild: {guild.Name} [{guild.MemberCount} Members]"); }; // Add reliability service. _ = new ReliabilityService(Client, logger); Connector = new BotConnector(settings, Client); }
/// <summary> /// Discord bot. /// </summary> /// <param name="modules">List of modules for the bot.</param> /// <param name="settings">Settings used to connect to Discord.</param> /// <param name="logger">Application logger.</param> public Bot(IList <IModule> modules, IDiscordSettings settings, ILogger <Bot> logger) { Modules = modules; Logger = logger; // TODO: Convert logging to module Client = new DiscordSocketClient(new DiscordSocketConfig() { LogLevel = LogSeverity.Verbose }); Client.Log += Log; Connector = new BotConnector(settings, Client); }
/// <summary> /// Discord bot. /// </summary> /// <param name="modules">List of modules for the bot.</param> /// <param name="settings">Settings used to connect to Discord.</param> /// <param name="logger">Application logger.</param> public Bot(IList <IModule> modules, IDiscordSettings settings, ILogger <Bot> logger) { Modules = modules; Logger = logger; // TODO: Convert logging to module Client = new DiscordSocketClient(new DiscordSocketConfig() { LogLevel = LogSeverity.Verbose }); Client.Log += Log; // Log when the bot is disconnected. Client.Disconnected += exception => { Logger.LogCritical("Bot has been disconnected!"); return(Task.CompletedTask); }; // Set bot game. Client.Ready += () => { Task.Run(async() => { for (;;) { await Client.SetGameAsync($"volvox.tech | with {Client.Guilds.Count} servers"); await Task.Delay(TimeSpan.FromMinutes(15)); } }); return(Task.CompletedTask); }; // Add reliability service. _ = new ReliabilityService(Client, logger); Connector = new BotConnector(settings, Client); }
public void Start() { AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit); Bot = new DiscordClient(); User = new BotUser(Bot); Bot.MessageReceived += (s, e) => { if (!e.Message.IsAuthor) { User.MessageSent(e.User.Id); } }; Bot.UsingCommands(x => { x.AllowMentionPrefix = true; x.PrefixChar = '$'; x.HelpMode = HelpMode.Public; }); Bot.GetService <CommandService>().CreateCommand("Strike") .Alias(new string[] { "Warn" }) .Description("Wans/Strikes a user (3 strikes = kick)") .Parameter("UserToStrike", ParameterType.Optional) .Parameter("ID", ParameterType.Optional) .Do(async e => { if (e.GetArg("UserToStrike") == "") { await e.Channel.SendMessage("Please use $strike <usertostrike> <id>"); } else { if (e.User.GetPermissions(e.Channel).ManageChannel) { if (User.Modules.UserModule.GetUserByName(e.GetArg("UserToStrike"), e.Channel).WasFound) { await e.Channel.SendMessage($"You just got striked {User.Modules.UserModule.GetUserByName(e.GetArg("UserToStrike"), e.Channel).User.Mention}!"); User.Modules.PunishmentModule.ChangeStrikes(e.Server, User.Modules.UserModule.GetUserByName(e.GetArg("UserToStrike"), e.Channel).User.Id, 1); } } else { await e.Channel.SendMessage("You ain't an admin bro..."); } } }); Bot.GetService <CommandService>().CreateCommand("XP") .Alias(new string[] { "Rank" }) .Description("Gives you your current ammount of xp!") .Do(async e => { await e.Channel.SendMessage($"{e.User.NicknameMention} has {User.Modules.DataModule.GetUserInfo(e.User.Id).XP} XP!!!"); // TODO make levels and ranking and shit }); Bot.GetService <CommandService>().CreateCommand("Hash") .Alias(new string[] { "TrackHash" }) .Description("Gets your tracking hash") .Parameter("UserToGetHashFor", ParameterType.Optional) .Do(async e => { if (e.GetArg("UserToGetHashFor") != "") // If the user it needs to hash is specified get that users hash { await e.Channel.SendMessage($"{e.GetArg("UserToGetHashFor")}'s hash is: {User.Modules.TokenModule.GetUserTrackHash(User.Modules.UserModule.GetUserByName(e.GetArg("UserToGetHashFor"), e.Channel).User.Id)}!"); // TODO make this be more checking as it may get the wrong user or something } else // If there isn't another user specified get the sending users hash. { await e.Channel.SendMessage($"{e.User.NicknameMention}'s hash is: {User.Modules.TokenModule.GetUserTrackHash(e.User)}!"); } }); // TODO remove this as it is only a test Bot.GetService <CommandService>().CreateCommand("DeHash") .Alias(new string[] { "ResolveTrackHash" }) .Description("Test Track Hash Resolver") .Parameter("Hash", ParameterType.Optional) .Do(async e => { await e.Channel.SendMessage("Atempting to resolve hash..."); // TODO remove cuz this is only for debugging await e.Channel.SendMessage($"{e.GetArg("Hash")} is actually #{User.Modules.TokenModule.TrackHashToID(e.GetArg("Hash"))} which in its turn is {User.Modules.UserModule.GetUserByID(User.Modules.TokenModule.TrackHashToID(e.GetArg("Hash")), e.Server).User.NicknameMention}!"); // TODO make this be more checking as it may get the wrong user or something }); Bot.GetService <CommandService>().CreateCommand("Hash") .Alias(new string[] { "TrackHash" }) .Description("Gets your tracking hash") .Parameter("UserToGetHashFor", ParameterType.Optional) .Do(async e => { if (e.GetArg("UserToGetHashFor") != "") // If the user it needs to hash is specified get that users hash { await e.Channel.SendMessage($"{e.GetArg("UserToGetHashFor")}'s hash is: {User.Modules.TokenModule.GetUserTrackHash(User.Modules.UserModule.GetUserByName(e.GetArg("UserToGetHashFor"), e.Channel).User.Id)}!"); // TODO make this be more checking as it may get the wrong user or something } else // If there isn't another user specified get the sending users hash. { await e.Channel.SendMessage($"{e.User.NicknameMention}'s hash is: {User.Modules.TokenModule.GetUserTrackHash(e.User)}!"); } }); // TODO remove this as it is only a test Bot.GetService <CommandService>().CreateCommand("DeHash") .Alias(new string[] { "ResolveTrackHash" }) .Description("Test Track Hash Resolver") .Parameter("Hash", ParameterType.Optional) .Do(async e => { await e.Channel.SendMessage("Atempting to resolve hash..."); // TODO remove cuz this is only for debugging await e.Channel.SendMessage($"{e.GetArg("Hash")} is actually #{User.Modules.TokenModule.TrackHashToID(e.GetArg("Hash"))} which in its turn is {User.Modules.UserModule.GetUserByID(User.Modules.TokenModule.TrackHashToID(e.GetArg("Hash")), e.Server).User.NicknameMention}!"); // TODO make this be more checking as it may get the wrong user or something }); // Connect the bot to the discord API. Bot.ExecuteAndWait(async() => { // TODO make this connect to api token BotConnector MyBotConnector = new BotConnector(); await Bot.Connect(BotConnector.GetAPIToken(), TokenType.Bot); Bot.SetGame("Testing biatch!"); }); }
public MessagesChannel(DecisionTreeHead decisionTreeHead, BotConnector botConnector, Responses responses) { _decisionTreeHead = decisionTreeHead; _botConnector = botConnector; _responses = responses; }
/// <summary> /// Discord bot. /// </summary> /// <param name="modules">List of modules for the bot.</param> /// <param name="settings">Settings used to connect to Discord.</param> /// <param name="logger">Application logger.</param> public Bot(IList <IModule> modules, IDiscordSettings settings, ILogger <Bot> logger, DiscordSocketClient client) { Modules = modules; Logger = logger; Client = client; Client.Log += Log; // Log when the bot is disconnected. Client.Disconnected += exception => { Logger.LogCritical("Bot has been disconnected!"); return(Task.CompletedTask); }; // Set bot game. Client.Ready += () => { Task.Run(async() => { for (;;) { var memberCount = Client.Guilds.Sum(guild => guild.MemberCount); var version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version; await Client.SetGameAsync( $"volvox.tech | {Client.Guilds.Count} servers | {memberCount} members | v{version.Major}.{version.Minor}.{version.Build}"); await Task.Delay(TimeSpan.FromMinutes(15)); } }); return(Task.CompletedTask); }; // Announce to Volvox when the bot joins a guild. Client.JoinedGuild += async guild => { var channel = Client.GetGuild(VolvoxGuildId)?.GetTextChannel(VolvoxGuildLogsChannelId); if (channel != null) { var builder = new EmbedBuilder(); builder.Title = "New Guild"; builder.Color = EmbedColors.GuildJoinColor; await channel.SendMessageAsync("", false, CreateEmbed(builder, guild)); } }; // Announce to Volvox when the bot leaves a guild. Client.LeftGuild += async guild => { var channel = Client.GetGuild(VolvoxGuildId)?.GetTextChannel(VolvoxGuildLogsChannelId); if (channel != null) { var builder = new EmbedBuilder(); builder.Title = "Left Guild"; builder.Color = EmbedColors.ErrorColor; await channel.SendMessageAsync("", false, CreateEmbed(builder, guild)); } }; // Add reliability service. _ = new ReliabilityService(Client, logger); Connector = new BotConnector(settings, Client); }
public async Task <IActionResult> ReceiveCall([FromQuery] string CallSid, [FromQuery] string From, [FromQuery] string To) { var audioToDelete = Directory.GetFiles(_hostingEnvironment.WebRootPath + "/audio"); foreach (var file in audioToDelete) { System.IO.File.Delete(file); } var xmlToDelete = Directory.GetFiles(_hostingEnvironment.WebRootPath + "/xml"); foreach (var file in xmlToDelete) { System.IO.File.Delete(file); } _botConnector = new BotConnector(_directlineConfig, CallSid); _ = System.Threading.Tasks.Task.Run(() => _botConnector.ReceiveMessagesFromBotAsync(HandleIncomingBotMessagesAsync)); var activity = new Activity { From = new ChannelAccount("TwilioUserId", "TwilioUser"), Type = ActivityTypes.Message, Text = string.Empty, Entities = new List <Entity>() }; var phoneNumber = string.Empty; if (From != _twilioAppConfig.TwilioPhoneNumber) { //User Phone Number during Inbound Call phoneNumber = From.Substring(1); } else { //User Phone Number during Outbound Call phoneNumber = To.Substring(1); } var entity = new Entity { Properties = new JObject { { "firstmessage", JToken.Parse(phoneNumber) } } }; activity.Entities.Add(entity); await _botConnector.SendMessageToBotAsync(activity); //Preventing the call from hanging up (/receive needs to return a TwiML) var response = new VoiceResponse(); response.Say("", voice: "alice", language: Say.LanguageEnum.FrFr); response.Pause(15); return(TwiML(response)); }
public TaskReminder(BotConnector botConnector, IAssistant please) { _botConnector = botConnector; Please = please; }
public Responses(BotConnector botConnector) { _botConnector = botConnector; }