-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathProgram.cs
More file actions
105 lines (81 loc) · 2.9 KB
/
Copy pathProgram.cs
File metadata and controls
105 lines (81 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using DanielExample.Rest;
using Refit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows.Forms;
using WebWhatsappBotCore;
namespace DanielExample
{
class Program
{
static void Main(string[] args)
{
Program x = new Program();
x.MainS(null);
}
IWebWhatsappDriver _driver;
void MainS(string[] args)
{
Console.WriteLine("1. Start");
Console.WriteLine("2. Configure");
string x = Console.ReadLine();
switch (x)
{
case "Start":
case "1":
Start(new WebWhatsappBotCore.Chrome.ChromeWApp());
break;
case "Configure":
case "2":
break;
default:
Main(null);
break;
}
Console.WriteLine("Done");
Console.ReadKey();
}
void Start(IWebWhatsappDriver driver)
{
_driver = driver;
driver.StartDriver();
Console.WriteLine("Press enter after scan QRCode");
Console.ReadKey();
driver.OnMsgRecieved += OnMsgRec;
Task.Run(() => driver.MessageScanner());
Console.WriteLine("Use CTRL+C to exit");
}
private void OnMsgRec(IWebWhatsappDriver.MsgArgs arg)
{
Console.WriteLine(arg.Sender + " Wrote: " + arg.Msg + " at " + arg.TimeStamp);
//get the name of pokemon by numer LOL
if (arg.Msg.ToLower().StartsWith("/pokemon"))
{
var gitHubApi = RestService.For<IPokemonApi>("http://pokeapi.co/api/v2");
String idPokemon = arg.Msg.ToLower().Split(' ')[1];
var octocat = gitHubApi.GetPokemon(idPokemon);
_driver.SendMessageToNumber(arg.Sender, "your pokemon is: " + octocat.Result.Forms[0].Name);
}
if (arg.Msg.ToLower().StartsWith("/group"))
{
string[] argr = arg.Msg.Split('-');
String nombreGrupo = argr[1].Trim();
string[] numerosGrupo = argr[2].Split(' ');
numerosGrupo = numerosGrupo.Where(x => x != "").ToArray();
_driver.createGroupFast(nombreGrupo, numerosGrupo);
Thread.Sleep(500);
_driver.SendMessageToName(nombreGrupo, nombreGrupo);
}
if (arg.Msg.ToLower().StartsWith("/number"))
{
_driver.SendMessageToNumber(arg.Msg.ToLower().Split('-')[1], arg.Msg.ToLower().Split('-')[2], arg.Msg.Split('-')[3]);
}
}
}
}