The easy to use and full featured Irc Bot everyone is talking about!
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Helper.cs 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Combot.IRCServices
  7. {
  8. public static class Helper
  9. {
  10. public static string ModeToString(this UserModeInfo mode)
  11. {
  12. return string.Format("{0}{1}", (mode.Set) ? "+" : "-", mode.Mode.ToString());
  13. }
  14. public static string ModesToString(this List<UserModeInfo> modes)
  15. {
  16. string modeStr = string.Empty;
  17. bool curSet = true;
  18. foreach (UserModeInfo mode in modes)
  19. {
  20. bool addSet = false;
  21. if (curSet != mode.Set)
  22. addSet = true;
  23. modeStr += ((addSet) ? ((curSet) ? "+" : "-") : string.Empty) + mode.Mode.ToString();
  24. curSet = mode.Set;
  25. }
  26. return modeStr;
  27. }
  28. public static string ModeToString(this ChannelModeInfo mode)
  29. {
  30. string param = string.Empty;
  31. if (!string.IsNullOrEmpty(mode.Parameter))
  32. param = " " + mode.Parameter;
  33. return string.Format("{0}{1}{2}", (mode.Set) ? "+" : "-", mode.Mode.ToString(), param);
  34. }
  35. public static string ModesToString(this List<ChannelModeInfo> modes)
  36. {
  37. string modeStr = string.Empty;
  38. bool curSet = true;
  39. bool addSet = true;
  40. foreach (ChannelModeInfo mode in modes)
  41. {
  42. modeStr += ((addSet) ? ((mode.Set) ? "+" : "-") : string.Empty) + mode.Mode.ToString();
  43. addSet = (curSet == mode.Set);
  44. curSet = mode.Set;
  45. }
  46. string param = string.Empty;
  47. foreach (ChannelModeInfo mode in modes)
  48. {
  49. if (!string.IsNullOrEmpty(mode.Parameter))
  50. param += " " + mode.Parameter;
  51. }
  52. modeStr += param;
  53. return modeStr;
  54. }
  55. }
  56. }