Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2018
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.49 KB | None | 0 0
  1. const tmi = require('tmi.js')
  2. const haikudos = require('haikudos')
  3.  
  4. // Valid commands start with:
  5. let commandPrefix = '!'
  6. // Define configuration options:
  7. let opts = {
  8. identity: {
  9. username:
  10. password: 'oauth:' +
  11. },
  12. channels: [
  13.  
  14.  
  15. ]
  16. }
  17.  
  18. // These are the commands the bot knows (defined below):
  19. let knownCommands = {
  20. echo,
  21. playlist,
  22. twitter,
  23. commands,
  24. free,
  25. timemeout,
  26. frankerfacez,
  27. realdragon,
  28. random,
  29. test,
  30. mawio,
  31. decklist,
  32. play,
  33. roll,
  34. howdy,
  35. pyramid,
  36. lurk,
  37. multi,
  38. emotes,
  39. }
  40. const knownCommand = 'echo (!echo <text>), playlist, twitter, commands, free, timemeout, frankerfacez, realdragon, random (!random <number>), mawio, roll, howdy, pyramid, lurk, multi <twitch channel>'
  41.  
  42. // Function called when the "echo" command is issued:
  43. function echo(target, context, params) {
  44. // If there's something to echo:
  45. if (params.length) {
  46. // Join the params into a string:
  47. const msg = params.join(' ')
  48. // Send it back to the correct place:
  49. sendMessage(target, context, msg)
  50. } else { // Nothing to echo
  51. console.log(`* Nothing to echo`)
  52. }
  53. }
  54.  
  55. //function called when the pyramid command is issued:
  56. function pyramid(target, context) {
  57. msg = 'bliniCat1 bliniCat2\nbliniCat3 bliniCat4\nbliniCat1 bliniCat2 bliniCat1 bliniCat2\nbliniCat3 bliniCat4 bliniCat3 bliniCat4\nbliniCat1 bliniCat2 bliniCat1 bliniCat2\nbliniCat3 bliniCat4 bliniCat3 bliniCat4\nbliniCat1 bliniCat2 bliniCat1 bliniCat2\nbliniCat3 bliniCat4 bliniCat3 bliniCat4\nbliniCat1 bliniCat2\nbliniCat3 bliniCat4'
  58. msg.split('\n').forEach((line) => {
  59. sendMessage(target, context, line)
  60. })
  61. }
  62.  
  63. //function called when the play command is issued:
  64. function play(target, context) {
  65. if (context.username == '') {
  66. const msg = '!play'
  67. sendMessage(target, context, msg)
  68. }
  69. }
  70.  
  71. //function called when the lurk command is issued:
  72. function lurk(target, context) {
  73. const msg = 'i see u'
  74. sendMessage(target, context, msg)
  75. }
  76.  
  77. //function called when the multi command is issued:
  78. function multi(target, context, params) {
  79. const msg = 'http://multitwitch.tv/crafthai/' + params
  80. sendMessage(target, context, msg)
  81. }
  82.  
  83. //function called when the mawio command is issued:
  84. function mawio(target, context) {
  85. const msg = 'https://i.imgur.com/zg5XjCA.png'
  86. sendMessage(target, context, msg)
  87. }
  88.  
  89. //function called when the howdy command is issued:
  90. function howdy(target, context) {
  91. const msg = 'https://i.imgur.com/74l8A6F.png'
  92. sendMessage(target, context, msg)
  93. }
  94.  
  95. //function called when the decklist command is issued:
  96. function decklist(target, context) {
  97. const msg = 'https://mtgarena.pro/decks/#crafthai'
  98. sendMessage(target, context, msg)
  99. }
  100.  
  101. //function called when the emotes command is issued:
  102. function emotes(target, context) {
  103. if (context.username == '' || context.username == '' || context.username == '') {
  104. const msg = 'BIGFROG BLELELE DANCE EZclap FeelsLagMan ImTriggered monkaHmm monkaS MonkaU Pepega Pepika lickR PepePls lickL pepeLaugh PepegaPls POGSLIDE sumSmash wheelChonk YIKERS DISCOFROG PepegaChair POGSLIDECOGSLIDE momoLewd LAnoot BIGHAM AngeryBlob WeSmart HYPERROBDAB gachiBASS monkaSpeed OMEGALUL OkMan PartyBlob IncreasinglyAngeryCog'
  105. sendMessage(target, context, msg)
  106. }
  107. }
  108.  
  109. //function called when the test command is issued:
  110. function test(target, context) {
  111. if (context.username == '') {
  112. const msg = 'yea yea im up'
  113. sendMessage(target, context, msg)
  114. }
  115. }
  116.  
  117. //function called when the "roll" command is issued:
  118. function roll(target, context) {
  119. var msg = Number(6)
  120. msg = (Math.floor(Math.random() * 6) + 1)
  121. msg = msg.toString()
  122. sendMessage(target, context, msg)
  123.  
  124. }
  125.  
  126. //function called when the "random" command is issued:
  127. function random(target, context, params) {
  128. if (params.length) {
  129. // Join the params into a string:
  130. var msg = params.join()
  131. msg = Number(msg)
  132. msg = (Math.floor(Math.random() * msg) + 1)
  133. msg = msg.toString()
  134. sendMessage(target, context, msg)
  135. }
  136. }
  137.  
  138. //function called when the realdragon command is issued:
  139. function realdragon(target, context) {
  140. msg = 'Neck1\nNeckLikeThis\nNeck2\nNeck2\nNeck3'
  141. msg.split('\n').forEach((line) => {
  142. sendMessage(target, context, line)
  143. })
  144. }
  145.  
  146. //function called when the frankerfacez command is issued:
  147. function frankerfacez(target, context) {
  148. const msg = 'get frankerfacez here https://www.frankerfacez.com/ LickMe NeverGiveUp LickMe'
  149. sendMessage(target, context, msg)
  150. }
  151.  
  152. //function called when the playlist command is issued:
  153. function playlist(target, context) {
  154. const msg = 'https://open.spotify.com/playlist/6hH3dSO8SRxUoROREupfjH (this is reynad27\'s playlist)'
  155. sendMessage(target, context, msg)
  156. }
  157.  
  158. //function called when the "twitter" command is issued:
  159. function twitter(target, context) {
  160. //create the link
  161. const msg = 'https://www.twitter.com/crafthai'
  162. sendMessage(target, context, msg)
  163. }
  164.  
  165. //function called when the "timemeout" command is used
  166. function timemeout(target, context) {
  167. const msg = '/timeout ' + context.username + ' 120'
  168. sendMessage(target, context, msg)
  169. }
  170.  
  171. //function called when the "free" command is issued:
  172. function free(target, context) {
  173. const msg = 'please direct your attention to the top right above the video and use your free twitch prime sub'
  174. sendMessage(target, context, msg)
  175. }
  176.  
  177. //function called when the "commands" command is issued:
  178. function commands(target, context) {
  179. sendMessage(target, context, knownCommand)
  180. }
  181.  
  182. // Helper function to send the correct type of message:
  183. function sendMessage(target, context, message) {
  184. if (context['message-type'] === 'whisper') {
  185. client.whisper(target, message)
  186. } else {
  187. client.say(target, message)
  188. }
  189. }
  190.  
  191. // Create a client with our options:
  192. let client = new tmi.client(opts)
  193.  
  194. // Register our event handlers (defined below):
  195. client.on('message', onMessageHandler)
  196. client.on('connected', onConnectedHandler)
  197. client.on('disconnected', onDisconnectedHandler)
  198.  
  199. // Connect to Twitch:
  200. client.connect()
  201.  
  202. // Called every time a message comes in:
  203. function onMessageHandler(target, context, msg, self) {
  204. if (self || context.username == 'hnlbot') {
  205. return
  206. } // Ignore messages from the bot
  207.  
  208. if(msg.includes('gay')) {
  209. sendMessage(target, context, 'no u')
  210. }
  211.  
  212. if(msg.includes('frog')) {
  213. sendMessage(target, context, 'BIGFROG DANCE DANCE DANCE BIGFROG')
  214. }
  215.  
  216. if(msg.includes('PepePls')) {
  217. sendMessage(target, context, 'PepePls')
  218. }
  219.  
  220. if(msg.includes('jermaJup1 jermaJup2')) {
  221. sendMessage(target, context, 'no jup')
  222. }
  223.  
  224. if(msg.includes('retard')) {
  225. no = '@' + context.username + ' u cant say that'
  226. timeout = '/timeout' + context.username + '5'
  227. sendMessage(target, context, timeout)
  228. sendMessage(target, context, no)
  229. }
  230.  
  231. if(msg.includes('cat')) {
  232. bliniCat = 'bliniCat1 bliniCat2\nbliniCat3 bliniCat4'
  233. bliniCat.split('\n').forEach((line) => {
  234. sendMessage(target, context, line)
  235. })
  236. }
  237.  
  238. if(msg.includes('stopS')) {
  239. sendMessage(target, context, 'no')
  240. }
  241.  
  242. if(msg.includes(':\)') || msg.includes(':\(') || msg.includes(':\\')|| msg.includes(':')) {
  243. sendMessage(target, context, 'smileR')
  244. }
  245.  
  246. if(msg.includes('nice')) {
  247. sendMessage(target, context, 'ty')
  248. }
  249.  
  250. if(msg.includes('epic')) {
  251. sendMessage(target, context, 'Okay, this is epic')
  252. }
  253.  
  254. if(msg.includes('whats this') || msg.includes('what\'s this') || msg.includes('wats this')) {
  255. sendMessage(target, context, 'owo')
  256. }
  257.  
  258. // This isn't a command since it has no prefix:
  259. if (msg.substr(0, 1) !== commandPrefix) {
  260. console.log(`[${target} (${context['message-type']})] ${context.username}: ${msg}`)
  261. return
  262. }
  263.  
  264. // Split the message into individual words:
  265. const parse = msg.slice(1).split(' ')
  266. // The command name is the first (0th) one:
  267. const commandName = parse[0]
  268. // The rest (if any) are the parameters:
  269. const params = parse.splice(1)
  270.  
  271. // If the command is known, let's execute it:
  272. if (commandName in knownCommands) {
  273. // Retrieve the function by its name:
  274. const command = knownCommands[commandName]
  275. // Then call the command with parameters:
  276. command(target, context, params)
  277. console.log(`* Executed ${commandName} command for ${context.username}`)
  278. }
  279. else {
  280. console.log(`* Unknown command ${commandName} from ${context.username}`)
  281. }
  282. }
  283.  
  284. // Called every time the bot connects to Twitch chat:
  285. function onConnectedHandler(addr, port) {
  286. console.log(`* Connected to ${addr}:${port}`)
  287. }
  288.  
  289. // Called every time the bot disconnects from Twitch:
  290. function onDisconnectedHandler(reason) {
  291. console.log(`Disconnected: ${reason}`)
  292. process.exit(1)
  293. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement