Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.18 KB | None | 0 0
  1. using Matrix;
  2. using Matrix.Xmpp;
  3. using Matrix.Xmpp.Client;
  4. using Parser;
  5. using PVPNetConnect;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using BotEventArgs;
  12. using EnumConvertExtensions;
  13. using PVPNetConnect.RiotObjects.Platform.Summoner;
  14. using PVPNETExtensions;
  15.  
  16. public class Bot : IDisposable
  17. {
  18. // nested class
  19. public class LeagueRank
  20. {
  21. public LeagueRank(Rank pRank, int pDiv)
  22. {
  23. Ranking = pRank;
  24. Division = pDiv;
  25. }
  26. public Rank Ranking { get; private set; }
  27. public enum Rank
  28. {
  29. Unranked = 0x0,
  30. BRONZE = 0x5,
  31. SILVER = 0xA,
  32. GOLD = 0xF,
  33. PLATINUM = 0x14,
  34. DIAMOND = 0x19,
  35. }
  36. public int Division { get; private set; }
  37. public static bool operator ==(LeagueRank pLeague, LeagueRank pLeague2)
  38. {
  39. return (int)pLeague.Ranking + pLeague.Division == (int)pLeague2.Ranking + pLeague2.Division;
  40. }
  41. public static bool operator !=(LeagueRank pLeague, LeagueRank pLeagu2)
  42. {
  43. return !(pLeague == pLeagu2);
  44. }
  45. public static bool operator <(LeagueRank pLeague, LeagueRank pLeague2)
  46. {
  47. return (int)pLeague.Ranking + (5 - pLeague.Division) < (int)pLeague2.Ranking + (5 - pLeague2.Division);
  48. }
  49. public static bool operator >(LeagueRank pLeague, LeagueRank pLeague2)
  50. {
  51. return (int)pLeague.Ranking + (5 - pLeague.Division) > (int)pLeague2.Ranking + (5 - pLeague2.Division);
  52. }
  53. public static bool operator <=(LeagueRank pLeague, LeagueRank pLeague2)
  54. {
  55. return (pLeague == pLeague2 || pLeague < pLeague2);
  56. }
  57. public static bool operator >=(LeagueRank pLeague, LeagueRank pLeague2)
  58. {
  59. return (pLeague == pLeague2 || pLeague > pLeague2);
  60. }
  61. public static LeagueRank ParseFromString(string pInput)
  62. {
  63. if (!pInput.Contains(' '))
  64. {
  65. return new LeagueRank(Rank.Unranked, 0);
  66. }
  67. else
  68. {
  69. string[] lParts = pInput.Split(' ');
  70. string lFirst = lParts[0];
  71. string lSecond = lParts[1];
  72. if (string.IsNullOrWhiteSpace(lSecond))
  73. return new LeagueRank(Rank.Unranked, 0);
  74. Rank lRank = Rank.Unranked;
  75. switch (lFirst)
  76. {
  77. case "BRONZE":
  78. lRank = Rank.BRONZE;
  79. break;
  80. case "SILVER":
  81. lRank = Rank.SILVER;
  82. break;
  83. case "GOLD":
  84. lRank = Rank.GOLD;
  85. break;
  86. case "PLATINUM":
  87. lRank = Rank.PLATINUM;
  88. break;
  89. case "DIAMOND":
  90. lRank = Rank.DIAMOND;
  91. break;
  92. }
  93. int lVal = 0;
  94. if (lSecond.Length != 2)
  95. {
  96. foreach (var item in lSecond)
  97. {
  98. if (item == 'V')
  99. lVal = 4;
  100. else if (item == 'I')
  101. lVal++;
  102. }
  103. }
  104. else
  105. {
  106. foreach (var item in lSecond)
  107. {
  108. if (item == 'V')
  109. lVal = 5;
  110. else if (item == 'I')
  111. lVal++;
  112. }
  113. }
  114. return new LeagueRank(lRank, lVal);
  115.  
  116. }
  117. }
  118. }
  119. bool disposed = false;
  120. public void Dispose()
  121. {
  122. Dispose(true);
  123. }
  124. public EventHandler Botdisposed;
  125. protected virtual void Dispose(bool disposing)
  126. {
  127.  
  128. if (disposing && !disposed)
  129. {
  130.  
  131.  
  132. using (LoL_AutoAdder.lol_usersEntities lContext = new LoL_AutoAdder.lol_usersEntities())
  133. {
  134. for (var x = actualOnes.Count - 1; x >= 0; x--)
  135. {
  136.  
  137.  
  138.  
  139.  
  140. int lValue = int.Parse(actualOnes[x]);
  141. var lUser = from it in lContext.euw
  142. where it.Region == this.WebScraper.LowerRegion
  143. && it.SummonerID.Value == lValue
  144. select it;
  145.  
  146. try
  147. {
  148. if (lUser.Count() > 0)
  149. {
  150. foreach (var user in lUser)
  151. {
  152.  
  153. user.Scraped = false;
  154.  
  155. }
  156. }
  157. lContext.SaveChanges();
  158. }
  159. catch (System.Reflection.TargetException ey)
  160. {
  161. Console.WriteLine(ey.Message);
  162. }
  163. }
  164.  
  165. }
  166.  
  167. if (Botdisposed != null)
  168. Botdisposed(this, System.EventArgs.Empty);
  169. WebScraper.Logger.LoggedIn = false;
  170. WebScraper.Stop();
  171. WebScraper = null;
  172. if (_chat != null)
  173. _chat.Close();
  174. if (_client != null)
  175. _client.Disconnect();
  176. _chat = null;
  177. _client = null;
  178. _logged_In = false;
  179. }
  180. disposed = true;
  181. }
  182. //Chatclient
  183. private XmppClient _chat = new XmppClient();
  184. public XmppClient Chat
  185. {
  186. get { return _chat; }
  187. }
  188. //Gameclient
  189. private PVPNetConnection _client = new PVPNetConnection();
  190. public PVPNetConnection Client
  191. {
  192. get { return _client; }
  193. }
  194.  
  195. public bool SummSite
  196. {
  197. get { return _lolSumm; }
  198. }
  199.  
  200. private Region _Region;
  201. public Region Region
  202. {
  203. get { return _Region; }
  204. }
  205.  
  206. private bool _acceptFriends = false;
  207. public bool AcceptFriends
  208. {
  209. get { return _acceptFriends; }
  210. set { _acceptFriends = value; }
  211. }
  212.  
  213. //Taking the Username's from lolsummoners
  214. public Scraper WebScraper { get; set; }
  215.  
  216.  
  217.  
  218. //Class to progress the Input
  219. private Tokenizer Token = new Tokenizer();
  220.  
  221. //Serverdomain of every Region
  222. private Dictionary<Region, string> regionDictionary = new Dictionary<Region, string>();
  223. private Dictionary<string, Region> newDict = new Dictionary<string, Region>();
  224. //All Commands
  225. private Dictionary<string, ParamAction> newAction = new Dictionary<string, ParamAction>();
  226. private static ExpressionParser _express;
  227. public event EventHandler<SummonerEventArgs> Game_Start;
  228. public event EventHandler<SummonerEventArgs> Game_End;
  229. public event EventHandler LoginSucceed;
  230. /// <summary>
  231. /// Signature of commands
  232. /// </summary>
  233. /// <param name="pParameter">All parameters of commands</param>
  234. /// <returns></returns>
  235. public delegate Task<string> ParamAction(Jid SummonerJID, params string[] pParameter);
  236.  
  237.  
  238. private bool _logged_In = false;
  239. public bool Logged_In
  240. {
  241. get { return _logged_In; }
  242. set
  243. {
  244. this._logged_In = value;
  245. if (this.WebScraper != null)
  246. this.WebScraper.Logger.LoggedIn = value;
  247. }
  248. }
  249.  
  250. private ParamAction _defaultCommand;
  251.  
  252. /// <summary>
  253. /// Functionpointer to function that shall get executed when no command got matched by the message
  254. /// </summary>
  255. public ParamAction DefaultCommand
  256. {
  257. get { return _defaultCommand; }
  258. set { _defaultCommand = value; }
  259. }
  260. private string _username;
  261. /// <summary>
  262. /// starts the bot
  263. /// </summary>
  264. /// <param name="pUsername">Account name to log in</param>
  265. /// <param name="pPassword">Account password to log in</param>
  266. /// <param name="pRegion">Region to log in</param>
  267. public void Start(string pUsername, string pPassword, Region pRegion)
  268. {
  269. PrepareStart(pUsername, pPassword, pRegion);
  270. Start();
  271. }
  272. public void Start()
  273. {
  274. ChatLogin(this._username, this._password, this._Region);
  275. if (_lolSumm) ClientLogin(this._username, this._password, this._Region);
  276. }
  277. public void PrepareStart(string pUsername, string pPassword, Region pRegion)
  278. {
  279. _Region = pRegion;
  280. _username = pUsername;
  281. _password = pPassword;
  282. }
  283. private readonly bool _lolSumm;
  284. public void Start(string pUsername, string pPassword, string pRegion)
  285. {
  286. pRegion = pRegion.Trim('\r').ToLower();
  287. pUsername = pUsername.Trim('\r');
  288. pPassword = pPassword.Trim('\r');
  289. if (!newDict.ContainsKey(pRegion))
  290. return;
  291.  
  292. WebScraper.Region = pRegion;
  293. WebScraper.Logger.Username = pUsername;
  294. Start(pUsername, pPassword, newDict[pRegion]);
  295. }
  296. private Random _random = new Random(DateTime.Now.Millisecond);
  297. private bool isFullReq = false;
  298. public bool FullRequest { get { return isFullReq; } }
  299. private List<string> users = new List<string>();
  300. private void Users_Found(object sender, UserFoundEventArgs e)
  301. {
  302.  
  303. if (this.disposed)
  304. {
  305. throw new ObjectDisposedException("Disposed");
  306. }
  307. actualOnes = e.Users.ToList();
  308. foreach (var item in e.Users)
  309. {
  310. if (this.disposed)
  311. {
  312.  
  313. return;
  314. }
  315. try
  316. {
  317. if (isFullReq)
  318. {
  319. System.Threading.Thread.Sleep(_waitTime + _max);
  320. }
  321. //while (lSummonerID == "0")
  322. //{
  323. // System.Threading.Thread.Sleep(10000);
  324. // lSummonerID = (await lID).SummonerId.ToString();
  325. //}
  326. var lJid = "sum" + item + "@pvp.net";
  327. this.AddFriend(lJid, false);
  328. users.Add(lJid);
  329. //this.SendMessage(lJid, this.Spamtext);
  330. //this.RemoveFriend(lJid, true);
  331. using (LoL_AutoAdder.lol_usersEntities lContext = new LoL_AutoAdder.lol_usersEntities())
  332. {
  333. var lUser = from it in lContext.euw
  334. where it.Region == this.WebScraper.LowerRegion
  335. && it.SummonerID.Value.ToString() == item
  336. select it;
  337. try
  338. {
  339. if (lUser.Count() > 0)
  340. {
  341. foreach (var user in lUser)
  342. {
  343. user.Friendreqest = true;
  344. }
  345. }
  346. lContext.SaveChanges();
  347. }
  348. catch (System.Reflection.TargetException ey)
  349. {
  350. Console.WriteLine(ey.Message);
  351. }
  352. }
  353.  
  354. System.Threading.Thread.Sleep(_random.Next(_min, _max));
  355. actualOnes.Remove(item);
  356. }
  357. catch { }
  358. }
  359.  
  360. //System.Threading.Thread.Sleep(10000);
  361.  
  362. }
  363. private List<string> actualOnes = new List<string>();
  364.  
  365. /// <summary>
  366. /// Adds a new command
  367. /// </summary>
  368. /// <param name="pCommand">Text to execute the command (case insensitive)</param>
  369. /// <param name="pExecution">Functionpointer to function that shall get executed</param>
  370. /// <returns>True if successful otherwise false</returns>
  371. public bool AddCommand(string pCommand, ParamAction pExecution)
  372. {
  373. if (!newAction.ContainsKey(pCommand.ToLower()))
  374. {
  375. newAction.Add(pCommand.ToLower(), pExecution);
  376. return true;
  377. }
  378. return false;
  379. }
  380. private string _password;
  381. /// <summary>
  382. /// Removes a existing command
  383. /// </summary>
  384. /// <param name="pCommand">Command to remove</param>
  385. /// <returns>True if successful otherwise false</returns>
  386. public bool RemoveCommand(string pCommand)
  387. {
  388. if (newAction.ContainsKey(pCommand.ToLower()))
  389. {
  390. newAction.Remove(pCommand.ToLower());
  391. return true;
  392. }
  393. return false;
  394. }
  395. private string _spamText;
  396. public string Spamtext
  397. {
  398. get { return _spamText; }
  399. set
  400. {
  401. _spamText = value;
  402. this.WebScraper.Logger.Message = value;
  403. }
  404. }
  405. private int _min;
  406. private int _max;
  407. private int _waitTime;
  408. public Bot(LeagueRank pMin, LeagueRank pMax, int pMinim, int pMaxim, int pLvlmin, int pLvlmax, string pSpamtext, string pClientVersion, bool pSumm, int pWaitTime, DateTime pDate)
  409. {
  410. From = pMin;
  411. To = pMax;
  412. _min = pMinim;
  413. _max = pMaxim;
  414. Min = pLvlmin;
  415. Max = pLvlmax;
  416. _waitTime = pWaitTime;
  417. _clientVersion = pClientVersion;
  418. regionDictionary.Add(Region.EUW, "euw1");
  419. regionDictionary.Add(Region.EUN, "eun1");
  420. regionDictionary.Add(Region.NA, "na2");
  421. regionDictionary.Add(Region.TR, "tr");
  422. regionDictionary.Add(Region.RU, "ru");
  423. regionDictionary.Add(Region.BR, "br");
  424. regionDictionary.Add(Region.OCE, "oc1");
  425. regionDictionary.Add(Region.KR, "kr");
  426. regionDictionary.Add(Region.LAN, "la1");
  427. regionDictionary.Add(Region.LAS, "la2");
  428. newDict.Add("euw", Region.EUW);
  429. newDict.Add("eune", Region.EUN);
  430. newDict.Add("na", Region.NA);
  431. newDict.Add("tr", Region.TR);
  432. newDict.Add("ru", Region.RU);
  433. newDict.Add("br", Region.BR);
  434. newDict.Add("oce", Region.OCE);
  435. newDict.Add("kr", Region.KR);
  436. newDict.Add("lan", Region.LAN);
  437. newDict.Add("las", Region.LAS);
  438. //to be continued
  439. Client.OnLogin += new PVPNetConnection.OnLoginHandler(Client_OnLogin);
  440. Chat.OnLogin += new EventHandler<Matrix.EventArgs>(Chat_OnLogin);
  441. Chat.OnMessage += new EventHandler<MessageEventArgs>(Chat_OnMessage);
  442. Token.Parsed += new Tokenizer.ParsedEventHandler(Token_Parsed);
  443. Chat.OnPresence += new EventHandler<PresenceEventArgs>(On_Presence);
  444. Client.OnDisconnect += new PVPNetConnection.OnDisconnectHandler(Client_Disconnected);
  445. Chat.OnClose += new EventHandler<Matrix.EventArgs>(Chat_Close);
  446. _lolSumm = pSumm;
  447. WebScraper = new DatabaseScraper(pMin, pMax, 0, pDate);
  448. WebScraper.User_Found += new EventHandler<UserFoundEventArgs>(Users_Found);
  449. Chat.AutoRoster = false;
  450. Client.OnError += new PVPNetConnection.OnErrorHandler(Client_Error);
  451. Chat.OnError += new EventHandler<ExceptionEventArgs>(Chat_Error);
  452. Chat.OnRosterItem += new EventHandler<Matrix.Xmpp.Roster.RosterEventArgs>(Roster_Requested);
  453. Chat.OnRosterEnd += new EventHandler<Matrix.EventArgs>(Roster_End);
  454. this.Spamtext = pSpamtext;
  455. this.DefaultCommand = Message;
  456.  
  457. }
  458. public LeagueRank From { get; private set; }
  459. public LeagueRank To { get; private set; }
  460. private void Chat_Error(object sender, ExceptionEventArgs e)
  461. {
  462. this.Dispose();
  463.  
  464. }
  465. private void Client_Error(object sender, PVPNetConnect.Error e)
  466. {
  467. this.Dispose();
  468. }
  469. static Bot()
  470. {
  471. _express = new ExpressionParser();
  472. }
  473. public static IEnumerable<System.Tuple<string, string, string, Bot>> CreateFromString(string pInput, string pClientVersion, bool pEndsite)
  474. {
  475. return _express.ParseExpression(pInput, pClientVersion, pEndsite);
  476. }
  477. private void Chat_Close(object sender, Matrix.EventArgs e)
  478. {
  479.  
  480.  
  481. this.Dispose();
  482.  
  483. //this._chat = new XmppClient();
  484. //this._client = new PVPNetConnection();
  485. //this.Start(this._username, this._password, this._Region);
  486. }
  487. private void Client_Disconnected(object sender, System.EventArgs e)
  488. {
  489. //this._chat = new XmppClient();
  490. //this._client = new PVPNetConnection();
  491. //this.Start(this._username, this._password, this._Region);
  492. }
  493. /// <summary>
  494. /// Add user to friendlist
  495. /// </summary>
  496. /// <param name="pSummonerID">SummonerJID of User</param>
  497. public void AddFriend(Jid pSummonerID, bool pOut)
  498. {
  499. if (Chat == null)
  500. return;
  501. Chat.Send(createPresence(pOut ? PresenceType.subscribed : PresenceType.subscribe, pSummonerID));
  502. if (!pOut) this.WebScraper.Logger.FriendrequestsSend++;
  503. }
  504.  
  505. private Presence createPresence(PresenceType pType, Jid pSummonerID)
  506. {
  507. var newPresence = new Presence(pType);
  508. newPresence.Priority = 0;
  509. newPresence.To = pSummonerID;
  510. return newPresence;
  511. }
  512.  
  513. /// <summary>
  514. /// Remove friend of friendlist
  515. /// </summary>
  516. /// <param name="pSummonerID">SummonerJID of friend</param>
  517. public void RemoveFriend(Jid pSummonerID, bool pOut)
  518. {
  519. if (Chat != null)
  520. Chat.Send(createPresence(pOut ? PresenceType.unsubscribed : PresenceType.unsubscribe, pSummonerID));
  521. }
  522. private int _acceptedFriends = 0;
  523. private async void On_Presence(object sender, PresenceEventArgs e)
  524. {
  525. if (e.Presence.Error != null && e.Presence.Error.Type == Matrix.Xmpp.Base.ErrorType.wait)
  526. {
  527. if (e.Presence.Error.Text == "max_outgoing_invites")
  528. {
  529. isFullReq = true;
  530. await Task.Delay(_waitTime);
  531. var lList = users.Select((item) => (string)item.Clone()).ToList();
  532. foreach (var item in lList)
  533. {
  534. try
  535. {
  536. //while (lSummonerID == "0")
  537. //{
  538. // System.Threading.Thread.Sleep(10000);
  539. // lSummonerID = (await lID).SummonerId.ToString();
  540. //}
  541. this.RemoveFriend(item, false);
  542. //this.SendMessage(lJid, this.Spamtext);
  543. //this.RemoveFriend(lJid, true);
  544.  
  545.  
  546. await Task.Delay(_random.Next(_min, _max));
  547. }
  548. catch { }
  549. }
  550. users.RemoveAll((elem) => lList.Contains(elem));
  551. isFullReq = false;
  552. }
  553. else
  554. {
  555. using (LoL_AutoAdder.lol_usersEntities lContext = new LoL_AutoAdder.lol_usersEntities())
  556. {
  557. var lUser = from item in lContext.euwbots
  558. where item.Region == this.WebScraper.LowerRegion
  559. && item.SummonerName == this.Username.ToLower()
  560. select item;
  561. try
  562. {
  563. if (lUser.Count() > 0)
  564. lUser.First().Fullfriendlist = true;
  565. lContext.SaveChanges();
  566. }
  567. catch (System.Reflection.TargetException ey)
  568. {
  569. Console.WriteLine(ey.Message);
  570. }
  571. this.Dispose();
  572. }
  573. }
  574.  
  575.  
  576.  
  577. }
  578. if (e.Presence.Type == PresenceType.subscribe && this.AcceptFriends && !this.disposed)
  579. {
  580. AddFriend(e.Presence.From, true);
  581. if (DefaultCommand != null)
  582. {
  583. DefaultCommand.BeginInvoke(e.Presence.From, new string[] { string.Empty }, async item =>
  584. {
  585. Task<string> lResult = (DefaultCommand.EndInvoke(item));
  586. var Result = await lResult;
  587. SendMessage(e.Presence.From, Result);
  588. RemoveFriend(e.Presence.From, false);
  589. lResult.Dispose();
  590. }, null);
  591. }
  592. }
  593. else if (e.Presence.Type == PresenceType.subscribed && !this.disposed)
  594. {
  595. _acceptedFriends++;
  596. lastAccepted = DateTime.Now;
  597. this.WebScraper.Logger.CountFriends++;
  598. using (LoL_AutoAdder.lol_usersEntities lContext = new LoL_AutoAdder.lol_usersEntities())
  599. {
  600. var lUser = from item in lContext.euw
  601. where item.Region == this.WebScraper.LowerRegion
  602. && item.SummonerID.ToString() == e.Presence.From.User
  603. select item;
  604. try
  605. {
  606. if (lUser.Count() > 0)
  607. lUser.First().Accept = true;
  608. lContext.SaveChanges();
  609. }
  610. catch (System.Reflection.TargetException ey)
  611. {
  612. Console.WriteLine(ey.Message);
  613. }
  614. }
  615. if (DefaultCommand != null)
  616. {
  617. DefaultCommand.BeginInvoke(e.Presence.From, new string[] { string.Empty }, async item =>
  618. {
  619. Task<string> lResult = (DefaultCommand.EndInvoke(item));
  620. var Result = await lResult;
  621. SendMessage(e.Presence.From, Result);
  622. RemoveFriend(e.Presence.From, false);
  623. lResult.Dispose();
  624. }, null);
  625. }
  626. }
  627.  
  628. var presenceMessage = e.Presence.ToString();
  629. if (GameStarted(presenceMessage) && e.Presence.Show == Show.dnd && Logged_In && Game_Start != null)
  630. {
  631. Game_Start(sender, new SummonerEventArgs(e.Presence.From));
  632. }
  633. else if (GameEnded(presenceMessage) && e.Presence.Show == Show.chat && Logged_In && Game_End != null)
  634. {
  635. Game_End(sender, new SummonerEventArgs(e.Presence.From));
  636. }
  637.  
  638. }
  639. public string Username { get; private set; }
  640. public int Min { get; private set; }
  641. public int Max { get; private set; }
  642. private DateTime lastAccepted;
  643. private void ChatLogin(string pUsername, string pPassword, Region pRegion)
  644. {
  645. pUsername = pUsername.Trim();
  646. pPassword = pPassword.Trim();
  647. Username = pUsername;
  648. if (!regionDictionary.ContainsKey(pRegion))
  649. throw new ArgumentException("Region not available yet");
  650. if (Chat == null)
  651. return;
  652. Chat.SetUsername(pUsername);
  653. Chat.SetXmppDomain("pvp.net");
  654. Chat.Port = 5223;
  655. Chat.Show = Matrix.Xmpp.Show.chat;
  656. Chat.Password = ("AIR_" + pPassword);
  657. Chat.Resource = "xiff";
  658. Chat.OldStyleSsl = true;
  659. Chat.Hostname = string.Concat("chat.", regionDictionary[pRegion], ".lol.riotgames.com");
  660. Chat.Open();
  661. }
  662.  
  663. public bool GameStarted(string presenceInput)
  664. {
  665. return presenceInput.Contains("gameStatus&gt;inGame&lt;/gameStatus");
  666. }
  667.  
  668. public bool GameEnded(string presenceInput)
  669. {
  670. return presenceInput.Contains("gameStatus&gt;outOfGame&lt;/gameStatus");
  671. }
  672. private string _clientVersion;
  673. private void ClientLogin(string pUsername, string pPassword, Region pRegion)
  674. {
  675. if (Client != null)
  676. Client.Connect(pUsername, pPassword, pRegion, _clientVersion);
  677. }
  678. public void ChangeStatus(int level, int wins, League league, string division)
  679. {
  680. Chat.SendPresence(Show.chat, "<body><profileIcon>508</profileIcon><statusMsg></statusMsg><dropInSpectateGameId>Shopuff</dropInSpectateGameId><featuredGameData>null</featuredGameData><level>" + level + "</level><wins>" + wins + "</wins><leaves>25</leaves><odinWins>148</odinWins><odinLeaves>1</odinLeaves><queueType /><rankedLosses>0</rankedLosses><rankedRating>0</rankedRating><tier>DIAMOND</tier><skinname>Lulu</skinname><gameQueueType>RANKED_SOLO_5x5</gameQueueType><timeStamp>1398886764092</timeStamp><gameStatus>outOfGame</gameStatus><rankedLeagueName></rankedLeagueName><rankedLeagueDivision>" + division + "</rankedLeagueDivision><rankedLeagueTier>" + league.ToStringValue() + "</rankedLeagueTier><rankedLeagueQueue>RANKED_SOLO_5x5</rankedLeagueQueue><rankedWins>" + wins + "</rankedWins></body>", 0);
  681. }
  682. public enum League
  683. {
  684. [StringValue("BRONZE")]
  685. Bronze,
  686. [StringValue("SILVER")]
  687. Silver,
  688. [StringValue("GOLD")]
  689. Gold,
  690. [StringValue("PLATINUM")]
  691. Platin,
  692. [StringValue("DIAMOND")]
  693. Diamond,
  694. [StringValue("CHALLENGER")]
  695. Challenger
  696. }
  697. private void Client_OnLogin(object sender, string username, string ipAddress)
  698. {
  699. //if (!this._lolSumm)
  700. // return;
  701. //Logged_In = true;
  702. //if (LoginSucceed != null)
  703. // LoginSucceed(this, System.EventArgs.Empty);
  704. //Action pAction = WebScraper.GetUserLoop;
  705. //pAction.BeginInvoke(pAction.EndInvoke, null);
  706. //ChangeStatus(69, 1337, League.Diamond, this._spamText);
  707. }
  708. private void Chat_OnLogin(object sender, Matrix.EventArgs e)
  709. {
  710. if (this._lolSumm)
  711. return;
  712. Logged_In = true;
  713. if (LoginSucceed != null)
  714. LoginSucceed(this, System.EventArgs.Empty);
  715. if (WebScraper == null)
  716. return;
  717. Action pAction = WebScraper.GetUserLoop;
  718. pAction.BeginInvoke(pAction.EndInvoke, null);
  719. ChangeStatus(69, 1337, League.Diamond, this._spamText);
  720. }
  721. private async Task<string> Message(Jid SummonerJID, params string[] pParams)
  722. {
  723. Task<string> lRes = Spamtext.ToTask<string>();
  724. var lText = await lRes;
  725. lRes.Dispose();
  726. return lText;
  727. }
  728.  
  729. private void Chat_OnMessage(object sender, Matrix.Xmpp.Client.MessageEventArgs e)
  730. {
  731.  
  732. if (!this.Logged_In)
  733. return;
  734. if (e.Message.Type == MessageType.chat)
  735. {
  736. Token.Parse(e.Message.Body.ToLower().Trim(), e.Message.From, newAction.Where(item => e.Message.Body.ToLower().Trim().IndexOf(item.Key) == 0 && !(e.Message.Body.Length == item.Key.Length) && e.Message.Body[item.Key.Length] == ' ').FirstOrDefault());
  737. }
  738. }
  739. private bool _flag = false;
  740. public void Deletefriends()
  741. {
  742. if (_flag)
  743. return;
  744. _flag = true;
  745. this._chat.RequestRoster();
  746. }
  747. private void Roster_Requested(object sender, Matrix.Xmpp.Roster.RosterEventArgs e)
  748. {
  749. if (_flag && this.Chat != null && this._logged_In && !this.disposed)
  750. this.RemoveFriend(e.RosterItem.Jid, true);
  751. }
  752. private void Roster_End(object sender, Matrix.EventArgs e)
  753. {
  754. _flag = false;
  755. }
  756. void Token_Parsed(object sender, ParsedEventArgs e)
  757. {
  758. // Result = Answer
  759. // e.Params = Params (for example: !Command Param1 Param2 ...)
  760. string Result = String.Empty;
  761. ParamAction pHolder = null;
  762. //Check whether the Command is registered or the Defaultcommand is enabled
  763. if (newAction.ContainsKey(e.ActCommand))
  764. {
  765. pHolder = newAction[e.ActCommand];
  766. }
  767. else if (DefaultCommand != null)
  768. {
  769. pHolder = DefaultCommand;
  770. }
  771. else
  772. {
  773. return;
  774. }
  775. //Call Function Asynchronous
  776. pHolder.BeginInvoke(e.User, e.Params, async item =>
  777. {
  778. var lRes = pHolder.EndInvoke(item);
  779. Result = await lRes;
  780. SendMessage(e.User, Result);
  781. lRes.Dispose();
  782. }, null);
  783.  
  784. }
  785.  
  786. public void SendMessage(Jid pUser, string pMessage)
  787. {
  788. if (Chat == null)
  789. return;
  790. Matrix.Xmpp.Client.Message newMessage = new Matrix.Xmpp.Client.Message();
  791. newMessage.To = pUser;
  792. newMessage.Type = Matrix.Xmpp.MessageType.chat;
  793. newMessage.Body = pMessage;
  794. Chat.Send(newMessage);
  795. }
  796. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement