A month is just about right for a quick trip through Morocco. Or an exploration of Togo and Benin, with a chunk of Ghana or Burkina thrown in. But this assumes you know how to ride, and know how to handle yourself in those sorts of places.
But if all you really want to do is ride ride ride (plus collect visas and deal with whatever shipping nightmares you run into), without stopping to do more than glance around and snap a few photos, then I think you can do Lome to Spain in 35 days. If you don't get hurt, break down or get sick....chances of which are better than average.
You've already got most of the information you need to plan your trip. Get a Michelin West/North Africa map and start counting miles. Divide by 200/day (my rough rule of thumb) or the 225-250 quoted above. You need to learn to ride, too, right? Then, you need to learn to ride in the Togo--not an easy place to start, but then again neither is Morocco, Ghana, Burkina Faso or the others--they're different from, say, Denver by an order of magnitude. You're going to buy a bike in Togo? Without speaking French, or do I misremember this part? Maybe try Ghana instead; that'll be difficult enough, and more expensive than it would be in the States, with less selection (and little in the way of real protective gear).
I'm not trying to be a jerk about this, but you could have the adventure of your life learning to ride a bike, then touring Spain and Morocco for 35 days. Or rent a bike in Accra (there's an American/Ghanian couple there renting various bikes). Why back yourself into a corner from which you have no ready escape, rather than plan something open-ended for your first time out? And why in the world Togo, anyway? It's a nice country with fun riding in the hills, but it's not exactly Africa For Beginners.
Keep asking questions, and keep adjusting your plans....but first buy a map and at least one guidebook and do some of the basic research.