Advertisement
Guest User

a

a guest
Jul 15th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. const tm = require("tmi.js");
  2.  
  3. const options = {
  4. options: {
  5. debug: true,
  6. },
  7. connection: {
  8. cluster: "aws",
  9. reconnect: true,
  10. },
  11. identity: {
  12. username: "some_kind_of_cheese",
  13. password: "",
  14. },
  15. channels: ["MeACheese"],
  16. };
  17.  
  18. const client = new tmi.client(options);
  19.  
  20. client.connect();
  21.  
  22.  
  23. const os = require('os');//uptime command - system uptime
  24. const prefixSmart = "?";
  25.  
  26. const smartcmd = [
  27.  
  28. {
  29. name: prefixSmart + "uptime",
  30. aliases: prefixSmart + "up",
  31. invocation: async (channel, user, message, args) => {
  32.  
  33. try{ //check the code for errors and send them to catch
  34. function format(seconds){
  35. function pad(s){
  36. return (s < 10 ? '0' : '') + s;
  37. }
  38.  
  39. var hours = Math.floor(seconds / (60*60));
  40. var minutes = Math.floor(seconds % (60*60) / 60);
  41. var seconds = Math.floor(seconds % 60);
  42. return hours + 'h ' + minutes + 'm ' + seconds + "s";
  43. }
  44. var uptime = process.uptime();
  45.  
  46. const os = require('os');
  47. const up = os.uptime() / 3600; //system uptime in hours
  48. const up2 = os.uptime() / 86400; //system uptime in days
  49.  
  50. var linecount = require('linecount')
  51. const lines = await new Promise((resolve, reject) => { //line count
  52.  
  53. linecount('./haxk.js', (err, count) => {
  54. if (err) {
  55. reject(err);
  56. }
  57. else{
  58. resolve(count);
  59. }
  60. });
  61. });
  62. //return message to client.say
  63. return user["display-name"] +
  64. ", my dank code is running for " + format(uptime) +
  65. " and has " + lines + " lines FeelsDankMan ," +
  66. " also my system runs for: " + up.toFixed(1) +
  67. "h (" + up2.toFixed(2) + " days)";
  68.  
  69. } catch(err) { //catch errors and optionally send error message to chat
  70.  
  71. return user['display-name'] +
  72. ", " +
  73. err +
  74. " FeelsDankMan !!!";
  75. }
  76. }
  77. },
  78. ];
  79.  
  80. try {
  81.  
  82. smartcmd.forEach(async smart => {
  83. if
  84. (
  85. (message.startsWith(smart.name) && message.split(" ")[0] == smart.name) ||
  86. //if message starts with command name, return command invocation (contents)
  87. (smart.aliases && message.startsWith(smart.aliases))
  88. ) {
  89. let result = await smart.invocation(channel, user);
  90.  
  91. if (repeatedMessages[channel] === result) { //if previous message was the same, send next message with unicode bypass
  92. result += " \u{E0000}";
  93. }
  94.  
  95. repeatedMessages[channel] = result;
  96. client.say(channel, result);
  97.  
  98. }
  99. });
  100. });
  101. } catch(err) { //send errors to chat
  102.  
  103. return user['display-name'] +
  104. ", " +
  105. err +
  106. " FeelsDankMan !!!";
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement