Reddit bot error : There was an error: 'unicode' object is not callable

Learn Programming - 26 min 26 sec ago

Hi all.
First time posting here.
I have an issue and was wondering if I could get some help from the community here.

I am currently trying to setup a bot which monitors keywords on a subreddit and then sends an alert to myself via PM.

I am using the code I found here ->

I have got the bot setup,and running, it can detect when a keyword has been posted on the specific subreddit. but when it detects the keyword it posts the following on terminal

There was an error: 'unicode' object is not callable

and does not send the PM

When I close the bot down, I get the following output

There was an error: 'unicode' object is not callable

^CTraceback (most recent call last):

File "", line 48, in <module>


File "", line 44, in main


File "", line 43, in main

sleep(60) # wait for 60 seconds before restarting


Does anyone have any idea how I could fix this problem?

submitted by /u/mlodypl123
[link] [comments]

I'm making an app for college minor project [suggestions needed]

Learn Programming - 33 min 46 sec ago

I'm making android app for minor project where people can take mock test for exams.

I need suggestions, I would really appreciate if look into it

Link :

submitted by /u/prashant13b
[link] [comments]

javafx - button size doesn't change no matter what i do.

Learn Programming - Fri, 11/16/2018 - 22:49
Region windowSpace = new Region(); HBox window = new HBox(); Button btnmin = new Button(); Button btnmax = new Button(); Button btnclose = new Button(); btnmin.setMaxSize(6989, 7800); window.setMaxHeight(165); btnmin.setStyle("-fx-background-image: url('/images/btnmin.png'); -fx-font: 0 Arial; -fx-pref-width: 16px; -fx-pref-height: 14px;"); window.setStyle("-fx-background-color: linear-gradient(from 25% 25% to 100% 100%, #000080, #1084D0)"); HBox.setHgrow(windowSpace, Priority.ALWAYS); window.getChildren().addAll(windowSpace,btnmin,btnmax,btnclose); btnclose.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Stage stage = (Stage) root.getScene().getWindow(); stage.close(); } }); BorderPane.setAlignment(btnmin, Pos.TOP_RIGHT); BorderPane.setAlignment(btnmax, Pos.TOP_RIGHT); BorderPane.setAlignment(btnclose, Pos.TOP_RIGHT);

No matter what I do or what I try, nothing I do makes the button size smaller. There's no additional code that changes the buttons here. What am I doing wrong?

submitted by /u/IoI_xD
[link] [comments]

how to use classes

Learn Programming - Fri, 11/16/2018 - 22:48

I have a "GameEvents" class that I made and was wondering if I made it correctly.

I'm only asking because I have nothing in my private, an empty constructor and destructor. From my understanding, there is no need to put anything in those, in my case, right?


#pragma once #include "Global.h" #include "Player.h" #include "DeveloperTesting.h" using namespace std; class GameEvents { public: GameEvents(); ~GameEvents(); void testGameEvent(); void event1(); void event2(); void event3(); void event4(); void event5(); void event6(); void event7(); void event8(); void event9(); void event10(); void event11(); void event12(); void checkDecision(int decision); };


#include "GameEvents.h" extern Global global; vector<string> Crew; GameEvents::GameEvents() { } GameEvents::~GameEvents() { } void GameEvents::testGameEvent() //delete test from title { int roll; roll = global.randomRoll(12,1); //passes a random numer 1-12 into roll switch (roll) { case 1: event1(); break; case 2: event2(); break; case 3: event3(); break; case 4: event4(); break; case 5: event5(); break; case 6: event6(); break; case 7: event7(); break; case 8: event8(); break; case 9: event9(); break; case 10: event10(); break; case 11: event11(); break; case 12: event12(); break; } } void GameEvents::event1() { cout << "Oh no! There is a space dog in sight. What do you want to do, Captain?" << endl; cout << endl << "1. Attack it!" << endl; cout << "2. Avoid it!" << endl; int decision; cin >> decision; checkDecision(decision); switch (decision) { case 1: if (global.randomRoll(100, 1) < 50) { cout << "The attack was a success! You've defeated the Space Dog." << endl; cout << endl << "You looted the space dog and found $50" << endl; p.setMoney(p.getMoney() + 50); cout << " You now have: $" << p.getMoney(); } else { cout << "The attack was a failure! The Space Dog defeated you." << endl; p.setHealth(p.getHealth() - 10); cout << "Your health is now: " << p.getHealth() << "/" << p.getmaxHealth() << " hp" << endl; } break; case 2: if (global.randomRoll(100, 1) < 50) { cout << "Nice job, Captain! You successfully avoided the space dog!" << endl; } else { cout << "Bad luck! The space dog spotted you and has attacked!" << endl; p.setHealth(p.getHealth() - 15); cout << "Your health is now: " << p.getHealth() << "/" << p.getmaxHealth() << " hp" << endl; } break; } } void GameEvents::event2() { global.clearScreen(); cout << "Your rocket has ran into a large asteroid! What's the decision captain?" << endl; cout << endl; cout << "1. Take it to a space mechanic." << endl; cout << "2. Ignore it and risk the chance of more problems." << endl; int decision; cin >> decision; checkDecision(decision); switch (decision) { case 1: cout << endl; cout << "You took it to a mechanic and he repaired your rocket!" << endl; cout << "You were charged: $100" << endl; p.setMoney(p.getMoney() - 100); cout << "You now have: $" << p.getMoney(); break; case 2: if (global.randomRoll(100, 1) < 50) { cout << "Your rocket seems to be fine... but the crew seems to be shaken up by the impact." << endl; p.setHealth(p.getHealth() - 5); //takes 55 health away cout << "Your health is now: " << p.getHealth() << "/" << p.getmaxHealth()<< " hp" << endl; } else { cout << "Your rocket broke down!" << endl; cout << "You had the space mechanic fix it and he charged you: $200" << endl; p.setMoney(p.getMoney() - 200); } break; } } void GameEvents::event3() { cout << "this is event 3" << endl; cout << "There is a meteor storm. Do you want to choose to go through?" << endl; cout << "You will be given options and a choice" << endl; cout << "From whatever choice you choose, it will use randNum 1-100 to determine success or failure" << endl; } void GameEvents::event4() { cout << "this is event 4" << endl; cout << "your crew has become sick, would you like to do ___" << endl; cout << "You will be given options and a choice" << endl; cout << "From whatever choice you choose, it will use randNum 1-100 to determine success or failure" << endl; } void GameEvents::event5() { global.clearScreen(); cout << "You passed a planet, would you like to explore?" << endl; cout << "1. Yes." << endl; cout << "2. No." << endl; int decision; cin >> decision; checkDecision(decision); switch (decision) { case 1: if (global.randomRoll(100, 1) < 50) { cout << "Great decision, " << p.getName() << "!" << endl; cout << "You found treasure and sold it for $200!" << endl; p.setMoney(p.getMoney() + 200); cout << "You now have: $" << p.getMoney() << endl; } else { cout << "While you were out exploring... Space Dogs raided your rocket." << endl; p.setFood(p.getFood() - 10); cout << "You now have: " << p.getFood() << "/" << p.getmaxFood() << " pounds of food left." << endl; //this can go into negatives. use if x<0, ... } break; case 2: if (global.randomRoll(100, 1) < 50) { cout << "Instead of exploring, you decided to rest." << endl; if (p.getHealth() <= (p.getmaxHealth() - 10)) { p.setHealth(p.getHealth() + 10); cout << "Your health is now: " << p.getHealth()<<"/"<<p.getmaxHealth(); } if (p.getHealth() > (p.getmaxHealth() - 10)) //ensures i can't go over 101 health.. it'll just set it to 100 hp. { p.setHealth(p.getmaxHealth()); cout << "Your health is now: " << p.getHealth() << "/" << p.getmaxHealth(); } } else { cout << "As you pass, you notice the entire planet is gold plated. You also realize that those weren't mountains." << endl; cout << "They were piles of gold." << endl; } break; } } void GameEvents::event6() { cout << "this is event 6" << endl; cout << "Space pirates are attacking. Flee or fight?" << endl; cout << "You will be given options and a choice" << endl; cout << "From whatever choice you choose, it will use randNum 1-100 to determine success or failure" << endl; } void GameEvents::event7() { cout << "this is event 7" << endl; //srand((unsigned)(time(0))); //int randNum = 2; //cout << "Your crew member, "<< Crew[randNum] << " broke his leg. What do you want to do?" << endl; cout << "From whatever choice you choose, it will use randNum 1-100 to determine success or failure" << endl; } void GameEvents::event8() { cout << "this is event 8" << endl; cout << "You will be given options and a choice" << endl; cout << "From whatever choice you choose, it will use randNum 1-100 to determine success or failure" << endl; } void GameEvents::event9() { cout << "this is event 9" << endl; cout << "You will be given options and a choice" << endl; cout << "From whatever choice you choose, it will use randNum 1-100 to determine success or failure" << endl; } void GameEvents::event10() { cout << "this is event 10" << endl; cout << "You will be given options and a choice" << endl; cout << "From whatever choice you choose, it will use randNum 1-100 to determine success or failure" << endl; } void GameEvents::event11() { cout << "this is event 11" << endl; cout << "You will be given options and a choice" << endl; cout << "From whatever choice you choose, it will use randNum 1-100 to determine success or failure" << endl; } void GameEvents::event12() { cout << "this is event 12" << endl; cout << "You will be given options and a choice" << endl; cout << "From whatever choice you choose, it will use randNum 1-100 to determine success or failure" << endl; } void GameEvents::checkDecision(int decision) { while (decision >= 3) { cout << "Invalid input. Try again." << endl; cin >> decision; cin.clear(); } }

submitted by /u/yestyleryes
[link] [comments]

Two friends

Learn Programming - Fri, 11/16/2018 - 22:47

If two childhood friends meet each other after school and both are computer science engineers now, on what basis ( number of programming languages or problem solving or CS knowledge ) is it correct to judge which in is best among both?

submitted by /u/ramhemanth3
[link] [comments]

Need help with Python 3.7 school assignment

Learn Programming - Fri, 11/16/2018 - 22:43

*Everything is tabbed correctly, reddit isn't carrying over the spacing.*

The assignment is:

  • Create a list that contains 12 string values: the names of the months.
  • Open the monthlySales.txt file.
  • Read the numbers into a list and convert the numbers from string to float.
  • Close the file.
  • Prompt the user to enter a month number from 1 to 12.
  • If the user does not enter a valid number, continue to prompt the user until an integer from 1 to 12 is entered. (Hint: use a while loop.)
  • When a valid number is entered, display the sales value for the corresponding month (formatted with commas and two decimal places).
  • Hint: if you subtract 1 from the number that is entered, you will have the correct index value for the list of sales numbers.
  • Use a for loop to total the values in the list containing the sales numbers.

I'm using the following code so far:

month_name = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

# open monthlysales.txt, convert it to a list and close file

sales = open("monthlysales.txt", "r")

sales_list = sales.readlines()


sales_list_float = [float(x) for x in sales_list]

# strip off the "\n" from each list item

number_of_list_item = 0

while number_of_list_item < len(sales_list):

sales_list[number_of_list_item] = sales_list[number_of_list_item].rstrip('\n')

number_of_list_item = number_of_list_item + 1

# input - request input from user to enter month number. If number is not valid, prompt user until valid number is entered.

month_num = float(input("Enter a month number (1-12): "))

while month_num < 1 or month_num > 12:

month_num = float(input("Invalid Entry. Enter a month number (1-12): "))

month_num = month_num - 1

print ("The", month_name[month_num], "sales total is:", sales_list_float[month_num])

I've attempted to convert the imported list from str to float and I think I have that figured out, however I'm getting the error message (Line 34 is the print line):

Traceback (most recent call last):

File "C:/Users/Azunia/Desktop/College/Python/My Solutions/Ch7Text/", line 34, in <module>

print ("The", month_name[month_num], "sales total is:", sales_list_float[month_num])

TypeError: list indices must be integers or slices, not float

I've attempted to google the error, but every answer just seems well beyond my understanding.

submitted by /u/Azunias
[link] [comments]

How would you code a streaming app?

Learn Programming - Fri, 11/16/2018 - 22:42

How would you code an app like the bs app where it grabs links from a specific source and puts them all in one app?

submitted by /u/Kurumi_Fortune
[link] [comments]

curly bracket ~ programmer greatest enemy

Learn Programming - Fri, 11/16/2018 - 22:25

This curly bracket is making me crazy,

my code don't work because of failing to see the excess curly bracket... :D

submitted by /u/lampheart
[link] [comments]

Good source for documentation on credit card payments.

Learn Programming - Fri, 11/16/2018 - 22:24

Has anybody have experience setting up credit card payment? Any documentation or website I could use as a guide?

submitted by /u/darcMadder
[link] [comments]


Learn Programming - Fri, 11/16/2018 - 22:13

What's the point of pointers? I understand the concept that it points to the address of another variable but what can I use it for?

It would help if you could speak in the context of building a text based game, as that's what I'm working on right now.

In what situations would I need to use a pointer when coding my game?

submitted by /u/yestyleryes
[link] [comments]

Keep learning c++ for better foundations or learn AI/Android app development ?

Learn Programming - Fri, 11/16/2018 - 21:24

So I am currently learning c++ (2nd year in college) created console-projects in it like Tic-tac-toe, Snake, Hangman and Space Invader and trying to keep improving by solving daily challenges/problems.

But to be honest, I am not sure what to do. My main reason for continuing to learn C++ is that it would help me transfer my skills to other languages much faster/better, not that I am learning it because I want to do something specific with C++ that I can't do better in other languages.

I have always had fantasies about creating my own AI ( probably from reading wayyy too much fantasy novels ) and mobile apps, and each time I want to start learning about it, I keep stopping myself and saying: "Later! Focus on learning all of C++ first! ( since I already started with it and don't find it difficult )" ; But I feel like that this mentality is wrong and that it would burn/tire me out quickly, where as I could just start with something like python/java/kotlin and build what I wanted through their more end-goal supporting libraries and frameworks.

tl;dr: What should I do? Do I keep learning c++ and lay my foundations with it then go exploring on what I like later? Or do I go and learn a language that would bring me faster to my end goal(AI/mobile app development) then continue learning programming through it?

// Sorry for my bad English

submitted by /u/kandeel4411
[link] [comments]

I wish to write a matrix op lib...

Learn Programming - Fri, 11/16/2018 - 21:17

I wish to write a matrix op lib, and besides a data structure, I want to include operations such as inverse, transpose, and determinant as well. But what else? What other ops can I include? These three are all that I know of. Thanks a lot.

PS: It's a 2x2 matrix lib, just written for the sake of practice. I can't really handle anything above 2x2.

submitted by /u/Lithy_Eum
[link] [comments]

Complete newbie: How do I make UIs for programs?

Learn Programming - Fri, 11/16/2018 - 21:06

First I want to apologise up front for my obvious ignorance in this post, I don't know who to ask about these things so I feel quite stupid. I'd like to at least talk to someone, as my whole programming knowledge has been in solitary.

I specifically want to create (or hire someone to create(feel free to pm me)) a tool to use on my own PC, to interact with google ads, using the script function there and the Google API. That's my end goal. I have ideas, I just don't know how to make them a reality.

I've tried a few times to learn python but I just don't seem to get it or understand how to use the whole command line thing.

I do have experience with basic front-end code for web design, and I did pretty well at using javascript in unity years ago, but this is the extent of my knowledge. I always have idea for things I want to make, but I never have the ability to bring them to life. I often create recorded KB&Mouse macros but get frustrated at the limitations.

Is there some way I can create UIs quickly? like a WYSIWYG editor, drag a button, add a checkbox, add some text, and 'when you press the button X happens'?

I know I'll need to learn the code to happen when you press the button, but I'm a much more visual thinker so feel this would be a good start! I usually find it easier to understand something by reverse engineering them. I get so tired sitting through hours of 'this is how to add a number' (etc) if I don't have a reason. Are there examples of simple programs you can analyse, see them running and see which bits of code provide each function?

submitted by /u/_SGP_
[link] [comments]

Question about landing an internship without being in a CS program

Learn Programming - Fri, 11/16/2018 - 20:56

Hey guys, I've been hacking away at Java since highschool and have done quite a few personal projects, and was wondering about how realistic it is to land a programming internship without being enrolled in a CS program. I'm a junior enrolled in a non-cs program and don't have any programming classes on my resume, but I'm pretty solid on data structures and have a github (that I'd prefer not to share here) with a few personal projects, one with simple image manipulation, an extensible command line tool for creating and working on flash cards, and put up a really simple bitcoin flipping bot last weekend.

As I understand it, it's hard enough to get an internship even if you're currently enrolled in a computer science program, so I wanted to see if anybody here has any input. I'm happy just programming as a hobbyist, but am curious to know how feasible it would be to make some money from it, and what steps would be necessary to make it a reality.


submitted by /u/rob-job
[link] [comments]

[C#] Getting an ally on the players team to go towards a random enemy on the other team?

Learn Programming - Fri, 11/16/2018 - 20:36

Hello! I'm pretty new to programming in general but i have been trying to figure out how to get an ally on my team to go towards a random enemy on the other team. I have seen a fair bit of info on using arrays and lists to get random spawning and such but nothing so far has been what i'm looking for. I also still don't really understand how arrays and lists work ( in the sense of accessing whats inside of them and getting things from particular game objects ).

Also i haven't listed any parts of the code here because i am pretty certain everything I've written has been completely wrong and useless.

submitted by /u/_CatGang
[link] [comments]

Getting NameError in rspec when trying to test an output that contains a variable.

Learn Programming - Fri, 11/16/2018 - 20:32



i'm trying to test

it("returns similar letters if not an anagram") do testing ="quick", "quack'") expect(testing.anagram_check()).to(eq("Not an Anagram or an Antigram but " + (@word1 - antigram).join(',') + " " + "are alike")) end

But getting

NameError: undefined local variable or method `antigram' for #<RSpec::ExampleGroups::AnagramCheck:0x007f97f11980d0> # ./spec/anagram_test_spec.rb:20:in `block (2 levels) in <top (required)>'

From what I've read it has something to do with scope?

Maybe something involving let?

How do I format this in rspec correctly so that I can test a method output that returns a variable from within the method?

submitted by /u/Centipededia
[link] [comments]